Skip to content

Commit

Permalink
425: Add new Metric Prefixes to EBNFUnitFormat
Browse files Browse the repository at this point in the history
Task-Url: #425
  • Loading branch information
keilw committed Nov 14, 2024
1 parent 735c7c9 commit 61cae50
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ public void testFormatN() {
}

@Test
// TODO address https://github.com/unitsofmeasurement/uom-se/issues/145
public void testFormatmm() {
final String s = format.format(MILLI(METRE));
assertEquals("mm", s);
Expand Down
47 changes: 43 additions & 4 deletions src/test/java/tech/units/indriya/format/EBNFPrefixTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import static tech.units.indriya.unit.Units.METRE;

import javax.measure.Quantity;
import javax.measure.Unit;
import javax.measure.format.UnitFormat;
import javax.measure.quantity.Length;
import javax.measure.quantity.Mass;
Expand All @@ -64,8 +65,6 @@ static void init() {

@Test
public void testKilo() {
// TODO how to handle equals for units?
// assertEquals(KILOGRAM.getSymbol(), KILO(GRAM).getSymbol());
assertEquals(format.format(KILOGRAM), format.format(KILO(GRAM)));
}

Expand Down Expand Up @@ -124,7 +123,7 @@ public void testMilli4() {
}

@Test
public void testMicro2() {
public void testMicro() {
Quantity<Length> m1 = Quantities.getQuantity(1.0, Units.METRE);
assertNumberEquals(1d, m1.getValue(), 1E-12);
assertEquals("m", format.format(m1.getUnit()));
Expand Down Expand Up @@ -161,11 +160,39 @@ public void testQuetta() {
assertEquals("Ql", format.format(QUETTA(LITRE)));
}

@Test
public void testRonna() {
assertEquals("Rm", format.format(RONNA(METRE)));
}

@Test
public void testQuecto() {
assertEquals("ql", format.format(QUECTO(LITRE)));
}

@Test
public void testRonto() {
assertEquals("rg", format.format(RONTO(GRAM)));
}


@Test
public void testPArseMilli() {
final Unit<?> m = format.parse("mg");
assertEquals(m, MILLI(Units.GRAM));
}

@Test
public void testParseRonna() {
final Unit<?> l = format.parse("Rm");
assertEquals(l, RONNA(METRE));
}

@Test
public void testParseQuecto() {
final Unit<?> v = format.parse("ql");
assertEquals(v, QUECTO(LITRE));
}

@Test
public void testHashMapAccessingMap() {
assertThat(LITRE.toString(), is("l"));
Expand Down Expand Up @@ -227,4 +254,16 @@ public void testZebi() {
public void testYobi() {
assertEquals("Yig", format.format(YOBI(GRAM)));
}

@Test
public void testParseKibiL() {
final Unit<?> v = format.parse("Kil");
assertEquals(v, KIBI(LITRE));
}

@Test
public void testParseMebi() {
final Unit<?> l = format.parse("Mim");
assertEquals(l, MEBI(METRE));
}
}

0 comments on commit 61cae50

Please sign in to comment.