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 Aug 18, 2024
1 parent 7a33470 commit 25ff7a8
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 21 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
build:
docker:
# specify the version you desire here
- image: cimg/openjdk:17.0.9
- image: cimg/openjdk:21.0.2

working_directory: ~/repo

Expand Down Expand Up @@ -35,7 +35,7 @@ jobs:
deployment:
docker:
# specify the version you desire here
- image: cimg/openjdk:17.0.9
- image: cimg/openjdk:21.0.2

working_directory: ~/repo

Expand Down
18 changes: 18 additions & 0 deletions ci-toolchains.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,22 @@
<jdkHome>JDK_home</jdkHome>
</configuration>
</toolchain>
<toolchain>
<type>jdk</type>
<provides>
<version>17</version>
</provides>
<configuration>
<jdkHome>JDK_home</jdkHome>
</configuration>
</toolchain>
<toolchain>
<type>jdk</type>
<provides>
<version>21</version>
</provides>
<configuration>
<jdkHome>JDK_home</jdkHome>
</configuration>
</toolchain>
</toolchains>
2 changes: 1 addition & 1 deletion src/main/config/indriya clean install.launch
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_ATTR_USE_ARGFILE" value="false"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_SHOW_CODEDETAILS_IN_EXCEPTION_MESSAGES" value="true"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_CLASSPATH_ONLY_JAR" value="false"/>
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17/"/>
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-21/"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms1024m -Xmx2048m -XX:+UseG1GC"/>
<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${workspace_loc:/indriya}"/>
</launchConfiguration>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
# Units of Measurement Reference Implementation
# Copyright (c) 2005-2023, Jean-Marie Dautelle, Werner Keil, Otavio Santana.
# Copyright (c) 2005-2024, Jean-Marie Dautelle, Werner Keil, Otavio Santana.
#
# All rights reserved.
#
Expand Down Expand Up @@ -59,6 +59,10 @@ javax.measure.MetricPrefix.YOCTO = y
javax.measure.MetricPrefix.YOTTA = Y
javax.measure.MetricPrefix.ZEPTO = z
javax.measure.MetricPrefix.ZETTA = Z
javax.measure.MetricPrefix.QUETTA = Q
javax.measure.MetricPrefix.RONNA = R
javax.measure.MetricPrefix.QUECTO = q
javax.measure.MetricPrefix.RONTO = r

# SI Units
tech.units.indriya.unit.Units.AMPERE = A
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
# Units of Measurement Reference Implementation
# Copyright (c) 2005-2020, Jean-Marie Dautelle, Werner Keil, Otavio Santana.
# Copyright (c) 2005-2024, Jean-Marie Dautelle, Werner Keil, Otavio Santana.
#
# All rights reserved.
#
Expand Down Expand Up @@ -50,6 +50,10 @@ javax.measure.MetricPrefix.YOCTO = y
javax.measure.MetricPrefix.YOTTA = Y
javax.measure.MetricPrefix.ZEPTO = z
javax.measure.MetricPrefix.ZETTA = Z
javax.measure.MetricPrefix.QUETTA = Q
javax.measure.MetricPrefix.RONNA = R
javax.measure.MetricPrefix.QUECTO = q
javax.measure.MetricPrefix.RONTO = r

# Common Units
tech.units.indriya.unit.Units.KILOMETRE_PER_HOUR = km/h
Expand Down
30 changes: 16 additions & 14 deletions src/test/java/tech/units/indriya/format/EBNFPrefixTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,8 @@
*/
package tech.units.indriya.format;

import static javax.measure.BinaryPrefix.EXBI;
import static javax.measure.BinaryPrefix.GIBI;
import static javax.measure.BinaryPrefix.KIBI;
import static javax.measure.BinaryPrefix.MEBI;
import static javax.measure.BinaryPrefix.PEBI;
import static javax.measure.BinaryPrefix.TEBI;
import static javax.measure.BinaryPrefix.YOBI;
import static javax.measure.BinaryPrefix.ZEBI;
import static javax.measure.MetricPrefix.DECI;
import static javax.measure.MetricPrefix.KILO;
import static javax.measure.MetricPrefix.MEGA;
import static javax.measure.MetricPrefix.MICRO;
import static javax.measure.MetricPrefix.MILLI;
import static javax.measure.MetricPrefix.NANO;
import static javax.measure.BinaryPrefix.*;
import static javax.measure.MetricPrefix.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.junit.jupiter.api.Assertions.assertEquals;
Expand Down Expand Up @@ -72,6 +60,8 @@ static void init() {
format = EBNFUnitFormat.getInstance();
}

// Metric Prefixes

@Test
public void testKilo() {
// TODO how to handle equals for units?
Expand Down Expand Up @@ -166,13 +156,25 @@ public void testNano2() {
assertEquals("nm", format.format(m2.getUnit()));
}

@Test
public void testQuetta() {
assertEquals("Ql", format.format(QUETTA(LITRE)));
}

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

@Test
public void testHashMapAccessingMap() {
assertThat(LITRE.toString(), is("l"));
assertThat(MILLI(LITRE).toString(), is("ml"));
assertThat(MILLI(GRAM).toString(), is("mg"));
}

// Binary Prefixes

@Test
public void testKibi() {
final String s = format.format(KIBI(METRE));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

@Tag("l10n")
public class LocalMessagesTest {
private static final int BUNDLE_ENTRIES = 73;
private static final int BUNDLE_ENTRIES = 77;
private static final String BUNDLE_NAME = "tech.units.indriya.format.messages";
private static final String KEY = "tech.units.indriya.unit.Units.KILOMETRE_PER_HOUR";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import org.junit.jupiter.api.Test;

public class MessagesTest {
private static final int BUNDLE_ENTRIES = 73;
private static final int BUNDLE_ENTRIES = 77;

@Test
public void testMessageBundle() {
Expand Down

0 comments on commit 25ff7a8

Please sign in to comment.