From fc3787c5455461a35213193f77a1b6bfa026defb Mon Sep 17 00:00:00 2001 From: Travis Keep Date: Tue, 18 Dec 2012 17:59:25 +0000 Subject: [PATCH] ICU-9804 Add unit test for fix to ures_getByKeyWithFallback. X-SVN-Rev: 32986 --- icu4c/source/test/cintltst/creststn.c | 25 +++++++++++++++++++++++++ icu4c/source/test/cintltst/creststn.h | 4 +++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/icu4c/source/test/cintltst/creststn.c b/icu4c/source/test/cintltst/creststn.c index 2cc2857a99f..8b1e33ca08c 100644 --- a/icu4c/source/test/cintltst/creststn.c +++ b/icu4c/source/test/cintltst/creststn.c @@ -202,6 +202,7 @@ void addNEWResourceBundleTest(TestNode** root) addTest(root, &TestDecodedBundle, "tsutil/creststn/TestDecodedBundle"); addTest(root, &TestResourceLevelAliasing, "tsutil/creststn/TestResourceLevelAliasing"); addTest(root, &TestDirectAccess, "tsutil/creststn/TestDirectAccess"); + addTest(root, &TestTicket9804, "tsutil/creststn/TestTicket9804"); addTest(root, &TestXPath, "tsutil/creststn/TestXPath"); addTest(root, &TestCLDRStyleAliases, "tsutil/creststn/TestCLDRStyleAliases"); addTest(root, &TestFallbackCodes, "tsutil/creststn/TestFallbackCodes"); @@ -2429,6 +2430,30 @@ static void TestDirectAccess(void) { ures_close(t); } +static void TestTicket9804(void) { + UErrorCode status = U_ZERO_ERROR; + UResourceBundle *t = NULL; + t = ures_open(NULL, "he", &status); + t = ures_getByKeyWithFallback(t, "calendar/islamic-civil/DateTime", t, &status); + if(U_SUCCESS(status)) { + log_err("This resource does not exist. How did it get here?\n"); + } + status = U_ZERO_ERROR; + ures_close(t); + t = ures_open(NULL, "he", &status); + t = ures_getByKeyWithFallback(t, "calendar/islamic-civil/eras", t, &status); + if(U_FAILURE(status)) { + log_err_status(status, "Didn't get Eras. I know they are there!\n"); + } else { + const char *locale = ures_getLocaleByType(t, ULOC_ACTUAL_LOCALE, &status); + if (uprv_strcmp("he", locale) != 0) { + log_err("Eras should be in the 'he' locale, but was in: %s", locale); + } + } + status = U_ZERO_ERROR; + ures_close(t); +} + static void TestJB3763(void) { /* Nasty bug prevented using parent as fill-in, since it would * stomp the path information. diff --git a/icu4c/source/test/cintltst/creststn.h b/icu4c/source/test/cintltst/creststn.h index f6becdb979c..86810be7884 100644 --- a/icu4c/source/test/cintltst/creststn.h +++ b/icu4c/source/test/cintltst/creststn.h @@ -1,6 +1,6 @@ /******************************************************************** * COPYRIGHT: - * Copyright (c) 1997-2006, International Business Machines Corporation and + * Copyright (c) 1997-2012, International Business Machines Corporation and * others. All Rights Reserved. ********************************************************************/ /*************************************************************************** @@ -63,6 +63,8 @@ static void TestEmptyBundle(void); static void TestDirectAccess(void); +static void TestTicket9804(void); + static void TestResourceLevelAliasing(void); static void TestErrorCodes(void); -- 2.40.0