Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Unified Diff: source/test/intltest/compactdecimalformattest.cpp

Issue 1621843002: ICU 56 update step 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@561
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « source/test/intltest/collationtest.cpp ('k') | source/test/intltest/csdetest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: source/test/intltest/compactdecimalformattest.cpp
diff --git a/source/test/intltest/compactdecimalformattest.cpp b/source/test/intltest/compactdecimalformattest.cpp
index 8d950c6a1fa9ce2a8e3a3a4f670e4346ea2c2d78..855994b01c7aa9bc34aa73eebdd4e78b8deb8e7b 100644
--- a/source/test/intltest/compactdecimalformattest.cpp
+++ b/source/test/intltest/compactdecimalformattest.cpp
@@ -1,6 +1,6 @@
/*
*******************************************************************************
-* Copyright (C) 1997-2014, International Business Machines Corporation and *
+* Copyright (C) 1997-2015, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*
@@ -100,7 +100,7 @@ static ExpectedResult kSerbianLongNegative[] = {
{-1.23456789E15, "-1200 \\u0442\\u0440\\u0438\\u043B\\u0438\\u043E\\u043D\\u0430"}};
static ExpectedResult kJapaneseShort[] = {
- {1234.0, "1.2\\u5343"},
+ {1234.0, "1200"},
{12345.0, "1.2\\u4E07"},
{123456.0, "12\\u4E07"},
{1234567.0, "120\\u4E07"},
@@ -145,8 +145,8 @@ static ExpectedResult kCsShort[] = {
static ExpectedResult kSkLong[] = {
{1000.0, "1 tis\\u00edc"},
- {1572.0, "1,6 tis\\u00edc"},
- {5184.0, "5,2 tis\\u00edc"}};
+ {1572.0, "1,6 tis\\u00edca"},
+ {5184.0, "5,2 tis\\u00edca"}};
static ExpectedResult kSwahiliShortNegative[] = {
{-1234.0, "elfu\\u00a0-1.2"},
@@ -185,6 +185,7 @@ private:
void TestArabicLong();
void TestFieldPosition();
void TestSignificantDigits();
+ void TestAPIVariants();
void CheckLocale(
const Locale& locale, UNumberCompactStyle style,
const ExpectedResult* expectedResult, int32_t expectedResultLength);
@@ -213,6 +214,7 @@ void CompactDecimalFormatTest::runIndexedTest(
TESTCASE_AUTO(TestArabicLong);
TESTCASE_AUTO(TestFieldPosition);
TESTCASE_AUTO(TestSignificantDigits);
+ TESTCASE_AUTO(TestAPIVariants);
TESTCASE_AUTO_END;
}
@@ -294,6 +296,102 @@ void CompactDecimalFormatTest::TestSignificantDigits() {
}
}
+void CompactDecimalFormatTest::TestAPIVariants() {
+ UErrorCode status = U_ZERO_ERROR;
+ LocalPointer<CompactDecimalFormat> cdf(CompactDecimalFormat::createInstance("en", UNUM_SHORT, status));
+ if (U_FAILURE(status)) {
+ dataerrln("Unable to create format object - %s", u_errorName(status));
+ return;
+ }
+ UnicodeString actual;
+ FieldPosition pos;
+ FieldPositionIterator posIter;
+ UnicodeString expected("123K", -1, US_INV);
+ pos.setField(UNUM_INTEGER_FIELD);
+
+ actual.remove();
+ pos.setBeginIndex(0);
+ pos.setEndIndex(0);
+ cdf->format((double)123456.0, actual, pos);
+ if (actual != expected || pos.getEndIndex() != 3) {
+ errln(UnicodeString("Fail format(double,UnicodeString&,FieldPosition&): Expected: \"") + expected + "\", pos 3; " +
+ "Got: \"" + actual + "\", pos " + pos.getEndIndex());
+ }
+
+ actual.remove();
+ pos.setBeginIndex(0);
+ pos.setEndIndex(0);
+ status = U_ZERO_ERROR;
+ cdf->format((double)123456.0, actual, pos, status);
+ if (actual != expected || pos.getEndIndex() != 3 || status != U_ZERO_ERROR) {
+ errln(UnicodeString("Fail format(double,UnicodeString&,FieldPosition&,UErrorCode&): Expected: \"") + expected + "\", pos 3, status U_ZERO_ERROR; " +
+ "Got: \"" + actual + "\", pos " + pos.getEndIndex() + ", status " + u_errorName(status));
+ }
+
+ actual.remove();
+ status = U_ZERO_ERROR;
+ cdf->format((double)123456.0, actual, &posIter, status);
+ if (status != U_UNSUPPORTED_ERROR) {
+ errln(UnicodeString("Fail format(double,UnicodeString&,FieldPositionIterator*,UErrorCode&): Expected status U_UNSUPPORTED_ERROR;") +
+ "Got status " + u_errorName(status));
+ }
+
+ actual.remove();
+ pos.setBeginIndex(0);
+ pos.setEndIndex(0);
+ cdf->format((int32_t)123456, actual, pos);
+ if (actual != expected || pos.getEndIndex() != 3) {
+ errln(UnicodeString("Fail format(int32_t,UnicodeString&,FieldPosition&): Expected: \"") + expected + "\", pos 3; " +
+ "Got: \"" + actual + "\", pos " + pos.getEndIndex());
+ }
+
+ actual.remove();
+ pos.setBeginIndex(0);
+ pos.setEndIndex(0);
+ status = U_ZERO_ERROR;
+ cdf->format((int32_t)123456, actual, pos, status);
+ if (actual != expected || pos.getEndIndex() != 3 || status != U_ZERO_ERROR) {
+ errln(UnicodeString("Fail format(int32_t,UnicodeString&,FieldPosition&,UErrorCode&): Expected: \"") + expected + "\", pos 3, status U_ZERO_ERROR; " +
+ "Got: \"" + actual + "\", pos " + pos.getEndIndex() + ", status " + u_errorName(status));
+ }
+
+ actual.remove();
+ status = U_ZERO_ERROR;
+ cdf->format((int32_t)123456, actual, &posIter, status);
+ if (status != U_UNSUPPORTED_ERROR) {
+ errln(UnicodeString("Fail format(int32_t,UnicodeString&,FieldPositionIterator*,UErrorCode&): Expected status U_UNSUPPORTED_ERROR;") +
+ "Got status " + u_errorName(status));
+ }
+
+ actual.remove();
+ pos.setBeginIndex(0);
+ pos.setEndIndex(0);
+ cdf->format((int64_t)123456, actual, pos);
+ if (actual != expected || pos.getEndIndex() != 3) {
+ errln(UnicodeString("Fail format(int64_t,UnicodeString&,FieldPosition&): Expected: \"") + expected + "\", pos 3; " +
+ "Got: \"" + actual + "\", pos " + pos.getEndIndex());
+ }
+
+ actual.remove();
+ pos.setBeginIndex(0);
+ pos.setEndIndex(0);
+ status = U_ZERO_ERROR;
+ cdf->format((int64_t)123456, actual, pos, status);
+ if (actual != expected || pos.getEndIndex() != 3 || status != U_ZERO_ERROR) {
+ errln(UnicodeString("Fail format(int64_t,UnicodeString&,FieldPosition&,UErrorCode&): Expected: \"") + expected + "\", pos 3, status U_ZERO_ERROR; " +
+ "Got: \"" + actual + "\", pos " + pos.getEndIndex() + ", status " + u_errorName(status));
+ }
+
+ actual.remove();
+ status = U_ZERO_ERROR;
+ cdf->format((int64_t)123456, actual, &posIter, status);
+ if (status != U_UNSUPPORTED_ERROR) {
+ errln(UnicodeString("Fail format(int64_t,UnicodeString&,FieldPositionIterator*,UErrorCode&): Expected status U_UNSUPPORTED_ERROR;") +
+ "Got status " + u_errorName(status));
+ }
+
+}
+
void CompactDecimalFormatTest::CheckLocale(const Locale& locale, UNumberCompactStyle style, const ExpectedResult* expectedResults, int32_t expectedResultLength) {
UErrorCode status = U_ZERO_ERROR;
LocalPointer<CompactDecimalFormat> cdf(createCDFInstance(locale, style, status));
« no previous file with comments | « source/test/intltest/collationtest.cpp ('k') | source/test/intltest/csdetest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698