Skip to content

Commit

Permalink
59: Add missing UCUM units
Browse files Browse the repository at this point in the history
Task-Url: #59
  • Loading branch information
keilw committed Sep 4, 2020
1 parent 1a3a593 commit c56c92d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ucum/src/main/java/systems/uom/ucum/UCUM.java
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ public static UCUM getInstance() {

public static final Unit<Dimensionless> INTERNATIONAL_UNIT_ALT = addUnit(new AlternateUnit<Dimensionless>(INTERNATIONAL_UNIT, "i.U."), "International Unit", "i.U.");

// public static final Unit ARBITRARY_UNIT = UNDEFINED;
public static final Unit<Dimensionless> ARBITRARY_UNIT = addUnit(new AlternateUnit<Dimensionless>(ONE, "arb. U"), "Arbitrary Unit", "arb. U");
// public static final Unit US_PHARMACOPEIA = UNDEFINED;
// public static final Unit GPL = UNDEFINED;
// public static final Unit MPL = UNDEFINED;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

public class SystemOfUnitsServiceTest {
private static final String EXPECTED_SYSTEM_NAME = "Unified Code for Units of Measure";
private static final int NUM_OF_UNITS = 247;
private static final int NUM_OF_UNITS = 248;

private static SystemOfUnitsService defaultService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@

import org.junit.jupiter.api.Test;

import tech.units.indriya.ComparableUnit;


/**
* @author <a href="mailto:[email protected]">Werner Keil</a>
Expand Down Expand Up @@ -401,8 +403,17 @@ public void testFormatUCUMPrintWithPositivePrefix() {
@Test
public void testNewton() {
final UnitFormat format = UCUMFormat.getInstance(PRINT);
Unit newton = KILO(GRAM).multiply(METER).divide(SECOND).divide(SECOND);
ComparableUnit newton = (ComparableUnit) KILO(GRAM).multiply(METER).divide(SECOND).divide(SECOND);
assertTrue(newton.isEquivalentTo(NEWTON));
assertEquals("kg.m/s2", format.format(newton));
}


@Test
public void testBaud() {
final UnitFormat format = UCUMFormat.getInstance(PRINT);
assertEquals("Bd", format.format(BAUD));
final UnitFormat formatCS = UCUMFormat.getInstance(CASE_SENSITIVE);
assertEquals(BAUD, formatCS.parse("Bd"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
package systems.uom.ucum.format;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static systems.uom.ucum.UCUM.LITER;
import static systems.uom.ucum.UCUM.LITER_DM3;
Expand Down Expand Up @@ -68,6 +69,12 @@ public void testParseUCUMCSUppercaseLiter() {
assertEquals(LITER, FORMAT_CS.parse("L"));
}

@Test
public void testParseUCUMCSUppercaseLiterDivision() {
final Unit<?> literDiv = FORMAT_CS.parse("103/L");
assertEquals("103/L", FORMAT_CS.format(literDiv));
}


@Test
public void testFormatUCUMCI() {
Expand Down

0 comments on commit c56c92d

Please sign in to comment.