Skip to content

Commit

Permalink
CLDR-15954 Add test of unit preferences test
Browse files Browse the repository at this point in the history
See #3571
  • Loading branch information
macchiati authored and Squash Bot committed Mar 18, 2024
1 parent b828ffb commit 85ddce1
Show file tree
Hide file tree
Showing 10 changed files with 909 additions and 192 deletions.
42 changes: 42 additions & 0 deletions common/testData/units/unitLocalePreferencesTest.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Test data for unit locale preferences
# Copyright © 1991-2024 Unicode, Inc.
# For terms of use, see http://www.unicode.org/copyright.html
# SPDX-License-Identifier: Unicode-3.0
# CLDR data files are interpreted according to the LDML specification (http://unicode.org/reports/tr35/)
#
# Format:
# input-unit; amount; usage; languageTag; expected-unit; expected-amount # comment
#
# • The amounts are both rationals
# • The comment is optional (if it isn't present the # can be omitted)
#
# Use: Convert the Input amount & unit according to the Usage and Locale.
# The result should match the Expected amount and unit.
#
# The input and expected output units are unit identifers; in particular, the output does not have further processing:
# • no localization
#
fahrenheit; 1; default; en-u-rg-uszzzz-ms-ussystem-mu-celsius; celsius; -155/9 # mu > ms > rg > (likely) region
fahrenheit; 1; default; en-u-rg-uszzzz-ms-ussystem-mu-celsius; celsius; -155/9
fahrenheit; 1; default; en-u-rg-uszzzz-ms-metric; celsius; -155/9
fahrenheit; 1; default; en-u-rg-dezzzz; celsius; -155/9
fahrenheit; 1; default; en-DE; celsius; -155/9 # explicit region > likely region
fahrenheit; 1; default; en-US; fahrenheit; 1
fahrenheit; 1; default; en; fahrenheit; 1 # likely region = US
gallon-imperial; 2.5; fluid; en-u-rg-uszzzz-ms-metric; liter; 11.365225
gallon-imperial; 2.5; fluid; en-u-rg-dezzzz; liter; 11.365225
gallon-imperial; 2.5; fluid; en-DE; liter; 11.365225
gallon-imperial; 2.5; fluid; en-US-u-rg-uszzzz-ms-uksystem; gallon-imperial; 2.5 # ms-uksystem should behave like GB
gallon-imperial; 2.5; fluid; en-u-rg-gbzzzz; gallon-imperial; 2.5
gallon-imperial; 2.5; fluid; en-GB; gallon-imperial; 2.5
gallon-imperial; 2.5; fluid; en-u-rg-uszzzz-ms-ussystem; gallon; 1,420,653,125/473176473
gallon-imperial; 2.5; fluid; en-u-rg-uszzzz; gallon; 1,420,653,125/473176473
gallon-imperial; 2.5; fluid; en-US; gallon; 1,420,653,125/473176473
gallon-imperial; 2.5; fluid; en; gallon; 1,420,653,125/473176473 # likely region = US
ampere; 2.5; default; en; ampere; 2.5 # an input unit whose quantity has no preference data should get base units
pound-force-foot; 12,345; default; en; kilowatt-hour; 0.004649325714486427205
kilocandela; 1; default; en; candela; 1,000 # an input unit whose quantity has no preference data should get base units
candela-per-byte; 1; default; en; candela-per-bit; 0.125 # an input unit that has no quantity should get base units
candela-per-cubic-foot; 1; default; en; candela-per-cubic-meter; 1,953,125,000/55306341 # an input unit that has no quantity should get base units
foot; 1; default; de-u-mu-celsius; centimeter; 30.48 # a -mu unit that is not convertible from the input unit should get ignored
#pound; 28; default; en-u-mu-stone; stone; 2 # only temperature units are supported
4 changes: 2 additions & 2 deletions common/testData/units/unitPreferencesTest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Test data for unit preferences
# Copyright © 1991-2024 Unicode, Inc.
# For terms of use, see http://www.unicode.org/copyright.html
# SPDX-License-Identifier: Unicode-DFS-2016
# SPDX-License-Identifier: Unicode-3.0
# CLDR data files are interpreted according to the LDML specification (http://unicode.org/reports/tr35/)
#
# Format:
Expand All @@ -22,7 +22,7 @@
# • no formatted with the skeleton
# • no suppression of zero values (for secondary -and- units such as pound in stone-and-pound)
#
# Generation: Set GENERATE_TESTS in TestUnits.java to regenerate unitPreferencesTest.txt.
# Generation: Use GenerateUnitTestData.java to regenerate unitPreferencesTest.txt.

area; default; 001; 1100000; 1100000.0; square-meter; 11/10; 1.1; square-kilometer
area; default; 001; 1000000; 1000000.0; square-meter; 1; 1.0; square-kilometer
Expand Down
4 changes: 2 additions & 2 deletions common/testData/units/unitsTest.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Test data for unit conversions
# Copyright © 1991-2024 Unicode, Inc.
# For terms of use, see http://www.unicode.org/copyright.html
# SPDX-License-Identifier: Unicode-DFS-2016
# SPDX-License-Identifier: Unicode-3.0
# CLDR data files are interpreted according to the LDML specification (http://unicode.org/reports/tr35/)
#
# Format:
Expand All @@ -12,7 +12,7 @@
# round to 4 decimal digits before comparing.
# Note that certain conversions are approximate, such as degrees to radians
#
# Generation: Set GENERATE_TESTS in TestUnits.java to regenerate unitsTest.txt.
# Generation: Use GenerateUnitTestData.java to regenerate unitsTest.txt.

acceleration ; meter-per-square-second ; meter-per-square-second ; 1 * x ; 1,000.00
acceleration ; g-force ; meter-per-square-second ; 9.80665 * x ; 9806.65
Expand Down
Loading

0 comments on commit 85ddce1

Please sign in to comment.