]> granicus.if.org Git - icu/commitdiff
ICU-10131 Added C test to verify that 3 empty set values stop fallback for ures_getSt...
authorTravis Keep <keep94@gmail.com>
Fri, 24 May 2013 18:23:49 +0000 (18:23 +0000)
committerTravis Keep <keep94@gmail.com>
Fri, 24 May 2013 18:23:49 +0000 (18:23 +0000)
X-SVN-Rev: 33749

icu4c/source/test/cintltst/creststn.c
icu4c/source/test/cintltst/creststn.h
icu4c/source/test/testdata/te.txt
icu4c/source/test/testdata/te_IN.txt

index cd01601df5a0fdde9eefdbf60110ee3d51139348..fbb05093efa58972fdfd485bda0e1bcb57e4df24 100644 (file)
@@ -208,6 +208,7 @@ void addNEWResourceBundleTest(TestNode** root)
     addTest(root, &TestFallbackCodes,         "tsutil/creststn/TestFallbackCodes");
     addTest(root, &TestGetUTF8String,         "tsutil/creststn/TestGetUTF8String");
     addTest(root, &TestCLDRVersion,           "tsutil/creststn/TestCLDRVersion");
+    addTest(root, &TestPreventFallback,       "tsutil/creststn/TestPreventFallback");
 #endif
     addTest(root, &TestFallback,              "tsutil/creststn/TestFallback");
     addTest(root, &TestGetVersion,            "tsutil/creststn/TestGetVersion");
@@ -2008,6 +2009,62 @@ static void record_fail()
     ++fail;
 }
 
+static void TestPreventFallback() {
+    UResourceBundle* theBundle = NULL;
+    const char* testdatapath;
+    UErrorCode status = U_ZERO_ERROR;
+    UResourceBundle* res = NULL;
+    int32_t unused_len = 0;
+
+    testdatapath=loadTestData(&status);
+    if(U_FAILURE(status))
+    {
+        log_data_err("Could not load testdata.dat %s \n",myErrorName(status));
+        return;
+    }
+
+    // In te_IN locale, fallback of string_in_te_no_te_IN_fallback is blocked
+    // with the three empty-set (U+2205) chars.
+    theBundle = ures_open(testdatapath, "te_IN_NE", &status);
+    if(U_FAILURE(status))
+    {
+        log_data_err("Could not open resource bundle te_IN_NE %s \n",myErrorName(status));
+        return;
+    }
+
+    // Fallback is blocked
+    ures_getStringByKeyWithFallback(theBundle, "string_in_te_no_te_IN_fallback", &unused_len, &status);
+    if (status != U_MISSING_RESOURCE_ERROR)
+    {
+        log_err("Expected missing resource error for string_in_te_no_te_IN_fallback.");
+    }
+    status = U_ZERO_ERROR;
+
+    // This fallback should succeed
+    ures_getStringByKeyWithFallback(theBundle, "string_only_in_te", &unused_len, &status);
+    if(U_FAILURE(status))
+    {
+        log_err("Expected to find string_only_in_te %s \n",myErrorName(status));
+    }
+    status = U_ZERO_ERROR;
+    ures_close(theBundle);
+
+    // From te locale, we should be able to fetch string_in_te_no_te_IN_fallback.
+    theBundle = ures_open(testdatapath, "te", &status);
+    if(U_FAILURE(status))
+    {
+        log_data_err("Could not open resource bundle te_IN_NE %s \n",myErrorName(status));
+        return;
+    }
+    ures_getStringByKeyWithFallback(theBundle, "string_in_te_no_te_IN_fallback", &unused_len, &status);
+    if(U_FAILURE(status))
+    {
+        log_err("Expected to find string_in_te_no_te_IN_fallback %s \n",myErrorName(status));
+    }
+    status = U_ZERO_ERROR;
+    ures_close(theBundle);
+}
+
 /**
  * Test to make sure that the U_USING_FALLBACK_ERROR and U_USING_DEFAULT_ERROR
  * are set correctly
index 86810be788431f7aaee81c37c188093f84d34905..95eb2c3d84d88f27d06ba6f5e30aab58c6e27ace 100644 (file)
@@ -1,6 +1,6 @@
 /********************************************************************
  * COPYRIGHT: 
- * Copyright (c) 1997-2012, International Business Machines Corporation and
+ * Copyright (c) 1997-2013, International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************/
 /***************************************************************************
@@ -45,6 +45,8 @@ static void TestAliasConflict(void);
 
 static void TestFallback(void);
 
+static void TestPreventFallback(void);
+
 static void TestBinaryCollationData(void);
 
 static void TestNewTypes(void);
index 807735e02828c7d13408ad420cdfdda69cc90001..d3f3863c01a7db3a94eb211f5bf53afca60e6979 100644 (file)
@@ -1,6 +1,6 @@
 //*******************************************************************************
 //*
-//*   Copyright (C) 1998-2010, International Business Machines
+//*   Copyright (C) 1998-2013, International Business Machines
 //*   Corporation and others.  All Rights Reserved.
 //*
 //*******************************************************************************
@@ -12,6 +12,8 @@ te
 {
     string_only_in_te { TE }
 
+    string_in_te_no_te_IN_fallback { TE_no_fallback }
+
     array_only_in_te { TE0, TE1, TE2, TE3 }
 
     array_2d_only_in_te
index 6d2aa73b058d49aed63c13d69df315f5c8141106..df6eb1ad1dadb242787af09c8d7f6839000e82b1 100644 (file)
@@ -1,6 +1,6 @@
 //*******************************************************************************
 //*
-//*   Copyright (C) 1998-2005, International Business Machines
+//*   Copyright (C) 1998-2013, International Business Machines
 //*   Corporation and others.  All Rights Reserved.
 //*
 //*******************************************************************************
@@ -14,6 +14,8 @@ te_IN
 
     string_only_in_te_IN { TE_IN }
 
+    string_in_te_no_te_IN_fallback { ∅∅∅ }
+
     array_only_in_te_IN { TE_IN0, TE_IN1, TE_IN2, TE_IN3 }
 
     array_2d_only_in_te_IN