]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/test/cintltst/cucdapi.c
ICU-511.25.tar.gz
[apple/icu.git] / icuSources / test / cintltst / cucdapi.c
index ee8d203342d6806d954e72a5a5e6a4f65a9e07e0..9fa0170973cfdd685ebaf25af93647ea3058162a 100644 (file)
@@ -1,5 +1,5 @@
 /********************************************************************
- * Copyright (c) 1997-2012, International Business Machines
+ * Copyright (c) 1997-2013, International Business Machines
  * Corporation and others. All Rights Reserved.
  ********************************************************************/
 
@@ -527,6 +527,68 @@ void TestGetScriptExtensions() {
     }
 }
 
+void TestScriptMetadataAPI() {
+    /* API & code coverage. More testing in intltest/ucdtest.cpp. */
+    UErrorCode errorCode=U_ZERO_ERROR;
+    UChar sample[8];
+
+    if(uscript_getSampleString(USCRIPT_LATIN, sample, LENGTHOF(sample), &errorCode)!=1 ||
+            U_FAILURE(errorCode) ||
+            uscript_getScript(sample[0], &errorCode)!=USCRIPT_LATIN ||
+            sample[1]!=0) {
+        log_err("uscript_getSampleString(Latn) failed - %s\n", u_errorName(errorCode));
+    }
+    sample[0]=0xfffe;
+    if(uscript_getSampleString(USCRIPT_LATIN, sample, 0, &errorCode)!=1 ||
+            errorCode!=U_BUFFER_OVERFLOW_ERROR ||
+            sample[0]!=0xfffe) {
+        log_err("uscript_getSampleString(Latn, capacity=0) failed - %s\n", u_errorName(errorCode));
+    }
+    errorCode=U_ZERO_ERROR;
+    if(uscript_getSampleString(USCRIPT_INVALID_CODE, sample, LENGTHOF(sample), &errorCode)!=0 ||
+            U_FAILURE(errorCode) ||
+            sample[0]!=0) {
+        log_err("uscript_getSampleString(invalid) failed - %s\n", u_errorName(errorCode));
+    }
+    sample[0]=0xfffe;
+    if(uscript_getSampleString(USCRIPT_CODE_LIMIT, sample, 0, &errorCode)!=0 ||
+            errorCode!=U_STRING_NOT_TERMINATED_WARNING ||
+            sample[0]!=0xfffe) {
+        log_err("uscript_getSampleString(limit, capacity=0) failed - %s\n", u_errorName(errorCode));
+    }
+
+    if(uscript_getUsage(USCRIPT_LATIN)!=USCRIPT_USAGE_RECOMMENDED ||
+            uscript_getUsage(USCRIPT_YI)!=USCRIPT_USAGE_ASPIRATIONAL ||
+            uscript_getUsage(USCRIPT_CHEROKEE)!=USCRIPT_USAGE_LIMITED_USE ||
+            uscript_getUsage(USCRIPT_COPTIC)!=USCRIPT_USAGE_EXCLUDED ||
+            uscript_getUsage(USCRIPT_CIRTH)!=USCRIPT_USAGE_NOT_ENCODED ||
+            uscript_getUsage(USCRIPT_INVALID_CODE)!=USCRIPT_USAGE_NOT_ENCODED ||
+            uscript_getUsage(USCRIPT_CODE_LIMIT)!=USCRIPT_USAGE_NOT_ENCODED) {
+        log_err("uscript_getUsage() failed\n");
+    }
+
+    if(uscript_isRightToLeft(USCRIPT_LATIN) ||
+            uscript_isRightToLeft(USCRIPT_CIRTH) ||
+            !uscript_isRightToLeft(USCRIPT_ARABIC) ||
+            !uscript_isRightToLeft(USCRIPT_HEBREW)) {
+        log_err("uscript_isRightToLeft() failed\n");
+    }
+
+    if(uscript_breaksBetweenLetters(USCRIPT_LATIN) ||
+            uscript_breaksBetweenLetters(USCRIPT_CIRTH) ||
+            !uscript_breaksBetweenLetters(USCRIPT_HAN) ||
+            !uscript_breaksBetweenLetters(USCRIPT_THAI)) {
+        log_err("uscript_breaksBetweenLetters() failed\n");
+    }
+
+    if(uscript_isCased(USCRIPT_CIRTH) ||
+            uscript_isCased(USCRIPT_HAN) ||
+            !uscript_isCased(USCRIPT_LATIN) ||
+            !uscript_isCased(USCRIPT_GREEK)) {
+        log_err("uscript_isCased() failed\n");
+    }
+}
+
 void TestBinaryValues() {
     /*
      * Unicode 5.1 explicitly defines binary property value aliases.