mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-10 07:39:16 +00:00
ICU-20568 unitsdata.cpp/.h and associated tests
Read unitsTest.txt, prepare to run unit tests. PR: https://github.com/sffc/icu/pull/20 Commit:9f65f41f18
No-op/cosmetic: reformat with clang-format ident:4 line-length:105. PR: https://github.com/sffc/icu/pull/25 Commit:4be0a2bc55
Parse unitPreferencesTest.txt preparing to run data-driven tests PR: https://github.com/sffc/icu/pull/26 Commit:9e021f9b6f
Improve test output: no more fprintfs. PR: https://github.com/sffc/icu/pull/34 Commit:12a5289238
Update to latest CLDR test files: b7a23f3f41 CLDR-13587. PR: https://github.com/sffc/icu/pull/33 Commit:44e9afb321
Add unitsdata.cpp, getConversionRatesInfo, and unit tests. PR: https://github.com/sffc/icu/pull/31 Commit:ca34233e08
Update unitsTest.txt and unitPreferencesTest.txt from current CLDR master PR: https://github.com/sffc/icu/pull/41 Commit:be7f69941d
This commit is contained in:
parent
adcc646e51
commit
cf46b4136e
13 changed files with 1384 additions and 105 deletions
|
@ -251,6 +251,7 @@
|
|||
<ClCompile Include="ulocdata.cpp" />
|
||||
<ClCompile Include="umsg.cpp" />
|
||||
<ClCompile Include="unitconverter.cpp" />
|
||||
<ClCompile Include="unitsdata.cpp" />
|
||||
<ClCompile Include="unum.cpp" />
|
||||
<ClCompile Include="unumsys.cpp" />
|
||||
<ClCompile Include="upluralrules.cpp" />
|
||||
|
@ -486,6 +487,7 @@
|
|||
<ClInclude Include="numrange_impl.h" />
|
||||
<ClInclude Include="formattedval_impl.h" />
|
||||
<ClInclude Include="unitconverter.h" />
|
||||
<ClInclude Include="unitsdata.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="i18n.rc" />
|
||||
|
|
|
@ -654,6 +654,9 @@
|
|||
<ClCompile Include="unitconverter.cpp">
|
||||
<Filter>formatting</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="unitsdata.cpp">
|
||||
<Filter>formatting</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="bocsu.cpp">
|
||||
|
@ -1001,6 +1004,9 @@
|
|||
<ClInclude Include="unitconveter.h">
|
||||
<Filter>formatting</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="unitsdata.h">
|
||||
<Filter>formatting</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="vzone.h">
|
||||
<Filter>formatting</Filter>
|
||||
</ClInclude>
|
||||
|
|
|
@ -482,6 +482,7 @@
|
|||
<ClCompile Include="ulocdata.cpp" />
|
||||
<ClCompile Include="umsg.cpp" />
|
||||
<ClCompile Include="unitconverter.cpp" />
|
||||
<ClCompile Include="unitsdata.cpp" />
|
||||
<ClCompile Include="unum.cpp" />
|
||||
<ClCompile Include="unumsys.cpp" />
|
||||
<ClCompile Include="upluralrules.cpp" />
|
||||
|
@ -717,6 +718,7 @@
|
|||
<ClInclude Include="numrange_impl.h" />
|
||||
<ClInclude Include="formattedval_impl.h" />
|
||||
<ClInclude Include="unitconverter.h" />
|
||||
<ClInclude Include="unitsdata.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="i18n.rc" />
|
||||
|
|
|
@ -209,6 +209,7 @@ umsg.cpp
|
|||
unesctrn.cpp
|
||||
uni2name.cpp
|
||||
unitconverter.cpp
|
||||
unitsdata.cpp
|
||||
unum.cpp
|
||||
unumsys.cpp
|
||||
upluralrules.cpp
|
||||
|
|
116
icu4c/source/i18n/unitsdata.cpp
Normal file
116
icu4c/source/i18n/unitsdata.cpp
Normal file
|
@ -0,0 +1,116 @@
|
|||
// © 2020 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
#if !UCONFIG_NO_FORMATTING
|
||||
|
||||
#include "cstring.h"
|
||||
#include "resource.h"
|
||||
#include "unitsdata.h"
|
||||
#include "uresimp.h"
|
||||
#include "util.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
namespace {
|
||||
|
||||
/**
|
||||
* A ResourceSink that collects conversion rate information.
|
||||
*
|
||||
* This class is for use by ures_getAllItemsWithFallback.
|
||||
*/
|
||||
class ConversionRateDataSink : public ResourceSink {
|
||||
public:
|
||||
/**
|
||||
* Constructor.
|
||||
* @param out The vector to which ConversionRateInfo instances are to be
|
||||
* added. This vector must outlive the use of the ResourceSink.
|
||||
*/
|
||||
explicit ConversionRateDataSink(MaybeStackVector<ConversionRateInfo> *out) : outVector(out) {}
|
||||
|
||||
/**
|
||||
* Adds the conversion rate information found in value to the output vector.
|
||||
*
|
||||
* Each call to put() collects a ConversionRateInfo instance for the
|
||||
* specified source unit identifier into the vector passed to the
|
||||
* constructor, but only if an identical instance isn't already present.
|
||||
*
|
||||
* @param source The source unit identifier.
|
||||
* @param value A resource containing conversion rate info (the base unit
|
||||
* and factor, and possibly an offset).
|
||||
* @param noFallback Ignored.
|
||||
* @param status The standard ICU error code output parameter.
|
||||
*/
|
||||
void put(const char *source, ResourceValue &value, UBool /*noFallback*/, UErrorCode &status) {
|
||||
if (U_FAILURE(status)) return;
|
||||
if (uprv_strcmp(source, "convertUnits") != 0) {
|
||||
// This is very strict, however it is the cheapest way to be sure
|
||||
// that with `value`, we're looking at the convertUnits table.
|
||||
status = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return;
|
||||
}
|
||||
ResourceTable conversionRateTable = value.getTable(status);
|
||||
const char *srcUnit;
|
||||
// We're reusing `value`, which seems to be a common pattern:
|
||||
for (int32_t unit = 0; conversionRateTable.getKeyAndValue(unit, srcUnit, value); unit++) {
|
||||
ResourceTable unitTable = value.getTable(status);
|
||||
const char *key;
|
||||
UnicodeString baseUnit = ICU_Utility::makeBogusString();
|
||||
UnicodeString factor = ICU_Utility::makeBogusString();
|
||||
UnicodeString offset = ICU_Utility::makeBogusString();
|
||||
for (int32_t i = 0; unitTable.getKeyAndValue(i, key, value); i++) {
|
||||
if (uprv_strcmp(key, "target") == 0) {
|
||||
baseUnit = value.getUnicodeString(status);
|
||||
} else if (uprv_strcmp(key, "factor") == 0) {
|
||||
factor = value.getUnicodeString(status);
|
||||
} else if (uprv_strcmp(key, "offset") == 0) {
|
||||
offset = value.getUnicodeString(status);
|
||||
}
|
||||
}
|
||||
if (U_FAILURE(status)) return;
|
||||
if (baseUnit.isBogus() || factor.isBogus()) {
|
||||
// We could not find a usable conversion rate: bad resource.
|
||||
status = U_MISSING_RESOURCE_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
// We don't have this ConversionRateInfo yet: add it.
|
||||
ConversionRateInfo *cr = outVector->emplaceBack();
|
||||
if (!cr) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
} else {
|
||||
cr->sourceUnit.append(srcUnit, status);
|
||||
cr->baseUnit.appendInvariantChars(baseUnit, status);
|
||||
cr->factor.appendInvariantChars(factor, status);
|
||||
if (!offset.isBogus()) cr->offset.appendInvariantChars(offset, status);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
private:
|
||||
MaybeStackVector<ConversionRateInfo> *outVector;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
void U_I18N_API getAllConversionRates(MaybeStackVector<ConversionRateInfo> &result, UErrorCode &status) {
|
||||
LocalUResourceBundlePointer unitsBundle(ures_openDirect(NULL, "units", &status));
|
||||
ConversionRateDataSink sink(&result);
|
||||
ures_getAllItemsWithFallback(unitsBundle.getAlias(), "convertUnits", sink, status);
|
||||
}
|
||||
|
||||
// TODO(hugovdm): ensure this gets removed. Currently
|
||||
// https://github.com/sffc/icu/pull/32 is making use of it.
|
||||
MaybeStackVector<ConversionRateInfo> U_I18N_API
|
||||
getConversionRatesInfo(const MaybeStackVector<MeasureUnit> &, UErrorCode &status) {
|
||||
MaybeStackVector<ConversionRateInfo> result;
|
||||
getAllConversionRates(result, status);
|
||||
return result;
|
||||
}
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif /* #if !UCONFIG_NO_FORMATTING */
|
67
icu4c/source/i18n/unitsdata.h
Normal file
67
icu4c/source/i18n/unitsdata.h
Normal file
|
@ -0,0 +1,67 @@
|
|||
// © 2020 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
#if !UCONFIG_NO_FORMATTING
|
||||
#ifndef __GETUNITSDATA_H__
|
||||
#define __GETUNITSDATA_H__
|
||||
|
||||
#include "charstr.h"
|
||||
#include "cmemory.h"
|
||||
#include "unicode/measunit.h"
|
||||
#include "unicode/stringpiece.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* Encapsulates "convertUnits" information from units resources, specifying how
|
||||
* to convert from one unit to another.
|
||||
*
|
||||
* Information in this class is still in the form of strings: symbolic constants
|
||||
* need to be interpreted. Rationale: symbols can cancel out for higher
|
||||
* precision conversion - going from feet to inches should cancel out the
|
||||
* `ft_to_m` constant.
|
||||
*/
|
||||
class U_I18N_API ConversionRateInfo : public UMemory {
|
||||
public:
|
||||
ConversionRateInfo(){};
|
||||
ConversionRateInfo(StringPiece sourceUnit, StringPiece baseUnit, StringPiece factor,
|
||||
StringPiece offset, UErrorCode &status)
|
||||
: sourceUnit(), baseUnit(), factor(), offset() {
|
||||
this->sourceUnit.append(sourceUnit, status);
|
||||
this->baseUnit.append(baseUnit, status);
|
||||
this->factor.append(factor, status);
|
||||
this->offset.append(offset, status);
|
||||
};
|
||||
CharString sourceUnit;
|
||||
CharString baseUnit;
|
||||
CharString factor;
|
||||
CharString offset;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns ConversionRateInfo for all supported conversions.
|
||||
*
|
||||
* @param result Receives the set of conversion rates.
|
||||
* @param status Receives status.
|
||||
*/
|
||||
void U_I18N_API getAllConversionRates(MaybeStackVector<ConversionRateInfo> &result, UErrorCode &status);
|
||||
|
||||
/**
|
||||
* Temporary backward-compatibility function.
|
||||
*
|
||||
* TODO(hugovdm): ensure this gets removed. Currently
|
||||
* https://github.com/sffc/icu/pull/32 is making use of it.
|
||||
*
|
||||
* @param units Ignored.
|
||||
* @return the result of getAllConversionRates.
|
||||
*/
|
||||
MaybeStackVector<ConversionRateInfo>
|
||||
U_I18N_API getConversionRatesInfo(const MaybeStackVector<MeasureUnit> &units, UErrorCode &status);
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif //__GETUNITSDATA_H__
|
||||
|
||||
#endif /* #if !UCONFIG_NO_FORMATTING */
|
|
@ -870,7 +870,7 @@ library: i18n
|
|||
listformatter
|
||||
formatting formattable_cnv regex regex_cnv translit
|
||||
double_conversion number_representation number_output numberformatter number_skeletons numberparser
|
||||
units_extra
|
||||
units_extra unitsformatter
|
||||
universal_time_scale
|
||||
uclean_i18n
|
||||
|
||||
|
@ -1064,7 +1064,7 @@ group: sharedbreakiterator
|
|||
breakiterator
|
||||
|
||||
group: units_extra
|
||||
measunit_extra.o
|
||||
measunit_extra.o unitconverter.o
|
||||
deps
|
||||
units bytestriebuilder bytestrie resourcebundle uclean_i18n
|
||||
|
||||
|
@ -1073,6 +1073,11 @@ group: units
|
|||
deps
|
||||
stringenumeration errorcode
|
||||
|
||||
group: unitsformatter
|
||||
unitsdata.o
|
||||
deps
|
||||
resourcebundle
|
||||
|
||||
group: decnumber
|
||||
decContext.o decNumber.o
|
||||
deps
|
||||
|
|
|
@ -69,7 +69,7 @@ string_segment_test.o \
|
|||
numbertest_parse.o numbertest_doubleconversion.o numbertest_skeletons.o \
|
||||
static_unisets_test.o numfmtdatadriventest.o numbertest_range.o erarulestest.o \
|
||||
formattedvaluetest.o formatted_string_builder_test.o numbertest_permutation.o \
|
||||
unitstest.o
|
||||
unitsdatatest.o unitstest.o
|
||||
|
||||
DEPS = $(OBJECTS:.o=.d)
|
||||
|
||||
|
|
|
@ -74,6 +74,7 @@ extern IntlTest *createScientificNumberFormatterTest();
|
|||
extern IntlTest *createFormattedValueTest();
|
||||
extern IntlTest *createFormattedStringBuilderTest();
|
||||
extern IntlTest *createStringSegmentTest();
|
||||
extern IntlTest *createUnitsDataTest();
|
||||
extern IntlTest *createUnitsTest();
|
||||
|
||||
|
||||
|
@ -257,6 +258,15 @@ void IntlTestFormat::runIndexedTest( int32_t index, UBool exec, const char* &nam
|
|||
callTest(*test, par);
|
||||
}
|
||||
break;
|
||||
case 57:
|
||||
name = "UnitsDataTest";
|
||||
if (exec) {
|
||||
logln("UnitsDataTest test---");
|
||||
logln((UnicodeString)"");
|
||||
LocalPointer<IntlTest> test(createUnitsDataTest());
|
||||
callTest(*test, par);
|
||||
}
|
||||
break;
|
||||
default: name = ""; break; //needed to end loop
|
||||
}
|
||||
if (exec) {
|
||||
|
|
43
icu4c/source/test/intltest/unitsdatatest.cpp
Normal file
43
icu4c/source/test/intltest/unitsdatatest.cpp
Normal file
|
@ -0,0 +1,43 @@
|
|||
// © 2020 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html#License
|
||||
|
||||
#if !UCONFIG_NO_FORMATTING
|
||||
|
||||
#include "unitsdata.h"
|
||||
#include "intltest.h"
|
||||
|
||||
class UnitsDataTest : public IntlTest {
|
||||
public:
|
||||
UnitsDataTest() {}
|
||||
|
||||
void runIndexedTest(int32_t index, UBool exec, const char *&name, char *par = NULL);
|
||||
|
||||
void testGetAllConversionRates();
|
||||
};
|
||||
|
||||
extern IntlTest *createUnitsDataTest() { return new UnitsDataTest(); }
|
||||
|
||||
void UnitsDataTest::runIndexedTest(int32_t index, UBool exec, const char *&name, char * /*par*/) {
|
||||
if (exec) { logln("TestSuite UnitsDataTest: "); }
|
||||
TESTCASE_AUTO_BEGIN;
|
||||
TESTCASE_AUTO(testGetAllConversionRates);
|
||||
TESTCASE_AUTO_END;
|
||||
}
|
||||
|
||||
void UnitsDataTest::testGetAllConversionRates() {
|
||||
IcuTestErrorCode status(*this, "testGetAllConversionRates");
|
||||
MaybeStackVector<ConversionRateInfo> conversionInfo;
|
||||
getAllConversionRates(conversionInfo, status);
|
||||
|
||||
// Convenience output for debugging
|
||||
for (int i = 0; i < conversionInfo.length(); i++) {
|
||||
ConversionRateInfo *cri = conversionInfo[i];
|
||||
logln("* conversionInfo %d: source=\"%s\", baseUnit=\"%s\", factor=\"%s\", offset=\"%s\"", i,
|
||||
cri->sourceUnit.data(), cri->baseUnit.data(), cri->factor.data(), cri->offset.data());
|
||||
assertTrue("sourceUnit", cri->sourceUnit.length() > 0);
|
||||
assertTrue("baseUnit", cri->baseUnit.length() > 0);
|
||||
assertTrue("factor", cri->factor.length() > 0);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* #if !UCONFIG_NO_FORMATTING */
|
|
@ -5,9 +5,17 @@
|
|||
|
||||
#if !UCONFIG_NO_FORMATTING
|
||||
|
||||
|
||||
#include "charstr.h"
|
||||
#include "filestrm.h"
|
||||
#include "intltest.h"
|
||||
#include "number_decimalquantity.h"
|
||||
#include "unicode/ctest.h"
|
||||
#include "unicode/measunit.h"
|
||||
#include "unicode/unistr.h"
|
||||
#include "unicode/unum.h"
|
||||
#include "uparse.h"
|
||||
|
||||
using icu::number::impl::DecimalQuantity;
|
||||
|
||||
class UnitsTest : public IntlTest {
|
||||
public:
|
||||
|
@ -15,11 +23,13 @@ class UnitsTest : public IntlTest {
|
|||
|
||||
void runIndexedTest(int32_t index, UBool exec, const char *&name, char *par = NULL);
|
||||
|
||||
void testBasic();
|
||||
void testSiPrefixes();
|
||||
void testMass();
|
||||
void testTemperature();
|
||||
void testArea();
|
||||
void testConversions();
|
||||
void testPreferences();
|
||||
// void testBasic();
|
||||
// void testSiPrefixes();
|
||||
// void testMass();
|
||||
// void testTemperature();
|
||||
// void testArea();
|
||||
};
|
||||
|
||||
extern IntlTest *createUnitsTest() { return new UnitsTest(); }
|
||||
|
@ -29,11 +39,13 @@ void UnitsTest::runIndexedTest(int32_t index, UBool exec, const char *&name, cha
|
|||
logln("TestSuite UnitsTest: ");
|
||||
}
|
||||
TESTCASE_AUTO_BEGIN;
|
||||
TESTCASE_AUTO(testBasic);
|
||||
TESTCASE_AUTO(testSiPrefixes);
|
||||
TESTCASE_AUTO(testMass);
|
||||
TESTCASE_AUTO(testTemperature);
|
||||
TESTCASE_AUTO(testArea);
|
||||
TESTCASE_AUTO(testConversions);
|
||||
TESTCASE_AUTO(testPreferences);
|
||||
// TESTCASE_AUTO(testBasic);
|
||||
// TESTCASE_AUTO(testSiPrefixes);
|
||||
// TESTCASE_AUTO(testMass);
|
||||
// TESTCASE_AUTO(testTemperature);
|
||||
// TESTCASE_AUTO(testArea);
|
||||
TESTCASE_AUTO_END;
|
||||
}
|
||||
|
||||
|
@ -48,115 +60,480 @@ double testConvert(UnicodeString source, UnicodeString target, double input) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
void UnitsTest::testBasic() {
|
||||
IcuTestErrorCode status(*this, "Units testBasic");
|
||||
// void UnitsTest::testBasic() {
|
||||
// IcuTestErrorCode status(*this, "Units testBasic");
|
||||
|
||||
// Test Cases
|
||||
struct TestCase {
|
||||
const char16_t *source;
|
||||
const char16_t *target;
|
||||
const double inputValue;
|
||||
const double expectedValue;
|
||||
} testCases[]{{u"meter", u"foot", 1.0, 3.28084}, {u"kilometer", u"foot", 1.0, 328.084}};
|
||||
// // Test Cases
|
||||
// struct TestCase {
|
||||
// const char16_t *source;
|
||||
// const char16_t *target;
|
||||
// const double inputValue;
|
||||
// const double expectedValue;
|
||||
// } testCases[]{{u"meter", u"foot", 1.0, 3.28084}, {u"kilometer", u"foot", 1.0, 328.084}};
|
||||
|
||||
for (const auto &testCase : testCases) {
|
||||
assertEquals("test convert", testConvert(testCase.source, testCase.target, testCase.inputValue),
|
||||
testCase.expectedValue);
|
||||
// for (const auto &testCase : testCases) {
|
||||
// assertEquals("test convert", testConvert(testCase.source, testCase.target, testCase.inputValue),
|
||||
// testCase.expectedValue);
|
||||
// }
|
||||
// }
|
||||
|
||||
// void UnitsTest::testSiPrefixes() {
|
||||
// IcuTestErrorCode status(*this, "Units testSiPrefixes");
|
||||
// // Test Cases
|
||||
// struct TestCase {
|
||||
// const char16_t *source;
|
||||
// const char16_t *target;
|
||||
// const double inputValue;
|
||||
// const double expectedValue;
|
||||
// } testCases[]{
|
||||
// {u"gram", u"kilogram", 1.0, 0.001}, //
|
||||
// {u"milligram", u"kilogram", 1.0, 0.000001}, //
|
||||
// {u"microgram", u"kilogram", 1.0, 0.000000001}, //
|
||||
// {u"megawatt", u"watt", 1, 1000000}, //
|
||||
// {u"megawatt", u"kilowatt", 1.0, 1000}, //
|
||||
// {u"gigabyte", u"byte", 1, 1000000000} //
|
||||
// };
|
||||
|
||||
// for (const auto &testCase : testCases) {
|
||||
// assertEquals("test convert", testConvert(testCase.source, testCase.target, testCase.inputValue),
|
||||
// testCase.expectedValue);
|
||||
// }
|
||||
// }
|
||||
|
||||
// void UnitsTest::testMass() {
|
||||
// IcuTestErrorCode status(*this, "Units testMass");
|
||||
|
||||
// // Test Cases
|
||||
// struct TestCase {
|
||||
// const char16_t *source;
|
||||
// const char16_t *target;
|
||||
// const double inputValue;
|
||||
// const double expectedValue;
|
||||
// } testCases[]{
|
||||
// {u"gram", u"kilogram", 1.0, 0.001}, //
|
||||
// {u"pound", u"kilogram", 1.0, 0.453592}, //
|
||||
// {u"pound", u"kilogram", 2.0, 0.907185}, //
|
||||
// {u"ounce", u"pound", 16.0, 1.0}, //
|
||||
// {u"ounce", u"kilogram", 16.0, 0.453592}, //
|
||||
// {u"ton", u"pound", 1.0, 2000}, //
|
||||
// {u"stone", u"pound", 1.0, 14}, //
|
||||
// {u"stone", u"kilogram", 1.0, 6.35029} //
|
||||
// };
|
||||
|
||||
// for (const auto &testCase : testCases) {
|
||||
// assertEquals("test convert", testConvert(testCase.source, testCase.target, testCase.inputValue),
|
||||
// testCase.expectedValue);
|
||||
// }
|
||||
// }
|
||||
|
||||
// void UnitsTest::testTemperature() {
|
||||
// IcuTestErrorCode status(*this, "Units testTemperature");
|
||||
// // Test Cases
|
||||
// struct TestCase {
|
||||
// const char16_t *source;
|
||||
// const char16_t *target;
|
||||
// const double inputValue;
|
||||
// const double expectedValue;
|
||||
// } testCases[]{
|
||||
// {u"celsius", u"fahrenheit", 0.0, 32.0}, //
|
||||
// {u"celsius", u"fahrenheit", 10.0, 50.0}, //
|
||||
// {u"fahrenheit", u"celsius", 32.0, 0.0}, //
|
||||
// {u"fahrenheit", u"celsius", 89.6, 32}, //
|
||||
// {u"kelvin", u"fahrenheit", 0.0, -459.67}, //
|
||||
// {u"kelvin", u"fahrenheit", 300, 80.33}, //
|
||||
// {u"kelvin", u"celsius", 0.0, -273.15}, //
|
||||
// {u"kelvin", u"celsius", 300.0, 26.85} //
|
||||
// };
|
||||
|
||||
// for (const auto &testCase : testCases) {
|
||||
// assertEquals("test convert", testConvert(testCase.source, testCase.target, testCase.inputValue),
|
||||
// testCase.expectedValue);
|
||||
// }
|
||||
// }
|
||||
|
||||
// void UnitsTest::testArea() {
|
||||
// IcuTestErrorCode status(*this, "Units Area");
|
||||
|
||||
// // Test Cases
|
||||
// struct TestCase {
|
||||
// const char16_t *source;
|
||||
// const char16_t *target;
|
||||
// const double inputValue;
|
||||
// const double expectedValue;
|
||||
// } testCases[]{
|
||||
// {u"square-meter", u"square-yard", 10.0, 11.9599}, //
|
||||
// {u"hectare", u"square-yard", 1.0, 11959.9}, //
|
||||
// {u"square-mile", u"square-foot", 0.0001, 2787.84} //
|
||||
// };
|
||||
|
||||
// for (const auto &testCase : testCases) {
|
||||
// assertEquals("test convert", testConvert(testCase.source, testCase.target, testCase.inputValue),
|
||||
// testCase.expectedValue);
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* Trims whitespace (spaces only) off of the specified string.
|
||||
* @param field is two pointers pointing at the start and end of the string.
|
||||
* @return A StringPiece with initial and final space characters trimmed off.
|
||||
*/
|
||||
StringPiece trimField(char *(&field)[2]) {
|
||||
char *start = field[0];
|
||||
while (start < field[1] && (start[0]) == ' ') {
|
||||
start++;
|
||||
}
|
||||
int32_t length = (int32_t)(field[1] - start);
|
||||
while (length > 0 && (start[length - 1]) == ' ') {
|
||||
length--;
|
||||
}
|
||||
return StringPiece(start, length);
|
||||
}
|
||||
|
||||
/**
|
||||
* WIP(hugovdm): deals with a single data-driven unit test for unit conversions.
|
||||
* This is a UParseLineFn as required by u_parseDelimitedFile.
|
||||
*/
|
||||
void unitsTestDataLineFn(void *context, char *fields[][2], int32_t fieldCount, UErrorCode *pErrorCode) {
|
||||
if (U_FAILURE(*pErrorCode)) return;
|
||||
UnitsTest* unitsTest = (UnitsTest*)context;
|
||||
(void)fieldCount; // unused UParseLineFn variable
|
||||
IcuTestErrorCode status(*unitsTest, "unitsTestDatalineFn");
|
||||
|
||||
StringPiece quantity = trimField(fields[0]);
|
||||
StringPiece x = trimField(fields[1]);
|
||||
StringPiece y = trimField(fields[2]);
|
||||
StringPiece commentConversionFormula = trimField(fields[3]);
|
||||
StringPiece utf8Expected = trimField(fields[4]);
|
||||
|
||||
UNumberFormat *nf = unum_open(UNUM_DEFAULT, NULL, -1, "en_US", NULL, pErrorCode);
|
||||
UnicodeString uExpected = UnicodeString::fromUTF8(utf8Expected);
|
||||
double expected = unum_parseDouble(nf, uExpected.getBuffer(), uExpected.length(), 0, pErrorCode);
|
||||
unum_close(nf);
|
||||
|
||||
MeasureUnit sourceUnit = MeasureUnit::forIdentifier(x, status);
|
||||
if (status.errIfFailureAndReset("forIdentifier(\"%.*s\")", x.length(), x.data())) return;
|
||||
|
||||
MeasureUnit targetUnit = MeasureUnit::forIdentifier(y, status);
|
||||
if (status.errIfFailureAndReset("forIdentifier(\"%.*s\")", y.length(), y.data())) return;
|
||||
|
||||
unitsTest->logln("Quantity (Category): \"%.*s\", "
|
||||
"Expected value of \"1000 %.*s in %.*s\": %f, "
|
||||
"commentConversionFormula: \"%.*s\", ",
|
||||
quantity.length(), quantity.data(), x.length(), x.data(), y.length(), y.data(),
|
||||
expected, commentConversionFormula.length(), commentConversionFormula.data());
|
||||
|
||||
// WIP(hugovdm): hook this up to actual tests.
|
||||
|
||||
// // Convertibility:
|
||||
// MaybeStackVector<MeasureUnit> units;
|
||||
// units.emplaceBack(sourceUnit);
|
||||
// units.emplaceBack(targetUnit);
|
||||
// const auto &conversionRateInfoList = getConversionRatesInfo(units, status);
|
||||
// if (status.errIfFailureAndReset("getConversionRatesInfo(...)")) return;
|
||||
|
||||
// auto actualState = checkUnitsState(sourceUnit, targetUnit, conversionRateInfoList, status);
|
||||
// if (status.errIfFailureAndReset("checkUnitsState(<%s>, <%s>, ...)", sourceUnit.getIdentifier(),
|
||||
// targetUnit.getIdentifier())) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// CharString msg;
|
||||
// msg.append("convertible: ", status)
|
||||
// .append(sourceUnit.getIdentifier(), status)
|
||||
// .append(" -> ", status)
|
||||
// .append(targetUnit.getIdentifier(), status);
|
||||
// if (status.errIfFailureAndReset("msg construction")) return;
|
||||
|
||||
// unitsTest->assertTrue(msg.data(), actualState != UNCONVERTIBLE);
|
||||
|
||||
// Unit conversion... untested:
|
||||
// UnitConverter converter(sourceUnit, targetUnit, status);
|
||||
// double got = converter.convert(1000, status);
|
||||
// unitsTest->assertEqualsNear(quantity.data(), expected, got, 0.0001);
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs data-driven unit tests for unit conversion. It looks for the test cases
|
||||
* in source/test/testdata/units/unitsTest.txt, which originates in CLDR.
|
||||
*/
|
||||
void UnitsTest::testConversions() {
|
||||
const char *filename = "unitsTest.txt";
|
||||
const int32_t kNumFields = 5;
|
||||
char *fields[kNumFields][2];
|
||||
|
||||
IcuTestErrorCode errorCode(*this, "UnitsTest::testConversions");
|
||||
const char *sourceTestDataPath = getSourceTestData(errorCode);
|
||||
if (errorCode.errIfFailureAndReset("unable to find the source/test/testdata "
|
||||
"folder (getSourceTestData())")) {
|
||||
return;
|
||||
}
|
||||
|
||||
CharString path(sourceTestDataPath, errorCode);
|
||||
path.appendPathPart("units", errorCode);
|
||||
path.appendPathPart(filename, errorCode);
|
||||
|
||||
u_parseDelimitedFile(path.data(), ';', fields, kNumFields, unitsTestDataLineFn, this, errorCode);
|
||||
if (errorCode.errIfFailureAndReset("error parsing %s: %s\n", path.data(), u_errorName(errorCode))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void UnitsTest::testSiPrefixes() {
|
||||
IcuTestErrorCode status(*this, "Units testSiPrefixes");
|
||||
// Test Cases
|
||||
struct TestCase {
|
||||
const char16_t *source;
|
||||
const char16_t *target;
|
||||
const double inputValue;
|
||||
const double expectedValue;
|
||||
} testCases[]{
|
||||
{u"gram", u"kilogram", 1.0, 0.001}, //
|
||||
{u"milligram", u"kilogram", 1.0, 0.000001}, //
|
||||
{u"microgram", u"kilogram", 1.0, 0.000000001}, //
|
||||
{u"megawatt", u"watt", 1, 1000000}, //
|
||||
{u"megawatt", u"kilowatt", 1.0, 1000}, //
|
||||
{u"gigabyte", u"byte", 1, 1000000000} //
|
||||
};
|
||||
/**
|
||||
* This class represents the output fields from unitPreferencesTest.txt. Please
|
||||
* see the documentation at the top of that file for details.
|
||||
*
|
||||
* For "mixed units" output, there are more (repeated) output fields. The last
|
||||
* output unit has the expected output specified as both a rational fraction and
|
||||
* a decimal fraction. This class ignores rational fractions, and expects to
|
||||
* find a decimal fraction for each output unit.
|
||||
*/
|
||||
class ExpectedOutput {
|
||||
private:
|
||||
// Counts number of units in the output. When this is more than one, we have
|
||||
// "mixed units" in the expected output.
|
||||
int _compoundCount = 0;
|
||||
|
||||
for (const auto &testCase : testCases) {
|
||||
assertEquals("test convert", testConvert(testCase.source, testCase.target, testCase.inputValue),
|
||||
testCase.expectedValue);
|
||||
// Counts how many fields were skipped: we expect to skip only one per
|
||||
// output unit type (the rational fraction).
|
||||
int _skippedFields = 0;
|
||||
|
||||
// The expected output units: more than one for "mixed units".
|
||||
MeasureUnit _measureUnits[3];
|
||||
|
||||
// The amounts of each of the output units.
|
||||
double _amounts[3];
|
||||
|
||||
public:
|
||||
/**
|
||||
* Parse an expected output field from the test data file.
|
||||
*
|
||||
* @param output may be a string representation of an integer, a rational
|
||||
* fraction, a decimal fraction, or it may be a unit identifier. Whitespace
|
||||
* should already be trimmed. This function ignores rational fractions,
|
||||
* saving only decimal fractions and their unit identifiers.
|
||||
* @return true if the field was successfully parsed, false if parsing
|
||||
* failed.
|
||||
*/
|
||||
void parseOutputField(StringPiece output, UErrorCode &errorCode) {
|
||||
if (U_FAILURE(errorCode)) return;
|
||||
DecimalQuantity dqOutputD;
|
||||
|
||||
dqOutputD.setToDecNumber(output, errorCode);
|
||||
if (U_SUCCESS(errorCode)) {
|
||||
_amounts[_compoundCount] = dqOutputD.toDouble();
|
||||
return;
|
||||
} else if (errorCode == U_DECIMAL_NUMBER_SYNTAX_ERROR) {
|
||||
// Not a decimal fraction, it might be a rational fraction or a unit
|
||||
// identifier: continue.
|
||||
errorCode = U_ZERO_ERROR;
|
||||
} else {
|
||||
// Unexpected error, so we propagate it.
|
||||
return;
|
||||
}
|
||||
|
||||
_measureUnits[_compoundCount] = MeasureUnit::forIdentifier(output, errorCode);
|
||||
if (U_SUCCESS(errorCode)) {
|
||||
_compoundCount++;
|
||||
_skippedFields = 0;
|
||||
return;
|
||||
}
|
||||
_skippedFields++;
|
||||
if (_skippedFields < 2) {
|
||||
// We are happy skipping one field per output unit: we want to skip
|
||||
// rational fraction fiels like "11 / 10".
|
||||
errorCode = U_ZERO_ERROR;
|
||||
return;
|
||||
} else {
|
||||
// Propagate the error.
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Produces an output string for debug purposes.
|
||||
*/
|
||||
std::string toDebugString() {
|
||||
std::string result;
|
||||
for (int i = 0; i < _compoundCount; i++) {
|
||||
result += std::to_string(_amounts[i]);
|
||||
result += " ";
|
||||
result += _measureUnits[i].getIdentifier();
|
||||
result += " ";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* WIP(hugovdm): deals with a single data-driven unit test for unit preferences.
|
||||
* This is a UParseLineFn as required by u_parseDelimitedFile.
|
||||
*/
|
||||
void unitPreferencesTestDataLineFn(void *context, char *fields[][2], int32_t fieldCount,
|
||||
UErrorCode *pErrorCode) {
|
||||
if (U_FAILURE(*pErrorCode)) return;
|
||||
UnitsTest *unitsTest = (UnitsTest *)context;
|
||||
IcuTestErrorCode status(*unitsTest, "unitPreferencesTestDatalineFn");
|
||||
|
||||
if (!unitsTest->assertTrue(u"unitPreferencesTestDataLineFn expects 9 fields for simple and 11 "
|
||||
u"fields for compound. Other field counts not yet supported. ",
|
||||
fieldCount == 9 || fieldCount == 11)) {
|
||||
return;
|
||||
}
|
||||
|
||||
StringPiece quantity = trimField(fields[0]);
|
||||
StringPiece usage = trimField(fields[1]);
|
||||
StringPiece region = trimField(fields[2]);
|
||||
// Unused // StringPiece inputR = trimField(fields[3]);
|
||||
StringPiece inputD = trimField(fields[4]);
|
||||
StringPiece inputUnit = trimField(fields[5]);
|
||||
ExpectedOutput output;
|
||||
for (int i = 6; i < fieldCount; i++) {
|
||||
output.parseOutputField(trimField(fields[i]), status);
|
||||
}
|
||||
if (status.errIfFailureAndReset("parsing unitPreferencesTestData.txt test case: %s", fields[0][0])) {
|
||||
return;
|
||||
}
|
||||
|
||||
DecimalQuantity dqInputD;
|
||||
dqInputD.setToDecNumber(inputD, status);
|
||||
if (status.errIfFailureAndReset("parsing decimal quantity: \"%.*s\"", inputD.length(),
|
||||
inputD.data())) {
|
||||
return;
|
||||
}
|
||||
double inputAmount = dqInputD.toDouble();
|
||||
|
||||
MeasureUnit inputMeasureUnit = MeasureUnit::forIdentifier(inputUnit, status);
|
||||
if (status.errIfFailureAndReset("forIdentifier(\"%.*s\")", inputUnit.length(), inputUnit.data())) {
|
||||
return;
|
||||
}
|
||||
|
||||
// WIP(hugovdm): hook this up to actual tests.
|
||||
//
|
||||
// Possible after merging in younies/tryingdouble:
|
||||
// UnitConverter converter(sourceUnit, targetUnit, *pErrorCode);
|
||||
// double got = converter.convert(1000, *pErrorCode);
|
||||
// ((UnitsTest*)context)->assertEqualsNear(quantity.data(), expected, got, 0.0001);
|
||||
|
||||
unitsTest->logln("Quantity (Category): \"%.*s\", Usage: \"%.*s\", Region: \"%.*s\", "
|
||||
"Input: \"%f %s\", Expected Output: %s",
|
||||
quantity.length(), quantity.data(), usage.length(), usage.data(), region.length(),
|
||||
region.data(), inputAmount, inputMeasureUnit.getIdentifier(),
|
||||
output.toDebugString().c_str());
|
||||
}
|
||||
|
||||
void UnitsTest::testMass() {
|
||||
IcuTestErrorCode status(*this, "Units testMass");
|
||||
/**
|
||||
* Parses the format used by unitPreferencesTest.txt, calling lineFn for each
|
||||
* line.
|
||||
*
|
||||
* This is a modified version of u_parseDelimitedFile, customised for
|
||||
* unitPreferencesTest.txt, due to it having a variable number of fields per
|
||||
* line.
|
||||
*/
|
||||
void parsePreferencesTests(const char *filename, char delimiter, char *fields[][2],
|
||||
int32_t maxFieldCount, UParseLineFn *lineFn, void *context,
|
||||
UErrorCode *pErrorCode) {
|
||||
FileStream *file;
|
||||
char line[10000];
|
||||
char *start, *limit;
|
||||
int32_t i;
|
||||
|
||||
// Test Cases
|
||||
struct TestCase {
|
||||
const char16_t *source;
|
||||
const char16_t *target;
|
||||
const double inputValue;
|
||||
const double expectedValue;
|
||||
} testCases[]{
|
||||
{u"gram", u"kilogram", 1.0, 0.001}, //
|
||||
{u"pound", u"kilogram", 1.0, 0.453592}, //
|
||||
{u"pound", u"kilogram", 2.0, 0.907185}, //
|
||||
{u"ounce", u"pound", 16.0, 1.0}, //
|
||||
{u"ounce", u"kilogram", 16.0, 0.453592}, //
|
||||
{u"ton", u"pound", 1.0, 2000}, //
|
||||
{u"stone", u"pound", 1.0, 14}, //
|
||||
{u"stone", u"kilogram", 1.0, 6.35029} //
|
||||
};
|
||||
if (U_FAILURE(*pErrorCode)) { return; }
|
||||
|
||||
for (const auto &testCase : testCases) {
|
||||
assertEquals("test convert", testConvert(testCase.source, testCase.target, testCase.inputValue),
|
||||
testCase.expectedValue);
|
||||
if (fields == NULL || lineFn == NULL || maxFieldCount <= 0) {
|
||||
*pErrorCode = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
if (filename == NULL || *filename == 0 || (*filename == '-' && filename[1] == 0)) {
|
||||
filename = NULL;
|
||||
file = T_FileStream_stdin();
|
||||
} else {
|
||||
file = T_FileStream_open(filename, "r");
|
||||
}
|
||||
if (file == NULL) {
|
||||
*pErrorCode = U_FILE_ACCESS_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
while (T_FileStream_readLine(file, line, sizeof(line)) != NULL) {
|
||||
/* remove trailing newline characters */
|
||||
u_rtrim(line);
|
||||
|
||||
start = line;
|
||||
*pErrorCode = U_ZERO_ERROR;
|
||||
|
||||
/* skip this line if it is empty or a comment */
|
||||
if (*start == 0 || *start == '#') { continue; }
|
||||
|
||||
/* remove in-line comments */
|
||||
limit = uprv_strchr(start, '#');
|
||||
if (limit != NULL) {
|
||||
/* get white space before the pound sign */
|
||||
while (limit > start && U_IS_INV_WHITESPACE(*(limit - 1))) {
|
||||
--limit;
|
||||
}
|
||||
|
||||
/* truncate the line */
|
||||
*limit = 0;
|
||||
}
|
||||
|
||||
/* skip lines with only whitespace */
|
||||
if (u_skipWhitespace(start)[0] == 0) { continue; }
|
||||
|
||||
/* for each field, call the corresponding field function */
|
||||
for (i = 0; i < maxFieldCount; ++i) {
|
||||
/* set the limit pointer of this field */
|
||||
limit = start;
|
||||
while (*limit != delimiter && *limit != 0) {
|
||||
++limit;
|
||||
}
|
||||
|
||||
/* set the field start and limit in the fields array */
|
||||
fields[i][0] = start;
|
||||
fields[i][1] = limit;
|
||||
|
||||
/* set start to the beginning of the next field, if any */
|
||||
start = limit;
|
||||
if (*start != 0) {
|
||||
++start;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == maxFieldCount) { *pErrorCode = U_PARSE_ERROR; }
|
||||
int fieldCount = i + 1;
|
||||
|
||||
/* call the field function */
|
||||
lineFn(context, fields, fieldCount, pErrorCode);
|
||||
if (U_FAILURE(*pErrorCode)) { break; }
|
||||
}
|
||||
|
||||
if (filename != NULL) { T_FileStream_close(file); }
|
||||
}
|
||||
|
||||
void UnitsTest::testTemperature() {
|
||||
IcuTestErrorCode status(*this, "Units testTemperature");
|
||||
// Test Cases
|
||||
struct TestCase {
|
||||
const char16_t *source;
|
||||
const char16_t *target;
|
||||
const double inputValue;
|
||||
const double expectedValue;
|
||||
} testCases[]{
|
||||
{u"celsius", u"fahrenheit", 0.0, 32.0}, //
|
||||
{u"celsius", u"fahrenheit", 10.0, 50.0}, //
|
||||
{u"fahrenheit", u"celsius", 32.0, 0.0}, //
|
||||
{u"fahrenheit", u"celsius", 89.6, 32}, //
|
||||
{u"kelvin", u"fahrenheit", 0.0, -459.67}, //
|
||||
{u"kelvin", u"fahrenheit", 300, 80.33}, //
|
||||
{u"kelvin", u"celsius", 0.0, -273.15}, //
|
||||
{u"kelvin", u"celsius", 300.0, 26.85} //
|
||||
};
|
||||
/**
|
||||
* Runs data-driven unit tests for unit preferences.
|
||||
*/
|
||||
void UnitsTest::testPreferences() {
|
||||
const char *filename = "unitPreferencesTest.txt";
|
||||
const int32_t maxFields = 11;
|
||||
char *fields[maxFields][2];
|
||||
|
||||
for (const auto &testCase : testCases) {
|
||||
assertEquals("test convert", testConvert(testCase.source, testCase.target, testCase.inputValue),
|
||||
testCase.expectedValue);
|
||||
IcuTestErrorCode errorCode(*this, "UnitsTest::testPreferences");
|
||||
const char *sourceTestDataPath = getSourceTestData(errorCode);
|
||||
if (errorCode.errIfFailureAndReset("unable to find the source/test/testdata "
|
||||
"folder (getSourceTestData())")) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void UnitsTest::testArea() {
|
||||
IcuTestErrorCode status(*this, "Units Area");
|
||||
CharString path(sourceTestDataPath, errorCode);
|
||||
path.appendPathPart("units", errorCode);
|
||||
path.appendPathPart(filename, errorCode);
|
||||
|
||||
// Test Cases
|
||||
struct TestCase {
|
||||
const char16_t *source;
|
||||
const char16_t *target;
|
||||
const double inputValue;
|
||||
const double expectedValue;
|
||||
} testCases[]{
|
||||
{u"square-meter", u"square-yard", 10.0, 11.9599}, //
|
||||
{u"hectare", u"square-yard", 1.0, 11959.9}, //
|
||||
{u"square-mile", u"square-foot", 0.0001, 2787.84} //
|
||||
};
|
||||
|
||||
for (const auto &testCase : testCases) {
|
||||
assertEquals("test convert", testConvert(testCase.source, testCase.target, testCase.inputValue),
|
||||
testCase.expectedValue);
|
||||
parsePreferencesTests(path.data(), ';', fields, maxFields, unitPreferencesTestDataLineFn, this,
|
||||
errorCode);
|
||||
if (errorCode.errIfFailureAndReset("error parsing %s: %s\n", path.data(), u_errorName(errorCode))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
453
icu4c/source/test/testdata/units/unitPreferencesTest.txt
vendored
Normal file
453
icu4c/source/test/testdata/units/unitPreferencesTest.txt
vendored
Normal file
|
@ -0,0 +1,453 @@
|
|||
# This file is a copy of common/testData/units/unitPreferencesTest.txt from CLDR.
|
||||
# WIP/TODO(hugovdm): determine a good update procedure and document it.
|
||||
#
|
||||
# Test data for unit preferences
|
||||
# Copyright © 1991-2020 Unicode, Inc.
|
||||
# For terms of use, see http://www.unicode.org/copyright.html
|
||||
# Unicode and the Unicode Logo are registered trademarks of Unicode, Inc. in the U.S. and other countries.
|
||||
# CLDR data files are interpreted according to the LDML specification (http://unicode.org/reports/tr35/)
|
||||
#
|
||||
# Format:
|
||||
# Quantity; Usage; Region; Input (r); Input (d); Input Unit; Output (r); Output (d); Output Unit
|
||||
#
|
||||
# Use: Convert the Input amount & unit according to the Usage and Region.
|
||||
# The result should match the Output amount and unit.
|
||||
# Both rational (r) and double64 (d) forms of the input and output amounts are supplied so that implementations
|
||||
# have two options for testing based on the precision in their implementations. For example:
|
||||
# 3429 / 12500; 0.27432; meter;
|
||||
# The Output amount and Unit are repeated for mixed units. In such a case, only the smallest unit will have
|
||||
# both a rational and decimal amount; the others will have a single integer value, such as:
|
||||
# length; person-height; CA; 3429 / 12500; 0.27432; meter; 2; foot; 54 / 5; 10.8; inch
|
||||
# The input and output units are unit identifers; in particular, the output does not have further processing:
|
||||
# • no localization
|
||||
# • no adjustment for pluralization
|
||||
# • 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, and look at TestUnitPreferences results.
|
||||
|
||||
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
|
||||
area; default; 001; 900000; 900000.0; square-meter; 90; 90.0; hectare
|
||||
area; default; 001; 10000; 10000.0; square-meter; 1; 1.0; hectare
|
||||
area; default; 001; 9000; 9000.0; square-meter; 9000; 9000.0; square-meter
|
||||
area; default; 001; 1; 1.0; square-meter; 1; 1.0; square-meter
|
||||
area; default; 001; 9 / 10; 0.9; square-meter; 9000; 9000.0; square-centimeter
|
||||
area; default; 001; 1 / 10000; 1.0E-4; square-meter; 1; 1.0; square-centimeter
|
||||
area; default; 001; 9 / 100000; 9.0E-5; square-meter; 9 / 10; 0.9; square-centimeter
|
||||
|
||||
area; default; GB; 222577103232 / 78125; 2848986.9213696; square-meter; 11 / 10; 1.1; square-mile
|
||||
area; default; GB; 40468564224 / 15625; 2589988.110336; square-meter; 1; 1.0; square-mile
|
||||
area; default; GB; 182108539008 / 78125; 2330989.2993024; square-meter; 576; 576.0; acre
|
||||
area; default; GB; 316160658 / 78125; 4046.8564224; square-meter; 1; 1.0; acre
|
||||
area; default; GB; 1422722961 / 390625; 3642.17078016; square-meter; 39204; 39204.0; square-foot
|
||||
area; default; GB; 145161 / 1562500; 0.09290304; square-meter; 1; 1.0; square-foot
|
||||
area; default; GB; 1306449 / 15625000; 0.083612736; square-meter; 648 / 5; 129.6; square-inch
|
||||
area; default; GB; 16129 / 25000000; 6.4516E-4; square-meter; 1; 1.0; square-inch
|
||||
area; default; GB; 145161 / 250000000; 5.80644E-4; square-meter; 9 / 10; 0.9; square-inch
|
||||
|
||||
area; geograph; 001; 1100000; 1100000.0; square-meter; 11 / 10; 1.1; square-kilometer
|
||||
area; geograph; 001; 1000000; 1000000.0; square-meter; 1; 1.0; square-kilometer
|
||||
area; geograph; 001; 900000; 900000.0; square-meter; 9 / 10; 0.9; square-kilometer
|
||||
|
||||
area; geograph; GB; 222577103232 / 78125; 2848986.9213696; square-meter; 11 / 10; 1.1; square-mile
|
||||
area; geograph; GB; 40468564224 / 15625; 2589988.110336; square-meter; 1; 1.0; square-mile
|
||||
area; geograph; GB; 182108539008 / 78125; 2330989.2993024; square-meter; 9 / 10; 0.9; square-mile
|
||||
|
||||
area; land; 001; 11000; 11000.0; square-meter; 11 / 10; 1.1; hectare
|
||||
area; land; 001; 10000; 10000.0; square-meter; 1; 1.0; hectare
|
||||
area; land; 001; 9000; 9000.0; square-meter; 9 / 10; 0.9; hectare
|
||||
|
||||
area; land; GB; 1738883619 / 390625; 4451.54206464; square-meter; 11 / 10; 1.1; acre
|
||||
area; land; GB; 316160658 / 78125; 4046.8564224; square-meter; 1; 1.0; acre
|
||||
area; land; GB; 1422722961 / 390625; 3642.17078016; square-meter; 9 / 10; 0.9; acre
|
||||
|
||||
concentration; blood-glucose; AG; 662435483600000000000000; 6.624354836E23; item-per-cubic-meter; 11 / 10; 1.1; millimole-per-liter
|
||||
concentration; blood-glucose; AG; 602214076000000000000000; 6.02214076E23; item-per-cubic-meter; 1; 1.0; millimole-per-liter
|
||||
concentration; blood-glucose; AG; 541992668400000000000000; 5.419926684E23; item-per-cubic-meter; 9 / 10; 0.9; millimole-per-liter
|
||||
|
||||
concentration; default; 001; 11 / 10; 1.1; item-per-cubic-meter; 11 / 10; 1.1; item-per-cubic-meter
|
||||
concentration; default; 001; 1; 1.0; item-per-cubic-meter; 1; 1.0; item-per-cubic-meter
|
||||
concentration; default; 001; 9 / 10; 0.9; item-per-cubic-meter; 9 / 10; 0.9; item-per-cubic-meter
|
||||
|
||||
consumption; default; 001; 11 / 1000000000; 1.1E-8; cubic-meter-per-meter; 11 / 10; 1.1; liter-per-100-kilometer
|
||||
consumption; default; 001; 1 / 100000000; 1.0E-8; cubic-meter-per-meter; 1; 1.0; liter-per-100-kilometer
|
||||
consumption; default; 001; 9 / 1000000000; 9.0E-9; cubic-meter-per-meter; 9 / 10; 0.9; liter-per-100-kilometer
|
||||
|
||||
consumption; vehicle-fuel; 001; 11 / 1000000000; 1.1E-8; cubic-meter-per-meter; 11 / 10; 1.1; liter-per-100-kilometer
|
||||
consumption; vehicle-fuel; 001; 1 / 100000000; 1.0E-8; cubic-meter-per-meter; 1; 1.0; liter-per-100-kilometer
|
||||
consumption; vehicle-fuel; 001; 9 / 1000000000; 9.0E-9; cubic-meter-per-meter; 9 / 10; 0.9; liter-per-100-kilometer
|
||||
|
||||
consumption; vehicle-fuel; BR; 11 / 10000000; 1.1E-6; cubic-meter-per-meter; 11 / 10; 1.1; liter-per-kilometer
|
||||
consumption; vehicle-fuel; BR; 1 / 1000000; 1.0E-6; cubic-meter-per-meter; 1; 1.0; liter-per-kilometer
|
||||
consumption; vehicle-fuel; BR; 9 / 10000000; 9.0E-7; cubic-meter-per-meter; 9 / 10; 0.9; liter-per-kilometer
|
||||
|
||||
consumption-inverse; default; 001; 110000000; 1.1E8; meter-per-cubic-meter; 11 / 10; 1.1; kilometer-per-centiliter
|
||||
consumption-inverse; default; 001; 100000000; 1.0E8; meter-per-cubic-meter; 1; 1.0; kilometer-per-centiliter
|
||||
consumption-inverse; default; 001; 90000000; 9.0E7; meter-per-cubic-meter; 9 / 10; 0.9; kilometer-per-centiliter
|
||||
|
||||
consumption-inverse; vehicle-fuel; 001; 110000000; 1.1E8; meter-per-cubic-meter; 11 / 10; 1.1; kilometer-per-centiliter
|
||||
consumption-inverse; vehicle-fuel; 001; 100000000; 1.0E8; meter-per-cubic-meter; 1; 1.0; kilometer-per-centiliter
|
||||
consumption-inverse; vehicle-fuel; 001; 90000000; 9.0E7; meter-per-cubic-meter; 9 / 10; 0.9; kilometer-per-centiliter
|
||||
|
||||
consumption-inverse; vehicle-fuel; US; 52800000000 / 112903; 467658.0781732992; meter-per-cubic-meter; 11 / 10; 1.1; mile-per-gallon
|
||||
consumption-inverse; vehicle-fuel; US; 48000000000 / 112903; 425143.707430272; meter-per-cubic-meter; 1; 1.0; mile-per-gallon
|
||||
consumption-inverse; vehicle-fuel; US; 43200000000 / 112903; 382629.3366872448; meter-per-cubic-meter; 9 / 10; 0.9; mile-per-gallon
|
||||
|
||||
consumption-inverse; vehicle-fuel; CA; 177027840000 / 454609; 389406.8089281118; meter-per-cubic-meter; 11 / 10; 1.1; mile-per-gallon-imperial
|
||||
consumption-inverse; vehicle-fuel; CA; 160934400000 / 454609; 354006.1899346471; meter-per-cubic-meter; 1; 1.0; mile-per-gallon-imperial
|
||||
consumption-inverse; vehicle-fuel; CA; 144840960000 / 454609; 318605.5709411824; meter-per-cubic-meter; 9 / 10; 0.9; mile-per-gallon-imperial
|
||||
|
||||
duration; default; 001; 95040; 95040.0; second; 11 / 10; 1.1; day
|
||||
duration; default; 001; 86400; 86400.0; second; 1; 1.0; day
|
||||
duration; default; 001; 77760; 77760.0; second; 108 / 5; 21.6; hour
|
||||
duration; default; 001; 3600; 3600.0; second; 1; 1.0; hour
|
||||
duration; default; 001; 3240; 3240.0; second; 54; 54.0; minute
|
||||
duration; default; 001; 60; 60.0; second; 1; 1.0; minute
|
||||
duration; default; 001; 54; 54.0; second; 54; 54.0; second
|
||||
duration; default; 001; 1; 1.0; second; 1; 1.0; second
|
||||
duration; default; 001; 9 / 10; 0.9; second; 900; 900.0; millisecond
|
||||
duration; default; 001; 1 / 1000; 0.001; second; 1; 1.0; millisecond
|
||||
duration; default; 001; 9 / 10000; 9.0E-4; second; 900; 900.0; microsecond
|
||||
duration; default; 001; 1 / 1000000; 1.0E-6; second; 1; 1.0; microsecond
|
||||
duration; default; 001; 9 / 10000000; 9.0E-7; second; 900; 900.0; nanosecond
|
||||
duration; default; 001; 1 / 1000000000; 1.0E-9; second; 1; 1.0; nanosecond
|
||||
duration; default; 001; 9 / 10000000000; 9.0E-10; second; 9 / 10; 0.9; nanosecond
|
||||
|
||||
duration; media; 001; 66; 66.0; second; 1; minute; 6; 6.0; second
|
||||
duration; media; 001; 60; 60.0; second; 1; minute; 0; 0.0; second
|
||||
duration; media; 001; 54; 54.0; second; 54; 54.0; second
|
||||
duration; media; 001; 1; 1.0; second; 1; 1.0; second
|
||||
duration; media; 001; 9 / 10; 0.9; second; 9 / 10; 0.9; second
|
||||
|
||||
energy; default; 001; 3960000; 3960000.0; kilogram-square-meter-per-square-second; 11 / 10; 1.1; kilowatt-hour
|
||||
energy; default; 001; 3600000; 3600000.0; kilogram-square-meter-per-square-second; 1; 1.0; kilowatt-hour
|
||||
energy; default; 001; 3240000; 3240000.0; kilogram-square-meter-per-square-second; 9 / 10; 0.9; kilowatt-hour
|
||||
|
||||
energy; food; US; 23012 / 5; 4602.4; kilogram-square-meter-per-square-second; 11 / 10; 1.1; foodcalorie
|
||||
energy; food; US; 4184; 4184.0; kilogram-square-meter-per-square-second; 1; 1.0; foodcalorie
|
||||
energy; food; US; 18828 / 5; 3765.6; kilogram-square-meter-per-square-second; 9 / 10; 0.9; foodcalorie
|
||||
|
||||
energy; food; 001; 23012 / 5; 4602.4; kilogram-square-meter-per-square-second; 11 / 10; 1.1; kilocalorie
|
||||
energy; food; 001; 4184; 4184.0; kilogram-square-meter-per-square-second; 1; 1.0; kilocalorie
|
||||
energy; food; 001; 18828 / 5; 3765.6; kilogram-square-meter-per-square-second; 9 / 10; 0.9; kilocalorie
|
||||
|
||||
length; default; 001; 1100; 1100.0; meter; 11 / 10; 1.1; kilometer
|
||||
length; default; 001; 1000; 1000.0; meter; 1; 1.0; kilometer
|
||||
length; default; 001; 900; 900.0; meter; 900; 900.0; meter
|
||||
length; default; 001; 1; 1.0; meter; 1; 1.0; meter
|
||||
length; default; 001; 9 / 10; 0.9; meter; 90; 90.0; centimeter
|
||||
length; default; 001; 1 / 100; 0.01; meter; 1; 1.0; centimeter
|
||||
length; default; 001; 9 / 1000; 0.009; meter; 9 / 10; 0.9; centimeter
|
||||
|
||||
length; default; GB; 1106424 / 625; 1770.2784; meter; 11 / 10; 1.1; mile
|
||||
length; default; GB; 201168 / 125; 1609.344; meter; 1; 1.0; mile
|
||||
length; default; GB; 905256 / 625; 1448.4096; meter; 4752; 4752.0; foot
|
||||
length; default; GB; 381 / 1250; 0.3048; meter; 1; 1.0; foot
|
||||
length; default; GB; 3429 / 12500; 0.27432; meter; 54 / 5; 10.8; inch
|
||||
length; default; GB; 127 / 5000; 0.0254; meter; 1; 1.0; inch
|
||||
length; default; GB; 1143 / 50000; 0.02286; meter; 9 / 10; 0.9; inch
|
||||
|
||||
length; person; 001; 11 / 1000; 0.011; meter; 11 / 10; 1.1; centimeter
|
||||
length; person; 001; 1 / 100; 0.01; meter; 1; 1.0; centimeter
|
||||
length; person; 001; 9 / 1000; 0.009; meter; 9 / 10; 0.9; centimeter
|
||||
|
||||
length; person; CA; 1397 / 50000; 0.02794; meter; 11 / 10; 1.1; inch
|
||||
length; person; CA; 127 / 5000; 0.0254; meter; 1; 1.0; inch
|
||||
length; person; CA; 1143 / 50000; 0.02286; meter; 9 / 10; 0.9; inch
|
||||
|
||||
length; person-height; 001; 11 / 1000; 0.011; meter; 11 / 10; 1.1; centimeter
|
||||
length; person-height; 001; 1 / 100; 0.01; meter; 1; 1.0; centimeter
|
||||
length; person-height; 001; 9 / 1000; 0.009; meter; 9 / 10; 0.9; centimeter
|
||||
|
||||
length; person-height; CA; 11811 / 12500; 0.94488; meter; 3; foot; 6 / 5; 1.2; inch
|
||||
length; person-height; CA; 1143 / 1250; 0.9144; meter; 3; foot; 0; 0.0; inch
|
||||
length; person-height; CA; 11049 / 12500; 0.88392; meter; 174 / 5; 34.8; inch
|
||||
length; person-height; CA; 127 / 5000; 0.0254; meter; 1; 1.0; inch
|
||||
length; person-height; CA; 1143 / 50000; 0.02286; meter; 9 / 10; 0.9; inch
|
||||
|
||||
length; person-height; AT; 11 / 10; 1.1; meter; 1; meter; 10; 10.0; centimeter
|
||||
length; person-height; AT; 1; 1.0; meter; 1; meter; 0; 0.0; centimeter
|
||||
length; person-height; AT; 9 / 10; 0.9; meter; 0; meter; 90; 90.0; centimeter
|
||||
|
||||
length; rainfall; BR; 11 / 1000; 0.011; meter; 11 / 10; 1.1; centimeter
|
||||
length; rainfall; BR; 1 / 100; 0.01; meter; 1; 1.0; centimeter
|
||||
length; rainfall; BR; 9 / 1000; 0.009; meter; 9 / 10; 0.9; centimeter
|
||||
|
||||
length; rainfall; US; 1397 / 50000; 0.02794; meter; 11 / 10; 1.1; inch
|
||||
length; rainfall; US; 127 / 5000; 0.0254; meter; 1; 1.0; inch
|
||||
length; rainfall; US; 1143 / 50000; 0.02286; meter; 9 / 10; 0.9; inch
|
||||
|
||||
length; rainfall; 001; 11 / 10000; 0.0011; meter; 11 / 10; 1.1; millimeter
|
||||
length; rainfall; 001; 1 / 1000; 0.001; meter; 1; 1.0; millimeter
|
||||
length; rainfall; 001; 9 / 10000; 9.0E-4; meter; 9 / 10; 0.9; millimeter
|
||||
|
||||
length; road; 001; 1000; 1000.0; meter; 1; 1.0; kilometer
|
||||
length; road; 001; 900; 900.0; meter; 9 / 10; 0.9; kilometer
|
||||
length; road; 001; 800; 800.0; meter; 800; 800.0; meter
|
||||
length; road; 001; 300; 300.0; meter; 300; 300.0; meter
|
||||
length; road; 001; 2999 / 10; 299.9; meter; 2999 / 10; 299.9; meter
|
||||
length; road; 001; 1; 1.0; meter; 1; 1.0; meter
|
||||
length; road; 001; 9 / 10; 0.9; meter; 9 / 10; 0.9; meter
|
||||
|
||||
length; road; US; 603504 / 625; 965.6064; meter; 3 / 5; 0.6; mile
|
||||
length; road; US; 100584 / 125; 804.672; meter; 1 / 2; 0.5; mile
|
||||
length; road; US; 402336 / 625; 643.7376; meter; 2112; 2112.0; foot
|
||||
length; road; US; 762 / 25; 30.48; meter; 100; 100.0; foot
|
||||
length; road; US; 380619 / 12500; 30.44952; meter; 999 / 10; 99.9; foot
|
||||
length; road; US; 381 / 1250; 0.3048; meter; 1; 1.0; foot
|
||||
length; road; US; 3429 / 12500; 0.27432; meter; 9 / 10; 0.9; foot
|
||||
|
||||
length; road; GB; 603504 / 625; 965.6064; meter; 3 / 5; 0.6; mile
|
||||
length; road; GB; 100584 / 125; 804.672; meter; 1 / 2; 0.5; mile
|
||||
length; road; GB; 402336 / 625; 643.7376; meter; 704; 704.0; yard
|
||||
length; road; GB; 2286 / 25; 91.44; meter; 100; 100.0; yard
|
||||
length; road; GB; 1141857 / 12500; 91.34856; meter; 999 / 10; 99.9; yard
|
||||
length; road; GB; 1143 / 1250; 0.9144; meter; 1; 1.0; yard
|
||||
length; road; GB; 10287 / 12500; 0.82296; meter; 9 / 10; 0.9; yard
|
||||
|
||||
length; road; SE; 11000; 11000.0; meter; 11 / 10; 1.1; mile-scandinavian
|
||||
length; road; SE; 10000; 10000.0; meter; 1; 1.0; mile-scandinavian
|
||||
length; road; SE; 9000; 9000.0; meter; 9; 9.0; kilometer
|
||||
length; road; SE; 1000; 1000.0; meter; 1; 1.0; kilometer
|
||||
length; road; SE; 900; 900.0; meter; 900; 900.0; meter
|
||||
length; road; SE; 300; 300.0; meter; 300; 300.0; meter
|
||||
length; road; SE; 2999 / 10; 299.9; meter; 2999 / 10; 299.9; meter
|
||||
length; road; SE; 1; 1.0; meter; 1; 1.0; meter
|
||||
length; road; SE; 9 / 10; 0.9; meter; 9 / 10; 0.9; meter
|
||||
|
||||
length; snowfall; 001; 11 / 1000; 0.011; meter; 11 / 10; 1.1; centimeter
|
||||
length; snowfall; 001; 1 / 100; 0.01; meter; 1; 1.0; centimeter
|
||||
length; snowfall; 001; 9 / 1000; 0.009; meter; 9 / 10; 0.9; centimeter
|
||||
|
||||
length; snowfall; US; 1397 / 50000; 0.02794; meter; 11 / 10; 1.1; inch
|
||||
length; snowfall; US; 127 / 5000; 0.0254; meter; 1; 1.0; inch
|
||||
length; snowfall; US; 1143 / 50000; 0.02286; meter; 9 / 10; 0.9; inch
|
||||
|
||||
length; vehicle; GB; 4191 / 12500; 0.33528; meter; 1; foot; 6 / 5; 1.2; inch
|
||||
length; vehicle; GB; 381 / 1250; 0.3048; meter; 1; foot; 0; 0.0; inch
|
||||
length; vehicle; GB; 3429 / 12500; 0.27432; meter; 0; foot; 54 / 5; 10.8; inch
|
||||
|
||||
length; vehicle; 001; 11 / 10; 1.1; meter; 11 / 10; 1.1; meter
|
||||
length; vehicle; 001; 1; 1.0; meter; 1; 1.0; meter
|
||||
length; vehicle; 001; 9 / 10; 0.9; meter; 9 / 10; 0.9; meter
|
||||
|
||||
length; vehicle; MX; 11 / 10; 1.1; meter; 1; meter; 10; 10.0; centimeter
|
||||
length; vehicle; MX; 1; 1.0; meter; 1; meter; 0; 0.0; centimeter
|
||||
length; vehicle; MX; 9 / 10; 0.9; meter; 0; meter; 90; 90.0; centimeter
|
||||
|
||||
length; visiblty; 001; 200; 200.0; meter; 1 / 5; 0.2; kilometer
|
||||
length; visiblty; 001; 100; 100.0; meter; 1 / 10; 0.1; kilometer
|
||||
length; visiblty; 001; 1; 1.0; meter; 1; 1.0; meter
|
||||
length; visiblty; 001; 9 / 10; 0.9; meter; 9 / 10; 0.9; meter
|
||||
length; visiblty; 001; 0; 0.0; meter; 0; 0.0; meter
|
||||
|
||||
length; visiblty; DE; 11 / 10; 1.1; meter; 11 / 10; 1.1; meter
|
||||
length; visiblty; DE; 1; 1.0; meter; 1; 1.0; meter
|
||||
length; visiblty; DE; 9 / 10; 0.9; meter; 9 / 10; 0.9; meter
|
||||
|
||||
length; visiblty; GB; 1106424 / 625; 1770.2784; meter; 11 / 10; 1.1; mile
|
||||
length; visiblty; GB; 201168 / 125; 1609.344; meter; 1; 1.0; mile
|
||||
length; visiblty; GB; 905256 / 625; 1448.4096; meter; 4752; 4752.0; foot
|
||||
length; visiblty; GB; 381 / 1250; 0.3048; meter; 1; 1.0; foot
|
||||
length; visiblty; GB; 3429 / 12500; 0.27432; meter; 9 / 10; 0.9; foot
|
||||
|
||||
mass; default; 001; 1100; 1100.0; kilogram; 11 / 10; 1.1; metric-ton
|
||||
mass; default; 001; 1000; 1000.0; kilogram; 1; 1.0; metric-ton
|
||||
mass; default; 001; 900; 900.0; kilogram; 900; 900.0; kilogram
|
||||
mass; default; 001; 1; 1.0; kilogram; 1; 1.0; kilogram
|
||||
mass; default; 001; 9 / 10; 0.9; kilogram; 900; 900.0; gram
|
||||
mass; default; 001; 1 / 1000; 0.001; kilogram; 1; 1.0; gram
|
||||
mass; default; 001; 9 / 10000; 9.0E-4; kilogram; 900; 900.0; milligram
|
||||
mass; default; 001; 1 / 1000000; 1.0E-6; kilogram; 1; 1.0; milligram
|
||||
mass; default; 001; 9 / 10000000; 9.0E-7; kilogram; 900; 900.0; microgram
|
||||
mass; default; 001; 1 / 1000000000; 1.0E-9; kilogram; 1; 1.0; microgram
|
||||
mass; default; 001; 9 / 10000000000; 9.0E-10; kilogram; 9 / 10; 0.9; microgram
|
||||
|
||||
mass; default; GB; 498951607 / 500000; 997.903214; kilogram; 11 / 10; 1.1; ton
|
||||
mass; default; GB; 45359237 / 50000; 907.18474; kilogram; 1; 1.0; ton
|
||||
mass; default; GB; 408233133 / 500000; 816.466266; kilogram; 1800; 1800.0; pound
|
||||
mass; default; GB; 45359237 / 100000000; 0.45359237; kilogram; 1; 1.0; pound
|
||||
mass; default; GB; 408233133 / 1000000000; 0.408233133; kilogram; 72 / 5; 14.4; ounce
|
||||
mass; default; GB; 45359237 / 1600000000; 0.028349523125; kilogram; 1; 1.0; ounce
|
||||
mass; default; GB; 408233133 / 16000000000; 0.0255145708125; kilogram; 9 / 10; 0.9; ounce
|
||||
|
||||
mass; person; 001; 11 / 10; 1.1; kilogram; 11 / 10; 1.1; kilogram
|
||||
mass; person; 001; 1; 1.0; kilogram; 1; 1.0; kilogram
|
||||
mass; person; 001; 9 / 10; 0.9; kilogram; 900; 900.0; gram
|
||||
mass; person; 001; 1 / 1000; 0.001; kilogram; 1; 1.0; gram
|
||||
mass; person; 001; 9 / 10000; 9.0E-4; kilogram; 9 / 10; 0.9; gram
|
||||
|
||||
mass; person; DZ; 11 / 10; 1.1; kilogram; 1; kilogram; 100; 100.0; gram
|
||||
mass; person; DZ; 1; 1.0; kilogram; 1; kilogram; 0; 0.0; gram
|
||||
mass; person; DZ; 9 / 10; 0.9; kilogram; 0; kilogram; 900; 900.0; gram
|
||||
|
||||
mass; person; US; 498951607 / 1000000000; 0.498951607; kilogram; 11 / 10; 1.1; pound
|
||||
mass; person; US; 45359237 / 100000000; 0.45359237; kilogram; 1; 1.0; pound
|
||||
mass; person; US; 408233133 / 1000000000; 0.408233133; kilogram; 0; pound; 72 / 5; 14.4; ounce
|
||||
|
||||
mass; person; GB; 3492661249 / 500000000; 6.985322498; kilogram; 1; stone; 7 / 5; 1.4; pound
|
||||
mass; person; GB; 317514659 / 50000000; 6.35029318; kilogram; 1; stone; 0; 0.0; pound
|
||||
mass; person; GB; 2857631931 / 500000000; 5.715263862; kilogram; 12; pound; 48 / 5; 9.6; ounce
|
||||
mass; person; GB; 45359237 / 100000000; 0.45359237; kilogram; 1; pound; 0; 0.0; ounce
|
||||
mass; person; GB; 408233133 / 1000000000; 0.408233133; kilogram; 0; pound; 72 / 5; 14.4; ounce
|
||||
|
||||
mass; person; HK; 498951607 / 1000000000; 0.498951607; kilogram; 1; pound; 8 / 5; 1.6; ounce
|
||||
mass; person; HK; 45359237 / 100000000; 0.45359237; kilogram; 1; pound; 0; 0.0; ounce
|
||||
mass; person; HK; 408233133 / 1000000000; 0.408233133; kilogram; 0; pound; 72 / 5; 14.4; ounce
|
||||
|
||||
mass-density; blood-glucose; 001; 11 / 1000; 0.011; kilogram-per-cubic-meter; 11 / 10; 1.1; milligram-per-deciliter
|
||||
mass-density; blood-glucose; 001; 1 / 100; 0.01; kilogram-per-cubic-meter; 1; 1.0; milligram-per-deciliter
|
||||
mass-density; blood-glucose; 001; 9 / 1000; 0.009; kilogram-per-cubic-meter; 9 / 10; 0.9; milligram-per-deciliter
|
||||
|
||||
mass-density; default; 001; 11 / 10; 1.1; kilogram-per-cubic-meter; 11 / 10; 1.1; kilogram-per-cubic-meter
|
||||
mass-density; default; 001; 1; 1.0; kilogram-per-cubic-meter; 1; 1.0; kilogram-per-cubic-meter
|
||||
mass-density; default; 001; 9 / 10; 0.9; kilogram-per-cubic-meter; 9 / 10; 0.9; kilogram-per-cubic-meter
|
||||
|
||||
power; default; 001; 1100000000; 1.1E9; kilogram-square-meter-per-cubic-second; 11 / 10; 1.1; gigawatt
|
||||
power; default; 001; 1000000000; 1.0E9; kilogram-square-meter-per-cubic-second; 1; 1.0; gigawatt
|
||||
power; default; 001; 900000000; 9.0E8; kilogram-square-meter-per-cubic-second; 900; 900.0; megawatt
|
||||
power; default; 001; 1000000; 1000000.0; kilogram-square-meter-per-cubic-second; 1; 1.0; megawatt
|
||||
power; default; 001; 900000; 900000.0; kilogram-square-meter-per-cubic-second; 900; 900.0; kilowatt
|
||||
power; default; 001; 1000; 1000.0; kilogram-square-meter-per-cubic-second; 1; 1.0; kilowatt
|
||||
power; default; 001; 900; 900.0; kilogram-square-meter-per-cubic-second; 900; 900.0; watt
|
||||
power; default; 001; 1; 1.0; kilogram-square-meter-per-cubic-second; 1; 1.0; watt
|
||||
power; default; 001; 9 / 10; 0.9; kilogram-square-meter-per-cubic-second; 900; 900.0; milliwatt
|
||||
power; default; 001; 1 / 1000; 0.001; kilogram-square-meter-per-cubic-second; 1; 1.0; milliwatt
|
||||
power; default; 001; 9 / 10000; 9.0E-4; kilogram-square-meter-per-cubic-second; 9 / 10; 0.9; milliwatt
|
||||
|
||||
power; engine; 001; 1100; 1100.0; kilogram-square-meter-per-cubic-second; 11 / 10; 1.1; kilowatt
|
||||
power; engine; 001; 1000; 1000.0; kilogram-square-meter-per-cubic-second; 1; 1.0; kilowatt
|
||||
power; engine; 001; 900; 900.0; kilogram-square-meter-per-cubic-second; 9 / 10; 0.9; kilowatt
|
||||
|
||||
power; engine; GB; 410134929370248621 / 500000000000000; 820.2698587404972; kilogram-square-meter-per-cubic-second; 11 / 10; 1.1; horsepower
|
||||
power; engine; GB; 37284993579113511 / 50000000000000; 745.6998715822702; kilogram-square-meter-per-cubic-second; 1; 1.0; horsepower
|
||||
power; engine; GB; 335564942212021599 / 500000000000000; 671.1298844240432; kilogram-square-meter-per-cubic-second; 9 / 10; 0.9; horsepower
|
||||
|
||||
pressure; baromtrc; 001; 110; 110.0; kilogram-per-meter-square-second; 11 / 10; 1.1; hectopascal
|
||||
pressure; baromtrc; 001; 100; 100.0; kilogram-per-meter-square-second; 1; 1.0; hectopascal
|
||||
pressure; baromtrc; 001; 90; 90.0; kilogram-per-meter-square-second; 9 / 10; 0.9; hectopascal
|
||||
|
||||
pressure; baromtrc; IN; 37250275043751 / 10000000000; 3725.0275043751; kilogram-per-meter-square-second; 11 / 10; 1.1; inch-ofhg
|
||||
pressure; baromtrc; IN; 3386388640341 / 1000000000; 3386.388640341; kilogram-per-meter-square-second; 1; 1.0; inch-ofhg
|
||||
pressure; baromtrc; IN; 30477497763069 / 10000000000; 3047.7497763069; kilogram-per-meter-square-second; 9 / 10; 0.9; inch-ofhg
|
||||
|
||||
pressure; baromtrc; BR; 110; 110.0; kilogram-per-meter-square-second; 11 / 10; 1.1; millibar
|
||||
pressure; baromtrc; BR; 100; 100.0; kilogram-per-meter-square-second; 1; 1.0; millibar
|
||||
pressure; baromtrc; BR; 90; 90.0; kilogram-per-meter-square-second; 9 / 10; 0.9; millibar
|
||||
|
||||
pressure; baromtrc; MX; 293309252313 / 2000000000; 146.6546261565; kilogram-per-meter-square-second; 11 / 10; 1.1; millimeter-ofhg
|
||||
pressure; baromtrc; MX; 26664477483 / 200000000; 133.322387415; kilogram-per-meter-square-second; 1; 1.0; millimeter-ofhg
|
||||
pressure; baromtrc; MX; 239980297347 / 2000000000; 119.9901486735; kilogram-per-meter-square-second; 9 / 10; 0.9; millimeter-ofhg
|
||||
|
||||
pressure; default; 001; 1100000; 1100000.0; kilogram-per-meter-square-second; 11 / 10; 1.1; megapascal
|
||||
pressure; default; 001; 1000000; 1000000.0; kilogram-per-meter-square-second; 1; 1.0; megapascal
|
||||
pressure; default; 001; 900000; 900000.0; kilogram-per-meter-square-second; 900000; 900000.0; pascal
|
||||
pressure; default; 001; 1; 1.0; kilogram-per-meter-square-second; 1; 1.0; pascal
|
||||
pressure; default; 001; 9 / 10; 0.9; kilogram-per-meter-square-second; 9 / 10; 0.9; pascal
|
||||
|
||||
pressure; default; GB; 97860875535731 / 12903200000; 7584.233022485197; kilogram-per-meter-square-second; 11 / 10; 1.1; pound-force-per-square-inch
|
||||
pressure; default; GB; 8896443230521 / 1290320000; 6894.757293168361; kilogram-per-meter-square-second; 1; 1.0; pound-force-per-square-inch
|
||||
pressure; default; GB; 80067989074689 / 12903200000; 6205.281563851525; kilogram-per-meter-square-second; 9 / 10; 0.9; pound-force-per-square-inch
|
||||
|
||||
speed; default; 001; 11 / 36; 0.3055555555555556; meter-per-second; 11 / 10; 1.1; kilometer-per-hour
|
||||
speed; default; 001; 5 / 18; 0.2777777777777778; meter-per-second; 1; 1.0; kilometer-per-hour
|
||||
speed; default; 001; 1 / 4; 0.25; meter-per-second; 9 / 10; 0.9; kilometer-per-hour
|
||||
|
||||
speed; default; GB; 15367 / 31250; 0.491744; meter-per-second; 11 / 10; 1.1; mile-per-hour
|
||||
speed; default; GB; 1397 / 3125; 0.44704; meter-per-second; 1; 1.0; mile-per-hour
|
||||
speed; default; GB; 12573 / 31250; 0.402336; meter-per-second; 9 / 10; 0.9; mile-per-hour
|
||||
|
||||
speed; wind; 001; 11 / 36; 0.3055555555555556; meter-per-second; 11 / 10; 1.1; kilometer-per-hour
|
||||
speed; wind; 001; 5 / 18; 0.2777777777777778; meter-per-second; 1; 1.0; kilometer-per-hour
|
||||
speed; wind; 001; 1 / 4; 0.25; meter-per-second; 9 / 10; 0.9; kilometer-per-hour
|
||||
|
||||
speed; wind; FI; 11 / 10; 1.1; meter-per-second; 11 / 10; 1.1; meter-per-second
|
||||
speed; wind; FI; 1; 1.0; meter-per-second; 1; 1.0; meter-per-second
|
||||
speed; wind; FI; 9 / 10; 0.9; meter-per-second; 9 / 10; 0.9; meter-per-second
|
||||
|
||||
speed; wind; US; 15367 / 31250; 0.491744; meter-per-second; 11 / 10; 1.1; mile-per-hour
|
||||
speed; wind; US; 1397 / 3125; 0.44704; meter-per-second; 1; 1.0; mile-per-hour
|
||||
speed; wind; US; 12573 / 31250; 0.402336; meter-per-second; 9 / 10; 0.9; mile-per-hour
|
||||
|
||||
temperature; default; 001; 1097 / 4; 274.25; kelvin; 11 / 10; 1.1; celsius
|
||||
temperature; default; 001; 5483 / 20; 274.15; kelvin; 1; 1.0; celsius
|
||||
temperature; default; 001; 5481 / 20; 274.05; kelvin; 9 / 10; 0.9; celsius
|
||||
|
||||
temperature; default; US; 15359 / 60; 255.9833333333333; kelvin; 11 / 10; 1.1; fahrenheit
|
||||
temperature; default; US; 46067 / 180; 255.9277777777778; kelvin; 1; 1.0; fahrenheit
|
||||
temperature; default; US; 46057 / 180; 255.8722222222222; kelvin; 9 / 10; 0.9; fahrenheit
|
||||
|
||||
temperature; weather; 001; 1097 / 4; 274.25; kelvin; 11 / 10; 1.1; celsius
|
||||
temperature; weather; 001; 5483 / 20; 274.15; kelvin; 1; 1.0; celsius
|
||||
temperature; weather; 001; 5481 / 20; 274.05; kelvin; 9 / 10; 0.9; celsius
|
||||
|
||||
temperature; weather; BS; 15359 / 60; 255.9833333333333; kelvin; 11 / 10; 1.1; fahrenheit
|
||||
temperature; weather; BS; 46067 / 180; 255.9277777777778; kelvin; 1; 1.0; fahrenheit
|
||||
temperature; weather; BS; 46057 / 180; 255.8722222222222; kelvin; 9 / 10; 0.9; fahrenheit
|
||||
|
||||
volume; default; 001; 11 / 10; 1.1; cubic-meter; 11 / 10; 1.1; cubic-meter
|
||||
volume; default; 001; 1; 1.0; cubic-meter; 1; 1.0; cubic-meter
|
||||
volume; default; 001; 9 / 10; 0.9; cubic-meter; 900000; 900000.0; cubic-centimeter
|
||||
volume; default; 001; 1 / 1000000; 1.0E-6; cubic-meter; 1; 1.0; cubic-centimeter
|
||||
volume; default; 001; 9 / 10000000; 9.0E-7; cubic-meter; 9 / 10; 0.9; cubic-centimeter
|
||||
|
||||
volume; default; GB; 608369751 / 19531250000; 0.0311485312512; cubic-meter; 11 / 10; 1.1; cubic-foot
|
||||
volume; default; GB; 55306341 / 1953125000; 0.028316846592; cubic-meter; 1; 1.0; cubic-foot
|
||||
volume; default; GB; 497757069 / 19531250000; 0.0254851619328; cubic-meter; 7776 / 5; 1555.2; cubic-inch
|
||||
volume; default; GB; 2048383 / 125000000000; 1.6387064E-5; cubic-meter; 1; 1.0; cubic-inch
|
||||
volume; default; GB; 18435447 / 1250000000000; 1.47483576E-5; cubic-meter; 9 / 10; 0.9; cubic-inch
|
||||
|
||||
volume; fluid; 001; 11 / 10000; 0.0011; cubic-meter; 11 / 10; 1.1; liter
|
||||
volume; fluid; 001; 1 / 1000; 0.001; cubic-meter; 1; 1.0; liter
|
||||
volume; fluid; 001; 9 / 10000; 9.0E-4; cubic-meter; 900; 900.0; milliliter
|
||||
volume; fluid; 001; 1 / 1000000; 1.0E-6; cubic-meter; 1; 1.0; milliliter
|
||||
volume; fluid; 001; 9 / 10000000; 9.0E-7; cubic-meter; 9 / 10; 0.9; milliliter
|
||||
|
||||
volume; fluid; US; 5204941203 / 1250000000000; 0.0041639529624; cubic-meter; 11 / 10; 1.1; gallon
|
||||
volume; fluid; US; 473176473 / 125000000000; 0.003785411784; cubic-meter; 1; 1.0; gallon
|
||||
volume; fluid; US; 4258588257 / 1250000000000; 0.0034068706056; cubic-meter; 18 / 5; 3.6; quart
|
||||
volume; fluid; US; 473176473 / 500000000000; 9.46352946E-4; cubic-meter; 1; 1.0; quart
|
||||
volume; fluid; US; 4258588257 / 5000000000000; 8.517176514E-4; cubic-meter; 9 / 5; 1.8; pint
|
||||
volume; fluid; US; 473176473 / 1000000000000; 4.73176473E-4; cubic-meter; 1; 1.0; pint
|
||||
volume; fluid; US; 4258588257 / 10000000000000; 4.258588257E-4; cubic-meter; 9 / 5; 1.8; cup
|
||||
volume; fluid; US; 473176473 / 2000000000000; 2.365882365E-4; cubic-meter; 1; 1.0; cup
|
||||
volume; fluid; US; 4258588257 / 20000000000000; 2.1292941285E-4; cubic-meter; 36 / 5; 7.2; fluid-ounce
|
||||
volume; fluid; US; 473176473 / 16000000000000; 2.95735295625E-5; cubic-meter; 1; 1.0; fluid-ounce
|
||||
volume; fluid; US; 4258588257 / 160000000000000; 2.661617660625E-5; cubic-meter; 9 / 5; 1.8; tablespoon
|
||||
volume; fluid; US; 473176473 / 32000000000000; 1.478676478125E-5; cubic-meter; 1; 1.0; tablespoon
|
||||
volume; fluid; US; 4258588257 / 320000000000000; 1.3308088303125E-5; cubic-meter; 27 / 10; 2.7; teaspoon
|
||||
volume; fluid; US; 157725491 / 32000000000000; 4.92892159375E-6; cubic-meter; 1; 1.0; teaspoon
|
||||
volume; fluid; US; 1419529419 / 320000000000000; 4.436029434375E-6; cubic-meter; 9 / 10; 0.9; teaspoon
|
||||
|
||||
volume; fluid; GB; 5000699 / 1000000000; 0.005000699; cubic-meter; 11 / 10; 1.1; gallon-imperial
|
||||
volume; fluid; GB; 454609 / 100000000; 0.00454609; cubic-meter; 1; 1.0; gallon-imperial
|
||||
volume; fluid; GB; 4091481 / 1000000000; 0.004091481; cubic-meter; 144; 144.0; fluid-ounce-imperial
|
||||
volume; fluid; GB; 454609 / 16000000000; 2.84130625E-5; cubic-meter; 1; 1.0; fluid-ounce-imperial
|
||||
volume; fluid; GB; 4091481 / 160000000000; 2.557175625E-5; cubic-meter; 9 / 10; 0.9; fluid-ounce-imperial
|
||||
|
||||
volume; oil; 001; 109303765263 / 625000000000; 0.1748860244208; cubic-meter; 11 / 10; 1.1; barrel
|
||||
volume; oil; 001; 9936705933 / 62500000000; 0.158987294928; cubic-meter; 1; 1.0; barrel
|
||||
volume; oil; 001; 89430353397 / 625000000000; 0.1430885654352; cubic-meter; 9 / 10; 0.9; barrel
|
||||
|
||||
volume; vehicle; US; 5204941203 / 1250000000000; 0.0041639529624; cubic-meter; 11 / 10; 1.1; gallon
|
||||
volume; vehicle; US; 473176473 / 125000000000; 0.003785411784; cubic-meter; 1; 1.0; gallon
|
||||
volume; vehicle; US; 4258588257 / 1250000000000; 0.0034068706056; cubic-meter; 9 / 10; 0.9; gallon
|
||||
|
||||
volume; vehicle; 001; 11 / 10000; 0.0011; cubic-meter; 11 / 10; 1.1; liter
|
||||
volume; vehicle; 001; 1 / 1000; 0.001; cubic-meter; 1; 1.0; liter
|
||||
volume; vehicle; 001; 9 / 10000; 9.0E-4; cubic-meter; 9 / 10; 0.9; liter
|
||||
|
||||
year-duration; default; 001; 11 / 10; 1.1; year; 11 / 10; 1.1; year
|
||||
year-duration; default; 001; 1; 1.0; year; 1; 1.0; year
|
||||
year-duration; default; 001; 9 / 10; 0.9; year; 54 / 5; 10.8; month
|
||||
year-duration; default; 001; 1 / 12; 0.08333333333333333; year; 1; 1.0; month
|
||||
year-duration; default; 001; 3 / 40; 0.075; year; 9 / 10; 0.9; month
|
||||
|
||||
year-duration; person-age; 001; 13 / 5; 2.6; year; 13 / 5; 2.6; year-person
|
||||
year-duration; person-age; 001; 5 / 2; 2.5; year; 5 / 2; 2.5; year-person
|
||||
year-duration; person-age; 001; 12 / 5; 2.4; year; 2; year-person; 24 / 5; 4.8; month-person
|
||||
year-duration; person-age; 001; 1; 1.0; year; 1; year-person; 0; 0.0; month-person
|
||||
year-duration; person-age; 001; 9 / 10; 0.9; year; 54 / 5; 10.8; month-person
|
||||
year-duration; person-age; 001; 1 / 12; 0.08333333333333333; year; 1; 1.0; month-person
|
||||
year-duration; person-age; 001; 3 / 40; 0.075; year; 9 / 10; 0.9; month-person
|
197
icu4c/source/test/testdata/units/unitsTest.txt
vendored
Normal file
197
icu4c/source/test/testdata/units/unitsTest.txt
vendored
Normal file
|
@ -0,0 +1,197 @@
|
|||
# This file is a copy of common/testData/units/unitsTest.txt from CLDR.
|
||||
# WIP/TODO(hugovdm): determine a good update procedure and document it.
|
||||
#
|
||||
# Test data for unit conversions
|
||||
# Copyright © 1991-2020 Unicode, Inc.
|
||||
# For terms of use, see http://www.unicode.org/copyright.html
|
||||
# Unicode and the Unicode Logo are registered trademarks of Unicode, Inc. in the U.S. and other countries.
|
||||
# CLDR data files are interpreted according to the LDML specification (http://unicode.org/reports/tr35/)
|
||||
#
|
||||
# Format:
|
||||
# Quantity ; x ; y ; conversion to y (rational) ; test: 1000 x ⟹ y
|
||||
#
|
||||
# Use: convert 1000 x units to the y unit; the result should match the final column,
|
||||
# at the given precision. For example, when the last column is 159.1549,
|
||||
# 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, and look at TestParseUnit results.
|
||||
|
||||
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
|
||||
angle ; arc-second ; revolution ; 0.0000625/81 * x ; 7.716049E-4
|
||||
angle ; arc-minute ; revolution ; 0.00125/27 * x ; 0.0462963
|
||||
angle ; degree ; revolution ; 0.025/9 * x ; 2.777778
|
||||
angle ; radian ; revolution ; 65,501,488/411,557,987 * x ; 159.1549
|
||||
angle ; revolution ; revolution ; 1 * x ; 1,000.00
|
||||
area ; square-centimeter ; square-meter ; 0.0001 * x ; 0.1
|
||||
area ; square-inch ; square-meter ; 0.00064516 * x ; 0.64516
|
||||
area ; square-foot ; square-meter ; 0.09290304 * x ; 92.90304
|
||||
area ; square-yard ; square-meter ; 0.83612736 * x ; 836.1274
|
||||
area ; square-meter ; square-meter ; 1 * x ; 1,000.00
|
||||
area ; dunam ; square-meter ; 1,000 * x ; 1000000.0
|
||||
area ; acre ; square-meter ; 4,046.8564224 * x ; 4046856.0
|
||||
area ; hectare ; square-meter ; 10,000 * x ; 1.0E7
|
||||
area ; square-kilometer ; square-meter ; 1,000,000 * x ; 1.0E9
|
||||
area ; square-mile ; square-meter ; 2,589,988.110336 * x ; 2.589988E9
|
||||
concentration ; millimole-per-liter ; item-per-cubic-meter ; 602,214,076,000,000,000,000,000 * x ; 6.022141E26
|
||||
consumption ; liter-per-100-kilometer ; cubic-meter-per-meter ; 0.00000001 * x ; 1.0E-5
|
||||
consumption ; liter-per-kilometer ; cubic-meter-per-meter ; 0.000001 * x ; 0.001
|
||||
consumption-inverse ; mile-per-gallon-imperial ; meter-per-cubic-meter ; 160,934,400,000/454,609 * x ; 3.540062E8
|
||||
consumption-inverse ; mile-per-gallon ; meter-per-cubic-meter ; 48,000,000,000/112,903 * x ; 4.251437E8
|
||||
digital ; bit ; bit ; 1 * x ; 1,000.00
|
||||
digital ; byte ; bit ; 8 * x ; 8000.0
|
||||
digital ; kilobit ; bit ; 1,000 * x ; 1000000.0
|
||||
digital ; kilobyte ; bit ; 8,000 * x ; 8000000.0
|
||||
digital ; megabit ; bit ; 1,000,000 * x ; 1.0E9
|
||||
digital ; megabyte ; bit ; 8,000,000 * x ; 8.0E9
|
||||
digital ; gigabit ; bit ; 1,000,000,000 * x ; 1.0E12
|
||||
digital ; gigabyte ; bit ; 8,000,000,000 * x ; 8.0E12
|
||||
digital ; terabit ; bit ; 1,000,000,000,000 * x ; 1.0E15
|
||||
digital ; terabyte ; bit ; 8,000,000,000,000 * x ; 8.0E15
|
||||
digital ; petabyte ; bit ; 8,000,000,000,000,000 * x ; 8.0E18
|
||||
duration ; nanosecond ; second ; 0.000000001 * x ; 1.0E-6
|
||||
duration ; microsecond ; second ; 0.000001 * x ; 0.001
|
||||
duration ; millisecond ; second ; 0.001 * x ; 1.0
|
||||
duration ; second ; second ; 1 * x ; 1,000.00
|
||||
duration ; minute ; second ; 60 * x ; 60000.0
|
||||
duration ; hour ; second ; 3,600 * x ; 3600000.0
|
||||
duration ; day ; second ; 86,400 * x ; 8.64E7
|
||||
duration ; day-person ; second ; 86,400 * x ; 8.64E7
|
||||
duration ; week ; second ; 604,800 * x ; 6.048E8
|
||||
duration ; week-person ; second ; 604,800 * x ; 6.048E8
|
||||
electric-current ; milliampere ; ampere ; 0.001 * x ; 1.0
|
||||
electric-current ; ampere ; ampere ; 1 * x ; 1,000.00
|
||||
electric-resistance ; ohm ; kilogram-square-meter-per-cubic-second-square-ampere ; 1 * x ; 1000.0
|
||||
energy ; electronvolt ; kilogram-square-meter-per-square-second ; 0.0000000000000000001602177 * x ; 1.602177E-16
|
||||
energy ; dalton ; kilogram-square-meter-per-square-second ; 0.00000000014924180856 * x ; 1.492418E-7
|
||||
energy ; joule ; kilogram-square-meter-per-square-second ; 1 * x ; 1000.0
|
||||
energy ; newton-meter ; kilogram-square-meter-per-square-second ; 1 * x ; 1000.0
|
||||
energy ; pound-force-foot ; kilogram-square-meter-per-square-second ; 1.3558179483314004 * x ; 1355.818
|
||||
energy ; calorie ; kilogram-square-meter-per-square-second ; 4.184 * x ; 4184.0
|
||||
energy ; kilojoule ; kilogram-square-meter-per-square-second ; 1,000 * x ; 1000000.0
|
||||
energy ; british-thermal-unit ; kilogram-square-meter-per-square-second ; 9,489.1523804/9 * x ; 1054350.0
|
||||
energy ; foodcalorie ; kilogram-square-meter-per-square-second ; 4,184 * x ; 4184000.0
|
||||
energy ; kilocalorie ; kilogram-square-meter-per-square-second ; 4,184 * x ; 4184000.0
|
||||
energy ; kilowatt-hour ; kilogram-square-meter-second-per-cubic-second ; 3,600,000 * x ; 3.6E9
|
||||
energy ; therm-us ; kilogram-square-meter-per-square-second ; 105,480,400 * x ; 1.054804E11
|
||||
force ; newton ; kilogram-meter-per-square-second ; 1 * x ; 1000.0
|
||||
force ; pound-force ; kilogram-meter-per-square-second ; 4.4482216152605 * x ; 4448.222
|
||||
frequency ; hertz ; revolution-per-second ; 1 * x ; 1000.0
|
||||
frequency ; kilohertz ; revolution-per-second ; 1,000 * x ; 1000000.0
|
||||
frequency ; megahertz ; revolution-per-second ; 1,000,000 * x ; 1.0E9
|
||||
frequency ; gigahertz ; revolution-per-second ; 1,000,000,000 * x ; 1.0E12
|
||||
graphics ; dot ; pixel ; 1 * x ; 1000.0
|
||||
graphics ; pixel ; pixel ; 1 * x ; 1,000.00
|
||||
graphics ; megapixel ; pixel ; 1,000,000 * x ; 1.0E9
|
||||
length ; picometer ; meter ; 0.000000000001 * x ; 1.0E-9
|
||||
length ; nanometer ; meter ; 0.000000001 * x ; 1.0E-6
|
||||
length ; micrometer ; meter ; 0.000001 * x ; 0.001
|
||||
length ; point ; meter ; 0.003175/9 * x ; 0.3527778
|
||||
length ; millimeter ; meter ; 0.001 * x ; 1.0
|
||||
length ; centimeter ; meter ; 0.01 * x ; 10.0
|
||||
length ; inch ; meter ; 0.0254 * x ; 25.4
|
||||
length ; decimeter ; meter ; 0.1 * x ; 100.0
|
||||
length ; foot ; meter ; 0.3048 * x ; 304.8
|
||||
length ; yard ; meter ; 0.9144 * x ; 914.4
|
||||
length ; meter ; meter ; 1 * x ; 1,000.00
|
||||
length ; fathom ; meter ; 1.8288 * x ; 1828.8
|
||||
length ; furlong ; meter ; 201.168 * x ; 201168.0
|
||||
length ; kilometer ; meter ; 1,000 * x ; 1000000.0
|
||||
length ; mile ; meter ; 1,609.344 * x ; 1609344.0
|
||||
length ; nautical-mile ; meter ; 1,852 * x ; 1852000.0
|
||||
length ; mile-scandinavian ; meter ; 10,000 * x ; 1.0E7
|
||||
length ; 100-kilometer ; meter ; 100,000 * x ; 1.0E8
|
||||
length ; earth-radius ; meter ; 6,378,100 * x ; 6.3781E9
|
||||
length ; solar-radius ; meter ; 695,700,000 * x ; 6.957E11
|
||||
length ; astronomical-unit ; meter ; 149,597,900,000 * x ; 1.495979E14
|
||||
length ; light-year ; meter ; 9,460,730,000,000,000 * x ; 9.46073E18
|
||||
length ; parsec ; meter ; 30,856,780,000,000,000 * x ; 3.085678E19
|
||||
luminous-flux ; lux ; candela-square-meter-per-square-meter ; 1 * x ; 1000.0
|
||||
luminous-intensity ; candela ; candela ; 1 * x ; 1,000.00
|
||||
mass ; microgram ; kilogram ; 0.000000001 * x ; 1.0E-6
|
||||
mass ; milligram ; kilogram ; 0.000001 * x ; 0.001
|
||||
mass ; carat ; kilogram ; 0.0002 * x ; 0.2
|
||||
mass ; gram ; kilogram ; 0.001 * x ; 1.0
|
||||
mass ; ounce ; kilogram ; 0.028349523125 * x ; 28.34952
|
||||
mass ; ounce-troy ; kilogram ; 0.03110348 * x ; 31.10348
|
||||
mass ; pound ; kilogram ; 0.45359237 * x ; 453.5924
|
||||
mass ; kilogram ; kilogram ; 1 * x ; 1,000.00
|
||||
mass ; stone ; kilogram ; 6.35029318 * x ; 6350.293
|
||||
mass ; ton ; kilogram ; 907.18474 * x ; 907184.7
|
||||
mass ; metric-ton ; kilogram ; 1,000 * x ; 1000000.0
|
||||
mass ; earth-mass ; kilogram ; 5,972,200,000,000,000,000,000,000 * x ; 5.9722E27
|
||||
mass ; solar-mass ; kilogram ; 1,988,470,000,000,000,000,000,000,000,000 * x ; 1.98847E33
|
||||
mass-density ; milligram-per-deciliter ; kilogram-per-cubic-meter ; 0.01 * x ; 10.0
|
||||
portion ; permillion ; portion ; 0.000001 * x ; 0.001
|
||||
portion ; permyriad ; portion ; 0.0001 * x ; 0.1
|
||||
portion ; permille ; portion ; 0.001 * x ; 1.0
|
||||
portion ; percent ; portion ; 0.01 * x ; 10.0
|
||||
portion ; karat ; portion ; 0.125/3 * x ; 41.66667
|
||||
portion ; portion ; portion ; 1 * x ; 1,000.00
|
||||
power ; milliwatt ; kilogram-square-meter-per-cubic-second ; 0.001 * x ; 1.0
|
||||
power ; watt ; kilogram-square-meter-per-cubic-second ; 1 * x ; 1000.0
|
||||
power ; horsepower ; kilogram-square-meter-per-cubic-second ; 745.69987158227022 * x ; 745699.9
|
||||
power ; kilowatt ; kilogram-square-meter-per-cubic-second ; 1,000 * x ; 1000000.0
|
||||
power ; megawatt ; kilogram-square-meter-per-cubic-second ; 1,000,000 * x ; 1.0E9
|
||||
power ; gigawatt ; kilogram-square-meter-per-cubic-second ; 1,000,000,000 * x ; 1.0E12
|
||||
power ; solar-luminosity ; kilogram-square-meter-per-cubic-second ; 382,800,000,000,000,000,000,000,000 * x ; 3.828E29
|
||||
pressure ; pascal ; kilogram-per-meter-square-second ; 1 * x ; 1000.0
|
||||
pressure ; hectopascal ; kilogram-per-meter-square-second ; 100 * x ; 100000.0
|
||||
pressure ; millibar ; kilogram-per-meter-square-second ; 100 * x ; 100000.0
|
||||
pressure ; millimeter-ofhg ; kilogram-meter-per-square-meter-square-second ; 133.322387415 * x ; 133322.4
|
||||
pressure ; kilopascal ; kilogram-per-meter-square-second ; 1,000 * x ; 1000000.0
|
||||
pressure ; inch-ofhg ; kilogram-meter-per-square-meter-square-second ; 3,386.388640341 * x ; 3386389.0
|
||||
#WIP(MeasureUnit parsing bug)#pressure ; pound-force-per-square-inch ; kilogram-meter-per-square-meter-square-second ; 111,205,540.3815125/16,129 * x ; 6894757.0
|
||||
pressure ; bar ; kilogram-per-meter-square-second ; 100,000 * x ; 1.0E8
|
||||
pressure ; atmosphere ; kilogram-per-meter-square-second ; 101,325 * x ; 1.01325E8
|
||||
pressure ; megapascal ; kilogram-per-meter-square-second ; 1,000,000 * x ; 1.0E9
|
||||
pressure-per-length ; ofhg ; kilogram-per-square-meter-square-second ; 133,322.387415 * x ; 1.333224E8
|
||||
resolution ; dot-per-inch ; pixel-per-meter ; 5,000/127 * x ; 39370.08
|
||||
resolution ; pixel-per-inch ; pixel-per-meter ; 5,000/127 * x ; 39370.08
|
||||
resolution ; dot-per-centimeter ; pixel-per-meter ; 100 * x ; 100000.0
|
||||
resolution ; pixel-per-centimeter ; pixel-per-meter ; 100 * x ; 100000.0
|
||||
speed ; kilometer-per-hour ; meter-per-second ; 2.5/9 * x ; 277.7778
|
||||
speed ; mile-per-hour ; meter-per-second ; 0.44704 * x ; 447.04
|
||||
speed ; knot ; meter-per-second ; 4.63/9 * x ; 514.4444
|
||||
speed ; meter-per-second ; meter-per-second ; 1 * x ; 1,000.00
|
||||
substance-amount ; item ; item ; 1 * x ; 1,000.00
|
||||
substance-amount ; mole ; item ; 602,214,076,000,000,000,000,000 * x ; 6.022141E26
|
||||
temperature ; fahrenheit ; kelvin ; 5/9 * x - 2,298.35/9 ; 810.9278
|
||||
temperature ; kelvin ; kelvin ; 1 * x ; 1,000.00
|
||||
temperature ; celsius ; kelvin ; 1 * x - 273.15 ; 1273.15
|
||||
typewidth ; em ; em ; 1 * x ; 1,000.00
|
||||
voltage ; volt ; kilogram-square-meter-per-cubic-second-ampere ; 1 * x ; 1000.0
|
||||
volume ; cubic-centimeter ; cubic-meter ; 0.000001 * x ; 0.001
|
||||
volume ; milliliter ; cubic-meter ; 0.000001 * x ; 0.001
|
||||
volume ; teaspoon ; cubic-meter ; 0.00000492892159375 * x ; 0.004928922
|
||||
volume ; centiliter ; cubic-meter ; 0.00001 * x ; 0.01
|
||||
volume ; tablespoon ; cubic-meter ; 0.00001478676478125 * x ; 0.01478676
|
||||
volume ; cubic-inch ; cubic-meter ; 0.000016387064 * x ; 0.01638706
|
||||
volume ; fluid-ounce-imperial ; cubic-meter ; 0.0000284130625 * x ; 0.02841306
|
||||
volume ; fluid-ounce ; cubic-meter ; 0.0000295735295625 * x ; 0.02957353
|
||||
volume ; deciliter ; cubic-meter ; 0.0001 * x ; 0.1
|
||||
volume ; cup ; cubic-meter ; 0.0002365882365 * x ; 0.2365882
|
||||
volume ; cup-metric ; cubic-meter ; 0.00025 * x ; 0.25
|
||||
volume ; pint ; cubic-meter ; 0.000473176473 * x ; 0.4731765
|
||||
volume ; pint-metric ; cubic-meter ; 0.0005 * x ; 0.5
|
||||
volume ; quart ; cubic-meter ; 0.000946352946 * x ; 0.9463529
|
||||
volume ; liter ; cubic-meter ; 0.001 * x ; 1.0
|
||||
volume ; gallon ; cubic-meter ; 0.003785411784 * x ; 3.785412
|
||||
volume ; gallon-imperial ; cubic-meter ; 0.00454609 * x ; 4.54609
|
||||
volume ; cubic-foot ; cubic-meter ; 0.028316846592 * x ; 28.31685
|
||||
volume ; bushel ; cubic-meter ; 0.03523907016688 * x ; 35.23907
|
||||
volume ; hectoliter ; cubic-meter ; 0.1 * x ; 100.0
|
||||
volume ; barrel ; cubic-meter ; 0.158987294928 * x ; 158.9873
|
||||
volume ; cubic-yard ; cubic-meter ; 0.764554857984 * x ; 764.5549
|
||||
volume ; cubic-meter ; cubic-meter ; 1 * x ; 1,000.00
|
||||
volume ; megaliter ; cubic-meter ; 1,000 * x ; 1000000.0
|
||||
volume ; acre-foot ; cubic-meter ; 1,233.48183754752 * x ; 1233482.0
|
||||
volume ; cubic-kilometer ; cubic-meter ; 1,000,000,000 * x ; 1.0E12
|
||||
volume ; cubic-mile ; cubic-meter ; 4,168,181,825.440579584 * x ; 4.168182E12
|
||||
year-duration ; month ; year ; 0.25/3 * x ; 83.33333
|
||||
year-duration ; month-person ; year ; 0.25/3 * x ; 83.33333
|
||||
year-duration ; year ; year ; 1 * x ; 1,000.00
|
||||
year-duration ; year-person ; year ; 1 * x ; 1000.0
|
||||
year-duration ; decade ; year ; 10 * x ; 10000.0
|
||||
year-duration ; century ; year ; 100 * x ; 100000.0
|
Loading…
Add table
Reference in a new issue