Skip to content

Commit

Permalink
CLDR-15216 Add light-speed
Browse files Browse the repository at this point in the history
  • Loading branch information
macchiati committed May 14, 2024
1 parent 9a667f1 commit 6bb2d48
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 5 deletions.
17 changes: 16 additions & 1 deletion common/main/en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7514,6 +7514,11 @@ annotations.
<unitPattern count="one">{0} knot</unitPattern>
<unitPattern count="other">{0} knots</unitPattern>
</unit>
<unit type="speed-light-speed">
<displayName>light</displayName>
<unitPattern count="other">{0} light</unitPattern>
<unitPattern count="other">{0} light</unitPattern>
</unit>
<unit type="speed-beaufort">
<displayName>Beaufort</displayName>
<unitPattern count="one">Beaufort {0}</unitPattern>
Expand Down Expand Up @@ -8593,6 +8598,11 @@ annotations.
<unitPattern count="one">{0} kn</unitPattern>
<unitPattern count="other">{0} kn</unitPattern>
</unit>
<unit type="speed-light-speed">
<displayName>light</displayName>
<unitPattern count="other">{0} light</unitPattern>
<unitPattern count="other">{0} light</unitPattern>
</unit>
<unit type="speed-beaufort">
<displayName>Bft</displayName>
<unitPattern count="one">B {0}</unitPattern>
Expand Down Expand Up @@ -9669,7 +9679,12 @@ annotations.
<unitPattern count="one">{0}kn</unitPattern>
<unitPattern count="other">{0}kn</unitPattern>
</unit>
<unit type="speed-beaufort">
<unit type="speed-light-speed">
<displayName>light</displayName>
<unitPattern count="other">{0}light</unitPattern>
<unitPattern count="other">{0}light</unitPattern>
</unit>
<unit type="speed-beaufort">
<displayName>Bft</displayName>
<unitPattern count="one">B{0}</unitPattern>
<unitPattern count="other">B{0}</unitPattern>
Expand Down
4 changes: 4 additions & 0 deletions common/main/root.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5615,6 +5615,10 @@ Warnings: All cp values have U+FE0F characters removed. See /annotationsDerived/
<displayName>kn</displayName>
<unitPattern count="other">{0} kn</unitPattern>
</unit>
<unit type="speed-light-speed">
<displayName>light</displayName>
<unitPattern count="other">{0} light</unitPattern>
</unit>
<unit type="speed-beaufort">
<displayName>Bft</displayName>
<unitPattern count="other">B {0}</unitPattern>
Expand Down
2 changes: 1 addition & 1 deletion common/supplemental/units.xml
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,8 @@ For terms of use, see http://www.unicode.org/copyright.html

<!-- speed -->
<convertUnit source='knot' baseUnit='meter-per-second' factor='1852/3600' systems="ussystem uksystem si_acceptable"/>
<convertUnit source='light-speed' baseUnit='meter-per-second' factor='speed_of_light_meters_per_second' systems="ussystem uksystem si_acceptable"/>
<convertUnit source='beaufort' baseUnit='meter-per-second' special='beaufort' systems="metric_adjacent"/>


<!-- magnetic-induction -->
<convertUnit source='tesla' baseUnit='kilogram-per-square-second-ampere' systems='si metric prefixable'/>
Expand Down
1 change: 1 addition & 0 deletions common/validity/unit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ For terms of use, see http://www.unicode.org/copyright.html
volume-koku
mass-fun
duration-night
speed-light-speed
</id>
<id type='unit' idStatus='deprecated'>
acceleration-meter-per-second-squared
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1869,6 +1869,7 @@ private static final class UnitOrderHolder {
"volume-sai",
"volume-to-jp",
"volume-koku",
"speed-light-speed",
"mass-fun",
"duration-night"))
.freeze();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3882,7 +3882,7 @@ public void testUnitSystems() {
|| cldrSystems.contains(UnitSystem.si) && !nistSystems.contains(UnitSystem.si)
|| cldrSystems.contains(UnitSystem.si_acceptable)
&& !nistSystems.contains(UnitSystem.si_acceptable)) {
if (unit.equals("100-kilometer")) {
if (unit.equals("100-kilometer") || unit.equals("light-speed")) {
continue;
}
fails.add(
Expand Down Expand Up @@ -4459,14 +4459,32 @@ public void testFactorsInUnits() {
{"item-per-1e9-item", "item-per-item", "1/1000000000"},
{"item-per-1e9", "item", "1/1000000000"},
};
checkConversionToBase(tests);
}

public void checkConversionToBase(String[][] tests) {
int count = 0;
for (String[] test : tests) {
++count;
Output<String> metric = new Output<>();
final String inputUnit = test[0];
final String expectedTarget = test[1];
final Rational expectedFactor = Rational.of(test[2]);
ConversionInfo unitId1 = converter.parseUnitId(inputUnit, metric, DEBUG);
assertEquals(inputUnit, expectedTarget, metric.value);
assertEquals(inputUnit, expectedFactor, unitId1.factor);
assertEquals(count + ")\t" + inputUnit + " to base", expectedTarget, metric.value);
assertEquals(count + ")\t" + inputUnit + " factor", expectedFactor, unitId1.factor);
}
}

public void testLightSpeed() {
String[][] tests = {
{"light-speed", "meter-per-second", "299792458"},
{"light-speed-second", "meter-second-per-second", "299792458"},
{"light-speed-minute", "meter-second-per-second", "299792458*60"},
{"light-speed-hour", "meter-second-per-second", "299792458*3600"},
{"light-speed-day", "meter-second-per-second", "299792458*86400"},
{"light-speed-week", "meter-second-per-second", "299792458*604800"},
};
checkConversionToBase(tests);
}
}

0 comments on commit 6bb2d48

Please sign in to comment.