X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/51004dcb01e06fef634b61be77ed73dd61cb6db9..b331163bffd790ced0e88b73f44f86d49ccc48a5:/icuSources/test/intltest/compactdecimalformattest.cpp?ds=sidebyside diff --git a/icuSources/test/intltest/compactdecimalformattest.cpp b/icuSources/test/intltest/compactdecimalformattest.cpp index 52f6c539..8d950c6a 100644 --- a/icuSources/test/intltest/compactdecimalformattest.cpp +++ b/icuSources/test/intltest/compactdecimalformattest.cpp @@ -1,6 +1,6 @@ /* ******************************************************************************* -* Copyright (C) 1997-2013, International Business Machines Corporation and * +* Copyright (C) 1997-2014, International Business Machines Corporation and * * others. All Rights Reserved. * ******************************************************************************* * @@ -17,8 +17,7 @@ #include "unicode/compactdecimalformat.h" #include "unicode/unum.h" - -#define LENGTHOF(array) (int32_t)(sizeof(array) / sizeof((array)[0])) +#include "cmemory.h" typedef struct ExpectedResult { double value; @@ -29,7 +28,7 @@ static const char *kShortStr = "Short"; static const char *kLongStr = "Long"; static ExpectedResult kEnglishShort[] = { - {0.0, "0.0"}, + {0.0, "0"}, {0.17, "0.17"}, {1.0, "1"}, {1234.0, "1.2K"}, @@ -47,42 +46,42 @@ static ExpectedResult kEnglishShort[] = { {1.23456789E15, "1200T"}}; static ExpectedResult kSerbianShort[] = { - {1234.0, "1200"}, - {12345.0, "12K"}, - {20789.0, "21\\u00a0\\u0445\\u0438\\u0459"}, - {123456.0, "120\\u00a0\\u0445\\u0438\\u0459"}, - {1234567.0, "1,2\\u00A0\\u043C\\u0438\\u043B"}, - {12345678.0, "12\\u00A0\\u043C\\u0438\\u043B"}, - {123456789.0, "120\\u00A0\\u043C\\u0438\\u043B"}, - {1.23456789E9, "1,2\\u00A0\\u043C\\u043B\\u0440\\u0434"}, - {1.23456789E10, "12\\u00A0\\u043C\\u043B\\u0440\\u0434"}, - {1.23456789E11, "120\\u00A0\\u043C\\u043B\\u0440\\u0434"}, - {1.23456789E12, "1,2\\u00A0\\u0431\\u0438\\u043B"}, - {1.23456789E13, "12\\u00A0\\u0431\\u0438\\u043B"}, - {1.23456789E14, "120\\u00A0\\u0431\\u0438\\u043B"}, - {1.23456789E15, "1200\\u00A0\\u0431\\u0438\\u043B"}}; + {1234.0, "1,2\\u00a0\\u0445\\u0438\\u0459."}, + {12345.0, "12\\u00a0\\u0445\\u0438\\u0459."}, + {20789.0, "21\\u00a0\\u0445\\u0438\\u0459."}, + {123456.0, "120\\u00a0\\u0445\\u0438\\u0459."}, + {1234567.0, "1,2\\u00A0\\u043C\\u0438\\u043B."}, + {12345678.0, "12\\u00A0\\u043C\\u0438\\u043B."}, + {123456789.0, "120\\u00A0\\u043C\\u0438\\u043B."}, + {1.23456789E9, "1,2\\u00A0\\u043C\\u043B\\u0440\\u0434."}, + {1.23456789E10, "12\\u00A0\\u043C\\u043B\\u0440\\u0434."}, + {1.23456789E11, "120\\u00A0\\u043C\\u043B\\u0440\\u0434."}, + {1.23456789E12, "1,2\\u00A0\\u0431\\u0438\\u043B."}, + {1.23456789E13, "12\\u00A0\\u0431\\u0438\\u043B."}, + {1.23456789E14, "120\\u00A0\\u0431\\u0438\\u043B."}, + {1.23456789E15, "1200\\u00A0\\u0431\\u0438\\u043B."}}; static ExpectedResult kSerbianLong[] = { - {1234.0, "1,2 \\u0445\\u0438\\u0459\\u0430\\u0434\\u0430"}, - {12345.0, "12 \\u0445\\u0438\\u0459\\u0430\\u0434\\u0430"}, - {21789.0, "22 \\u0445\\u0438\\u0459\\u0430\\u0434\\u0435"}, - {123456.0, "120 \\u0445\\u0438\\u0459\\u0430\\u0434\\u0430"}, - {999999.0, "1 \\u043C\\u0438\\u043B\\u0438\\u043E\\u043D"}, - {1234567.0, "1,2 \\u043C\\u0438\\u043B\\u0438\\u043E\\u043D\\u0430"}, - {12345678.0, "12 \\u043C\\u0438\\u043B\\u0438\\u043E\\u043D\\u0430"}, - {123456789.0, "120 \\u043C\\u0438\\u043B\\u0438\\u043E\\u043D\\u0430"}, - {1.23456789E9, "1,2 \\u043C\\u0438\\u043B\\u0438\\u0458\\u0430\\u0440\\u0434\\u0438"}, - {1.23456789E10, "12 \\u043C\\u0438\\u043B\\u0438\\u0458\\u0430\\u0440\\u0434\\u0438"}, - {2.08901234E10, "21 \\u043C\\u0438\\u043B\\u0438\\u0458\\u0430\\u0440\\u0434\\u0430"}, - {2.18901234E10, "22 \\u043C\\u0438\\u043B\\u0438\\u0458\\u0430\\u0440\\u0434\\u0435"}, - {1.23456789E11, "120 \\u043C\\u0438\\u043B\\u0438\\u0458\\u0430\\u0440\\u0434\\u0438"}, - {1.23456789E12, "1,2 \\u0442\\u0440\\u0438\\u043B\\u0438\\u043E\\u043D\\u0430"}, - {1.23456789E13, "12 \\u0442\\u0440\\u0438\\u043B\\u0438\\u043E\\u043D\\u0430"}, - {1.23456789E14, "120 \\u0442\\u0440\\u0438\\u043B\\u0438\\u043E\\u043D\\u0430"}, - {1.23456789E15, "1200 \\u0442\\u0440\\u0438\\u043B\\u0438\\u043E\\u043D\\u0430"}}; + {1234.0, "1,2 \\u0445\\u0438\\u0459\\u0430\\u0434\\u0435"}, // 10^3 few + {12345.0, "12 \\u0445\\u0438\\u0459\\u0430\\u0434\\u0430"}, // 10^3 other + {21789.0, "22 \\u0445\\u0438\\u0459\\u0430\\u0434\\u0435"}, // 10^3 few + {123456.0, "120 \\u0445\\u0438\\u0459\\u0430\\u0434\\u0430"}, // 10^3 other + {999999.0, "1 \\u043C\\u0438\\u043B\\u0438\\u043E\\u043D"}, // 10^6 one + {1234567.0, "1,2 \\u043C\\u0438\\u043B\\u0438\\u043E\\u043D\\u0430"}, // 10^6 few + {12345678.0, "12 \\u043C\\u0438\\u043B\\u0438\\u043E\\u043D\\u0430"}, // 10^6 other + {123456789.0, "120 \\u043C\\u0438\\u043B\\u0438\\u043E\\u043D\\u0430"}, // 10^6 other + {1.23456789E9, "1,2 \\u043C\\u0438\\u043B\\u0438\\u0458\\u0430\\u0440\\u0434\\u0435"}, // 10^9 few + {1.23456789E10, "12 \\u043C\\u0438\\u043B\\u0438\\u0458\\u0430\\u0440\\u0434\\u0438"}, // 10^9 other + {2.08901234E10, "21 \\u043C\\u0438\\u043B\\u0438\\u0458\\u0430\\u0440\\u0434\\u0430"}, // 10^9 one + {2.18901234E10, "22 \\u043C\\u0438\\u043B\\u0438\\u0458\\u0430\\u0440\\u0434\\u0435"}, // 10^9 few + {1.23456789E11, "120 \\u043C\\u0438\\u043B\\u0438\\u0458\\u0430\\u0440\\u0434\\u0438"}, // 10^9 other + {1.23456789E12, "1,2 \\u0442\\u0440\\u0438\\u043B\\u0438\\u043E\\u043D\\u0430"}, // 10^12 few + {1.23456789E13, "12 \\u0442\\u0440\\u0438\\u043B\\u0438\\u043E\\u043D\\u0430"}, // 10^12 other + {1.23456789E14, "120 \\u0442\\u0440\\u0438\\u043B\\u0438\\u043E\\u043D\\u0430"}, // 10^12 other + {1.23456789E15, "1200 \\u0442\\u0440\\u0438\\u043B\\u0438\\u043E\\u043D\\u0430"}}; // 10^12 other static ExpectedResult kSerbianLongNegative[] = { - {-1234.0, "-1,2 \\u0445\\u0438\\u0459\\u0430\\u0434\\u0430"}, + {-1234.0, "-1,2 \\u0445\\u0438\\u0459\\u0430\\u0434\\u0435"}, {-12345.0, "-12 \\u0445\\u0438\\u0459\\u0430\\u0434\\u0430"}, {-21789.0, "-22 \\u0445\\u0438\\u0459\\u0430\\u0434\\u0435"}, {-123456.0, "-120 \\u0445\\u0438\\u0459\\u0430\\u0434\\u0430"}, @@ -90,7 +89,7 @@ static ExpectedResult kSerbianLongNegative[] = { {-1234567.0, "-1,2 \\u043C\\u0438\\u043B\\u0438\\u043E\\u043D\\u0430"}, {-12345678.0, "-12 \\u043C\\u0438\\u043B\\u0438\\u043E\\u043D\\u0430"}, {-123456789.0, "-120 \\u043C\\u0438\\u043B\\u0438\\u043E\\u043D\\u0430"}, - {-1.23456789E9, "-1,2 \\u043C\\u0438\\u043B\\u0438\\u0458\\u0430\\u0440\\u0434\\u0438"}, + {-1.23456789E9, "-1,2 \\u043C\\u0438\\u043B\\u0438\\u0458\\u0430\\u0440\\u0434\\u0435"}, {-1.23456789E10, "-12 \\u043C\\u0438\\u043B\\u0438\\u0458\\u0430\\u0440\\u0434\\u0438"}, {-2.08901234E10, "-21 \\u043C\\u0438\\u043B\\u0438\\u0458\\u0430\\u0440\\u0434\\u0430"}, {-2.18901234E10, "-22 \\u043C\\u0438\\u043B\\u0438\\u0458\\u0430\\u0440\\u0434\\u0435"}, @@ -117,7 +116,7 @@ static ExpectedResult kJapaneseShort[] = { static ExpectedResult kSwahiliShort[] = { {1234.0, "elfu\\u00a01.2"}, {12345.0, "elfu\\u00a012"}, - {123456.0, "laki1.2"}, + {123456.0, "elfu\\u00a0120"}, {1234567.0, "M1.2"}, {12345678.0, "M12"}, {123456789.0, "M120"}, @@ -152,7 +151,7 @@ static ExpectedResult kSkLong[] = { static ExpectedResult kSwahiliShortNegative[] = { {-1234.0, "elfu\\u00a0-1.2"}, {-12345.0, "elfu\\u00a0-12"}, - {-123456.0, "laki-1.2"}, + {-123456.0, "elfu\\u00a0-120"}, {-1234567.0, "M-1.2"}, {-12345678.0, "M-12"}, {-123456789.0, "M-120"}, @@ -218,27 +217,27 @@ void CompactDecimalFormatTest::runIndexedTest( } void CompactDecimalFormatTest::TestEnglishShort() { - CheckLocale("en", UNUM_SHORT, kEnglishShort, LENGTHOF(kEnglishShort)); + CheckLocale("en", UNUM_SHORT, kEnglishShort, UPRV_LENGTHOF(kEnglishShort)); } void CompactDecimalFormatTest::TestSerbianShort() { - CheckLocale("sr", UNUM_SHORT, kSerbianShort, LENGTHOF(kSerbianShort)); + CheckLocale("sr", UNUM_SHORT, kSerbianShort, UPRV_LENGTHOF(kSerbianShort)); } void CompactDecimalFormatTest::TestSerbianLong() { - CheckLocale("sr", UNUM_LONG, kSerbianLong, LENGTHOF(kSerbianLong)); + CheckLocale("sr", UNUM_LONG, kSerbianLong, UPRV_LENGTHOF(kSerbianLong)); } void CompactDecimalFormatTest::TestSerbianLongNegative() { - CheckLocale("sr", UNUM_LONG, kSerbianLongNegative, LENGTHOF(kSerbianLongNegative)); + CheckLocale("sr", UNUM_LONG, kSerbianLongNegative, UPRV_LENGTHOF(kSerbianLongNegative)); } void CompactDecimalFormatTest::TestJapaneseShort() { - CheckLocale(Locale::getJapan(), UNUM_SHORT, kJapaneseShort, LENGTHOF(kJapaneseShort)); + CheckLocale(Locale::getJapan(), UNUM_SHORT, kJapaneseShort, UPRV_LENGTHOF(kJapaneseShort)); } void CompactDecimalFormatTest::TestSwahiliShort() { - CheckLocale("sw", UNUM_SHORT, kSwahiliShort, LENGTHOF(kSwahiliShort)); + CheckLocale("sw", UNUM_SHORT, kSwahiliShort, UPRV_LENGTHOF(kSwahiliShort)); } void CompactDecimalFormatTest::TestFieldPosition() { @@ -259,7 +258,7 @@ void CompactDecimalFormatTest::TestFieldPosition() { } void CompactDecimalFormatTest::TestCsShort() { - CheckLocale("cs", UNUM_SHORT, kCsShort, LENGTHOF(kCsShort)); + CheckLocale("cs", UNUM_SHORT, kCsShort, UPRV_LENGTHOF(kCsShort)); } void CompactDecimalFormatTest::TestSkLong() { @@ -268,15 +267,15 @@ void CompactDecimalFormatTest::TestSkLong() { // few{"0"} // one{"0"} // other{"0"} - CheckLocale("sk", UNUM_LONG, kSkLong, LENGTHOF(kSkLong)); + CheckLocale("sk", UNUM_LONG, kSkLong, UPRV_LENGTHOF(kSkLong)); } void CompactDecimalFormatTest::TestSwahiliShortNegative() { - CheckLocale("sw", UNUM_SHORT, kSwahiliShortNegative, LENGTHOF(kSwahiliShortNegative)); + CheckLocale("sw", UNUM_SHORT, kSwahiliShortNegative, UPRV_LENGTHOF(kSwahiliShortNegative)); } void CompactDecimalFormatTest::TestArabicLong() { - CheckLocale("ar", UNUM_LONG, kArabicLong, LENGTHOF(kArabicLong)); + CheckLocale("ar", UNUM_LONG, kArabicLong, UPRV_LENGTHOF(kArabicLong)); } void CompactDecimalFormatTest::TestSignificantDigits() {