| OLD | NEW |
| 1 /* | 1 /* |
| 2 ******************************************************************************* | 2 ******************************************************************************* |
| 3 * Copyright (C) 2014, International Business Machines Corporation and * | 3 * Copyright (C) 2014-2015, International Business Machines Corporation and |
| 4 * others. All Rights Reserved. * | 4 * others. All Rights Reserved. |
| 5 ******************************************************************************* | 5 ******************************************************************************* |
| 6 * | 6 * |
| 7 * File QUANTITYFORMATTERTEST.CPP | 7 * File QUANTITYFORMATTERTEST.CPP |
| 8 * | 8 * |
| 9 ******************************************************************************** | 9 ******************************************************************************** |
| 10 */ | 10 */ |
| 11 #include "cstring.h" | 11 #include "cstring.h" |
| 12 #include "intltest.h" | 12 #include "intltest.h" |
| 13 #include "quantityformatter.h" | 13 #include "quantityformatter.h" |
| 14 #include "simplepatternformatter.h" | 14 #include "simplepatternformatter.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 30 TESTCASE_AUTO(TestBasic); | 30 TESTCASE_AUTO(TestBasic); |
| 31 TESTCASE_AUTO_END; | 31 TESTCASE_AUTO_END; |
| 32 } | 32 } |
| 33 | 33 |
| 34 void QuantityFormatterTest::TestBasic() { | 34 void QuantityFormatterTest::TestBasic() { |
| 35 UErrorCode status = U_ZERO_ERROR; | 35 UErrorCode status = U_ZERO_ERROR; |
| 36 #if !UCONFIG_NO_FORMATTING | 36 #if !UCONFIG_NO_FORMATTING |
| 37 QuantityFormatter fmt; | 37 QuantityFormatter fmt; |
| 38 assertFalse( | 38 assertFalse( |
| 39 "adding bad variant", | 39 "adding bad variant", |
| 40 fmt.add("a bad variant", "{0} pounds", status)); | 40 fmt.addIfAbsent("a bad variant", "{0} pounds", status)); |
| 41 assertEquals("adding bad variant status", U_ILLEGAL_ARGUMENT_ERROR, status); | 41 assertEquals("adding bad variant status", U_ILLEGAL_ARGUMENT_ERROR, status); |
| 42 status = U_ZERO_ERROR; | 42 status = U_ZERO_ERROR; |
| 43 assertFalse( | 43 assertFalse( |
| 44 "Adding bad pattern", | 44 "Adding bad pattern", |
| 45 fmt.add("other", "{0} {1} too many placeholders", status)); | 45 fmt.addIfAbsent("other", "{0} {1} too many placeholders", status)); |
| 46 assertEquals("adding bad pattern status", U_ILLEGAL_ARGUMENT_ERROR, status); | 46 assertEquals("adding bad pattern status", U_ILLEGAL_ARGUMENT_ERROR, status); |
| 47 status = U_ZERO_ERROR; | 47 status = U_ZERO_ERROR; |
| 48 assertFalse("isValid with no patterns", fmt.isValid()); | 48 assertFalse("isValid with no patterns", fmt.isValid()); |
| 49 assertTrue( | 49 assertTrue( |
| 50 "Adding good pattern with no placeholders", | 50 "Adding good pattern with no placeholders", |
| 51 fmt.add("other", "no placeholder", status)); | 51 fmt.addIfAbsent("zero", "no placeholder", status)); |
| 52 assertTrue( | 52 assertTrue( |
| 53 "Adding good pattern", | 53 "Adding good pattern", |
| 54 fmt.add("other", "{0} pounds", status)); | 54 fmt.addIfAbsent("other", "{0} pounds", status)); |
| 55 assertTrue("isValid with other", fmt.isValid()); | 55 assertTrue("isValid with other", fmt.isValid()); |
| 56 assertTrue( | 56 assertTrue( |
| 57 "Adding good pattern", | 57 "Adding good pattern", |
| 58 fmt.add("one", "{0} pound", status)); | 58 fmt.addIfAbsent("one", "{0} pound", status)); |
| 59 | 59 |
| 60 assertEquals( | 60 assertEquals( |
| 61 "getByVariant", | 61 "getByVariant", |
| 62 fmt.getByVariant("bad variant")->getPatternWithNoPlaceholders(), | 62 fmt.getByVariant("bad variant")->getPatternWithNoPlaceholders(), |
| 63 " pounds"); | 63 " pounds"); |
| 64 assertEquals( | 64 assertEquals( |
| 65 "getByVariant", | 65 "getByVariant", |
| 66 fmt.getByVariant("other")->getPatternWithNoPlaceholders(), | 66 fmt.getByVariant("other")->getPatternWithNoPlaceholders(), |
| 67 " pounds"); | 67 " pounds"); |
| 68 assertEquals( | 68 assertEquals( |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 } | 141 } |
| 142 fmt.reset(); | 142 fmt.reset(); |
| 143 assertFalse("isValid after reset", fmt.isValid()); | 143 assertFalse("isValid after reset", fmt.isValid()); |
| 144 #endif | 144 #endif |
| 145 assertSuccess("", status); | 145 assertSuccess("", status); |
| 146 } | 146 } |
| 147 | 147 |
| 148 extern IntlTest *createQuantityFormatterTest() { | 148 extern IntlTest *createQuantityFormatterTest() { |
| 149 return new QuantityFormatterTest(); | 149 return new QuantityFormatterTest(); |
| 150 } | 150 } |
| OLD | NEW |