]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/test/cintltst/cpluralrulestest.c
ICU-511.25.tar.gz
[apple/icu.git] / icuSources / test / cintltst / cpluralrulestest.c
index 7b12fadd9f177ae04927874e0f46a0a9f02469ea..3f33d2347366734f897d8e4060876c906bfe1d44 100644 (file)
@@ -1,5 +1,5 @@
 /********************************************************************
- * Copyright (c) 2011, International Business Machines Corporation
+ * Copyright (c) 2011-2012, International Business Machines Corporation
  * and others. All Rights Reserved.
  ********************************************************************/
 /* C API TEST FOR PLURAL RULES */
@@ -14,6 +14,7 @@
 #include "cmemory.h"
 
 static void TestPluralRules(void);
+static void TestOrdinalRules(void);
 
 void addPluralRulesTest(TestNode** root);
 
@@ -22,6 +23,7 @@ void addPluralRulesTest(TestNode** root);
 void addPluralRulesTest(TestNode** root)
 {
     TESTCASE(TestPluralRules);
+    TESTCASE(TestOrdinalRules);
 }
 
 typedef struct {
@@ -89,4 +91,22 @@ static void TestPluralRules()
     }
 }
 
+static void TestOrdinalRules() {
+    U_STRING_DECL(two, "two", 3);
+    UChar keyword[8];
+    int32_t length;
+    UErrorCode errorCode = U_ZERO_ERROR;
+    UPluralRules* upr = uplrules_openForType("en", UPLURAL_TYPE_ORDINAL, &errorCode);
+    if (U_FAILURE(errorCode)) {
+        log_err("uplrules_openForType(en, ordinal) failed - %s\n", u_errorName(errorCode));
+        return;
+    }
+    U_STRING_INIT(two, "two", 3);
+    length = uplrules_select(upr, 2., keyword, 8, &errorCode);
+    if (U_FAILURE(errorCode) || u_strCompare(keyword, length, two, 3, FALSE) != 0) {
+        log_data_err("uplrules_select(en-ordinal, 2) failed - %s\n", u_errorName(errorCode));
+    }
+    uplrules_close(upr);
+}
+
 #endif /* #if !UCONFIG_NO_FORMATTING */