1
/********************************************************************
3
* Copyright (c) 1997-2001, International Business Machines Corporation and
4
* others. All Rights Reserved.
5
********************************************************************/
11
#define RESTEST_HEAP_CHECK 0
13
#include "unicode/utypes.h"
15
#if defined(_WIN32) && !defined(__WINDOWS__)
16
#define _CRTDBG_MAP_ALLOC
21
#include "unicode/unistr.h"
22
#include "unicode/resbund.h"
26
//***************************************************************************************
28
static const UChar kErrorUChars[] = { 0x45, 0x52, 0x52, 0x4f, 0x52, 0 };
29
static const int32_t kErrorLength = 5;
30
static const int32_t kERROR_COUNT = -1234567;
32
//***************************************************************************************
42
//***************************************************************************************
44
#define CONFIRM_EQ(actual,expected) if ((expected)==(actual)) { record_pass(); } else { record_fail(); OUT << action << " returned " << (actual) << " instead of " << (expected) << endl; }
45
#define CONFIRM_GE(actual,expected) if ((actual)>=(expected)) { record_pass(); } else { record_fail(); OUT << action << " returned " << (actual) << " instead of x >= " << (expected) << endl; }
46
#define CONFIRM_NE(actual,expected) if ((expected)!=(actual)) { record_pass(); } else { record_fail(); OUT << action << " returned " << (actual) << " instead of x != " << (expected) << endl; }
48
#define CONFIRM_UErrorCode(actual,expected) if ((expected)==(actual)) { record_pass(); } else { record_fail(); OUT << action << " returned " << u_errorName(actual) << " instead of " << u_errorName(expected) << endl; }
50
//***************************************************************************************
53
* Convert an integer, positive or negative, to a character string radix 10.
56
itoa(int32_t i, char* buf)
67
// Output digits in reverse order
71
*p++ = (char)('0' + (i % 10));
90
//***************************************************************************************
92
// Array of our test objects
98
UErrorCode expected_constructor_status;
100
UBool like[e_Where_count];
101
UBool inherits[e_Where_count];
106
// "IN" means inherits
107
// "NE" or "ne" means "does not exist"
109
{ "root", 0, U_ZERO_ERROR, e_Root, { TRUE, FALSE, FALSE }, { TRUE, FALSE, FALSE } },
110
{ "te", 0, U_ZERO_ERROR, e_te, { FALSE, TRUE, FALSE }, { TRUE, TRUE, FALSE } },
111
{ "te_IN", 0, U_ZERO_ERROR, e_te_IN, { FALSE, FALSE, TRUE }, { TRUE, TRUE, TRUE } },
112
{ "te_NE", 0, U_USING_FALLBACK_ERROR, e_te, { FALSE, TRUE, FALSE }, { TRUE, TRUE, FALSE } },
113
{ "te_IN_NE", 0, U_USING_FALLBACK_ERROR, e_te_IN, { FALSE, FALSE, TRUE }, { TRUE, TRUE, TRUE } },
114
{ "ne", 0, U_USING_DEFAULT_ERROR, e_Root, { TRUE, FALSE, FALSE }, { TRUE, FALSE, FALSE } }
117
static int32_t bundles_count = sizeof(param) / sizeof(param[0]);
119
//***************************************************************************************
122
* Return a random unsigned long l where 0N <= l <= ULONG_MAX.
128
static UBool initialized = FALSE;
131
srand((unsigned)time(NULL));
134
// Assume rand has at least 12 bits of precision
136
for (uint32_t i=0; i<sizeof(l); ++i)
137
((char*)&l)[i] = (char)((rand() & 0x0FF0) >> 4);
142
* Return a random double x where 0.0 <= x < 1.0.
147
return (double)(randul() / ULONG_MAX);
151
* Return a random integer i where 0 <= i < n.
153
static int32_t randi(int32_t n)
155
return (int32_t)(randd() * n);
158
//***************************************************************************************
161
Don't use more than one of these at a time because of the Locale names
163
NewResourceBundleTest::NewResourceBundleTest()
168
if (param[5].locale == NULL) {
169
param[0].locale = new Locale("root");
170
param[1].locale = new Locale("te");
171
param[2].locale = new Locale("te", "IN");
172
param[3].locale = new Locale("te", "NE");
173
param[4].locale = new Locale("te", "IN", "NE");
174
param[5].locale = new Locale("ne");
178
NewResourceBundleTest::~NewResourceBundleTest()
180
if (param[5].locale) {
182
for (idx = 0; idx < (int)(sizeof(param)/sizeof(param[0])); idx++) {
183
delete param[idx].locale;
184
param[idx].locale = NULL;
189
void NewResourceBundleTest::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par*/ )
191
if (exec) logln("TestSuite ResourceBundleTest: ");
193
case 0: name = "TestResourceBundles"; if (exec) TestResourceBundles(); break;
194
case 1: name = "TestConstruction"; if (exec) TestConstruction(); break;
195
case 2: name = "TestIteration"; if (exec) TestIteration(); break;
196
case 3: name = "TestOtherAPI"; if(exec) TestOtherAPI(); break;
198
default: name = ""; break; //needed to end loop
202
//***************************************************************************************
205
NewResourceBundleTest::TestResourceBundles()
207
#if defined(_WIN32) && !defined(__WINDOWS__)
208
#if defined(_DEBUG) && RESTEST_HEAP_CHECK
210
* Set the debug-heap flag to keep freed blocks in the
211
* heap's linked list - This will allow us to catch any
212
* inadvertent use of freed memory
214
int tmpDbgFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
215
tmpDbgFlag |= _CRTDBG_DELAY_FREE_MEM_DF;
216
tmpDbgFlag |= _CRTDBG_LEAK_CHECK_DF;
217
tmpDbgFlag |= _CRTDBG_CHECK_ALWAYS_DF;
218
_CrtSetDbgFlag(tmpDbgFlag);
220
_CrtMemState memstate;
221
_CrtMemCheckpoint(&memstate);
226
testTag("only_in_Root", TRUE, FALSE, FALSE);
227
testTag("only_in_te", FALSE, TRUE, FALSE);
228
testTag("only_in_te_IN", FALSE, FALSE, TRUE);
229
testTag("in_Root_te", TRUE, TRUE, FALSE);
230
testTag("in_Root_te_te_IN", TRUE, TRUE, TRUE);
231
testTag("in_Root_te_IN", TRUE, FALSE, TRUE);
232
testTag("in_te_te_IN", FALSE, TRUE, TRUE);
233
testTag("nonexistent", FALSE, FALSE, FALSE);
234
OUT << "Passed: " << pass << "\nFailed: " << fail << endl;
236
#if defined(_WIN32) && !defined(__WINDOWS__)
237
#if defined(_DEBUG) && RESTEST_HEAP_CHECK
239
_CrtMemDumpAllObjectsSince(&memstate);
242
* Set the debug-heap flag to keep freed blocks in the
243
* heap's linked list - This will allow us to catch any
244
* inadvertent use of freed memory
246
tmpDbgFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
247
tmpDbgFlag |= _CRTDBG_DELAY_FREE_MEM_DF;
248
tmpDbgFlag &= ~_CRTDBG_LEAK_CHECK_DF;
249
tmpDbgFlag &= ~_CRTDBG_CHECK_ALWAYS_DF;
250
_CrtSetDbgFlag(tmpDbgFlag);
256
NewResourceBundleTest::TestConstruction()
259
UErrorCode err = U_ZERO_ERROR;
260
const char* testdatapath;
261
Locale locale("te", "IN");
262
testdatapath=loadTestData(err);
265
errln("Could not load testdata.dat %s " + UnicodeString(u_errorName(err)));
269
ResourceBundle test1((UnicodeString)testdatapath, err);
270
ResourceBundle test2(testdatapath, locale, err);
272
UnicodeString result1;
273
UnicodeString result2;
275
result1 = test1.getStringEx("string_in_Root_te_te_IN", err);
276
result2 = test2.getStringEx("string_in_Root_te_te_IN", err);
277
if (U_FAILURE(err)) {
278
errln("Something threw an error in TestConstruction()");
282
logln("for string_in_Root_te_te_IN, root.txt had " + result1);
283
logln("for string_in_Root_te_te_IN, te_IN.txt had " + result2);
285
if (result1 != "ROOT" || result2 != "TE_IN")
286
errln("Construction test failed; run verbose for more information");
288
const char* version1;
289
const char* version2;
291
version1 = test1.getVersionNumber();
292
version2 = test2.getVersionNumber();
294
char *versionID1 = new char[1 + strlen(U_ICU_VERSION) + strlen(version1)]; // + 1 for zero byte
295
char *versionID2 = new char[1 + strlen(U_ICU_VERSION) + strlen(version2)]; // + 1 for zero byte
297
strcpy(versionID1, "44.0"); // hardcoded, please change if the default.txt file or ResourceBundle::kVersionSeparater is changed.
299
strcpy(versionID2, "55.0"); // hardcoded, please change if the te_IN.txt file or ResourceBundle::kVersionSeparater is changed.
301
logln(UnicodeString("getVersionNumber on default.txt returned ") + version1 + UnicodeString(" Expect: " ) + versionID1);
302
logln(UnicodeString("getVersionNumber on te_IN.txt returned ") + version2 + UnicodeString(" Expect: " ) + versionID2);
304
if (strcmp(version1, versionID1) != 0 || strcmp(version2, versionID2) != 0)
305
errln("getVersionNumber() failed");
310
UErrorCode err = U_ZERO_ERROR;
311
const char* testdatapath;
312
Locale locale("te", "IN");
314
testdatapath=loadTestData(err);
317
errln("Could not load testdata.dat %s " + UnicodeString(u_errorName(err)));
322
wchar_t* wideDirectory = new wchar_t[256];
323
mbstowcs(wideDirectory, testdatapath, 256);
325
ResourceBundle test2(wideDirectory, locale, err);
327
UnicodeString result2;
329
result2 = test2.getStringEx("string_in_Root_te_te_IN", err);
330
if (U_FAILURE(err)) {
331
errln("Something threw an error in TestConstruction()");
335
logln("for string_in_Root_te_te_IN, te_IN.txt had " + result2);
337
if (result2 != "TE_IN")
338
errln("Construction test failed; run verbose for more information");
340
delete[] wideDirectory;
344
NewResourceBundleTest::TestIteration()
346
UErrorCode err = U_ZERO_ERROR;
347
const char* testdatapath;
349
"string_in_Root_te_te_IN", "1",
350
"array_in_Root_te_te_IN", "5",
351
"array_2d_in_Root_te_te_IN", "4",
354
Locale *locale=new Locale("te_IN");
356
testdatapath=loadTestData(err);
359
errln("Could not load testdata.dat %s " + UnicodeString(u_errorName(err)));
363
ResourceBundle test1(testdatapath, *locale, err);
365
errln("Construction failed");
368
int32_t count, row=0, col=0;
370
UnicodeString expected;
371
UnicodeString element("TE_IN");
372
UnicodeString action;
375
for(i=0; i<sizeof(data)/sizeof(data[0]); i=i+2){
381
ResourceBundle bundle = test1.get(data[i], err);
384
action +=".getKey()";
386
CONFIRM_EQ((UnicodeString)bundle.getKey(), (UnicodeString)data[i]);
390
while(bundle.hasNext()){
392
action +=".getNextString(err)";
394
UnicodeString got=bundle.getNextString(err);
397
if(bundle.getSize() > 1){
398
CONFIRM_EQ(bundle.getType(), RES_ARRAY);
399
expected+=itoa(row, buf);
400
ResourceBundle rowbundle=bundle.get(row, err);
401
if(!U_FAILURE(err) && rowbundle.getSize()>1){
403
while(rowbundle.hasNext()){
405
got=rowbundle.getNextString(err);
407
expected+=itoa(row, buf);
408
expected+=itoa(col, buf);
410
CONFIRM_EQ(got, expected);
413
CONFIRM_EQ(col, rowbundle.getSize());
417
CONFIRM_EQ(bundle.getType(), (int32_t)RES_STRING);
420
CONFIRM_EQ(got, expected);
424
action +=".getSize()";
425
CONFIRM_EQ(bundle.getSize(), count);
426
CONFIRM_EQ(count, atoi(data[i+1]));
427
//after reaching the end
429
ResourceBundle errbundle=bundle.getNext(err);
430
action = "After reaching the end of the Iterator:- ";
432
action +=".getNext()";
433
CONFIRM_NE(err, (int32_t)U_ZERO_ERROR);
434
CONFIRM_EQ(u_errorName(err), u_errorName(U_INDEX_OUTOFBOUNDS_ERROR));
437
bundle.resetIterator();
438
/* The following code is causing a crash
444
errln("ERROR: getNext() throw an error");
457
NewResourceBundleTest::TestOtherAPI(){
458
UErrorCode err = U_ZERO_ERROR;
459
const char* testdatapath;
460
testdatapath=loadTestData(err);
463
errln("Could not load testdata.dat %s " + UnicodeString(u_errorName(err)));
466
Locale *locale=new Locale("te_IN");
468
ResourceBundle test1(testdatapath, *locale, err);
470
errln("Construction failed");
474
logln("Testing getLocale()\n");
475
if(strcmp(test1.getLocale().getName(), locale->getName()) !=0 ){
476
errln("FAIL: ResourceBundle::getLocale() failed\n");
481
logln("Testing ResourceBundle(UErrorCode)\n");
482
ResourceBundle defaultresource(err);
484
errln("Construction of default resourcebundle failed");
486
if(strcmp(defaultresource.getLocale().getName(), Locale::getDefault().getName()) != 0){
487
errln("Construction of default resourcebundle didn't take the defaultlocale\n");
491
ResourceBundle copyRes(defaultresource);
492
if(strcmp(copyRes.getName(), defaultresource.getName() ) !=0 ||
493
strcmp(test1.getName(), defaultresource.getName() ) ==0 ||
494
strcmp(copyRes.getLocale().getName(), defaultresource.getLocale().getName() ) !=0 ||
495
strcmp(test1.getLocale().getName(), defaultresource.getLocale().getName() ) ==0 ){
496
errln("copy construction failed\n");
499
ResourceBundle defaultSub = defaultresource.get(1, err);
500
ResourceBundle defSubCopy(defaultSub);
501
if(strcmp(defSubCopy.getName(), defaultSub.getName() ) !=0 ||
502
strcmp(defSubCopy.getLocale().getName(), defaultSub.getLocale().getName() ) !=0 ){
503
errln("copy construction for subresource failed\n");
509
copyRes.getVersion(ver);
511
logln("Version returned: [%d.%d.%d.%d]\n", ver[0], ver[1], ver[2], ver[3]);
513
logln("Testing C like UnicodeString APIs\n");
515
UResourceBundle *testCAPI = NULL, *bundle = NULL, *rowbundle = NULL, *temp = NULL;
518
"string_in_Root_te_te_IN", "1",
519
"array_in_Root_te_te_IN", "5",
520
"array_2d_in_Root_te_te_IN", "4",
525
testCAPI = ures_open(testdatapath, "te_IN", &err);
532
int32_t count, row=0, col=0;
534
UnicodeString expected;
535
UnicodeString element("TE_IN");
536
UnicodeString action;
539
for(i=0; i<sizeof(data)/sizeof(data[0]); i=i+2){
545
bundle = ures_getByKey(testCAPI, data[i], bundle, &err);
547
const char* key = NULL;
549
action +=".getKey()";
551
CONFIRM_EQ((UnicodeString)ures_getKey(bundle), (UnicodeString)data[i]);
555
while(ures_hasNext(bundle)){
557
action +=".getNextString(err)";
559
UnicodeString got=ures_getNextUnicodeString(bundle, &key, &err);
562
if(ures_getSize(bundle) > 1){
563
CONFIRM_EQ(ures_getType(bundle), RES_ARRAY);
564
expected+=itoa(row, buf);
565
rowbundle=ures_getByIndex(bundle, row, rowbundle, &err);
566
if(!U_FAILURE(err) && ures_getSize(rowbundle)>1){
568
while(ures_hasNext(rowbundle)){
570
got=ures_getNextUnicodeString(rowbundle, &key, &err);
571
temp = ures_getByIndex(rowbundle, col, temp, &err);
572
UnicodeString bla = ures_getUnicodeString(temp, &err);
573
UnicodeString bla2 = ures_getUnicodeStringByIndex(rowbundle, col, &err);
575
expected+=itoa(row, buf);
576
expected+=itoa(col, buf);
578
CONFIRM_EQ(got, expected);
579
CONFIRM_EQ(bla, expected);
580
CONFIRM_EQ(bla2, expected);
583
CONFIRM_EQ(col, ures_getSize(rowbundle));
587
CONFIRM_EQ(ures_getType(bundle), (int32_t)RES_STRING);
590
CONFIRM_EQ(got, expected);
596
ures_close(rowbundle);
598
ures_close(testCAPI);
600
errln("failed to open a resource bundle\n");
617
//***************************************************************************************
620
NewResourceBundleTest::testTag(const char* frag,
625
int32_t failOrig = fail;
627
// Make array from input params
629
UBool is_in[] = { in_Root, in_te, in_te_IN };
631
const char* NAME[] = { "ROOT", "TE", "TE_IN" };
633
// Now try to load the desired items
636
UnicodeString action;
638
int32_t i,j,row,col, actual_bundle;
640
const char* testdatapath;
642
UErrorCode status = U_ZERO_ERROR;
643
testdatapath=loadTestData(status);
644
if(U_FAILURE(status))
646
errln("Could not load testdata.dat %s " + UnicodeString(u_errorName(status)));
650
for (i=0; i<bundles_count; ++i)
652
action = "Constructor for ";
653
action += param[i].name;
655
status = U_ZERO_ERROR;
656
ResourceBundle theBundle( testdatapath, *param[i].locale, status);
657
//ResourceBundle theBundle( "c:\\icu\\icu\\source\\test\\testdata\\testdata", *param[i].locale, status);
658
CONFIRM_UErrorCode(status,param[i].expected_constructor_status);
661
actual_bundle = 0; /* ne -> default */
663
actual_bundle = 1; /* te_NE -> te */
665
actual_bundle = 2; /* te_IN_NE -> te_IN */
670
UErrorCode expected_resource_status = U_MISSING_RESOURCE_ERROR;
671
for (j=e_te_IN; j>=e_Root; --j)
673
if (is_in[j] && param[i].inherits[j])
675
if(j == actual_bundle) /* it's in the same bundle OR it's a nonexistent=default bundle (5) */
676
expected_resource_status = U_ZERO_ERROR;
678
expected_resource_status = U_USING_DEFAULT_ERROR;
680
expected_resource_status = U_USING_FALLBACK_ERROR;
686
UErrorCode expected_status;
689
for (j=param[i].where; j>=0; --j)
698
//--------------------------------------------------------------------------
701
uprv_strcpy(tag, "string_");
702
uprv_strcat(tag, frag);
704
action = param[i].name;
705
action += ".getStringEx(";
710
status = U_ZERO_ERROR;
711
UnicodeString string = theBundle.getStringEx(tag, status);
712
if(U_FAILURE(status)) {
713
string.setTo(TRUE, kErrorUChars, kErrorLength);
716
CONFIRM_UErrorCode(status, expected_resource_status);
718
UnicodeString expected_string(kErrorUChars);
719
if (U_SUCCESS(status)) {
720
expected_string = base;
723
CONFIRM_EQ(string, expected_string);
725
//--------------------------------------------------------------------------
726
// array ResourceBundle using the key
728
uprv_strcpy(tag, "array_");
729
uprv_strcat(tag, frag);
731
action = param[i].name;
736
int32_t count = kERROR_COUNT;
737
status = U_ZERO_ERROR;
738
ResourceBundle array = theBundle.get(tag, status);
739
CONFIRM_UErrorCode(status,expected_resource_status);
742
if (U_SUCCESS(status))
744
//confirm the resource type is an array
745
UResType bundleType=array.getType();
746
CONFIRM_EQ(bundleType, RES_ARRAY);
748
count=array.getSize();
751
for (j=0; j<count; ++j)
754
expected_string = base;
755
expected_string += itoa(j,buf);
756
CONFIRM_EQ(array.getNextString(status),expected_string);
762
CONFIRM_EQ(count,kERROR_COUNT);
763
// CONFIRM_EQ((int32_t)(unsigned long)array,(int32_t)0);
767
//--------------------------------------------------------------------------
768
// arrayItem ResourceBundle using the index
771
for (j=0; j<100; ++j)
773
index = count ? (randi(count * 3) - count) : (randi(200) - 100);
774
status = U_ZERO_ERROR;
775
string = kErrorUChars;
776
ResourceBundle array = theBundle.get(tag, status);
777
if(!U_FAILURE(status)){
778
UnicodeString t = array.getStringEx(index, status);
779
if(!U_FAILURE(status)) {
784
expected_status = (index >= 0 && index < count) ? expected_resource_status : U_MISSING_RESOURCE_ERROR;
785
CONFIRM_UErrorCode(status,expected_status);
787
if (U_SUCCESS(status)){
789
expected_string = base;
790
expected_string += itoa(index,buf);
792
expected_string = kErrorUChars;
794
CONFIRM_EQ(string,expected_string);
798
//--------------------------------------------------------------------------
801
uprv_strcpy(tag, "array_2d_");
802
uprv_strcat(tag, frag);
804
action = param[i].name;
810
int32_t row_count = kERROR_COUNT, column_count = kERROR_COUNT;
811
status = U_ZERO_ERROR;
812
ResourceBundle array2d=theBundle.get(tag, status);
814
//const UnicodeString** array2d = theBundle.get2dArray(tag, row_count, column_count, status);
815
CONFIRM_UErrorCode(status,expected_resource_status);
817
if (U_SUCCESS(status))
819
//confirm the resource type is an 2darray
820
UResType bundleType=array2d.getType();
821
CONFIRM_EQ(bundleType, RES_ARRAY);
823
row_count=array2d.getSize();
824
CONFIRM_GE(row_count,1);
826
for(row=0; row<row_count; ++row){
827
ResourceBundle tablerow=array2d.get(row, status);
828
CONFIRM_UErrorCode(status, expected_resource_status);
829
if(U_SUCCESS(status)){
830
//confirm the resourcetype of each table row is an array
831
UResType rowType=tablerow.getType();
832
CONFIRM_EQ(rowType, RES_ARRAY);
834
column_count=tablerow.getSize();
835
CONFIRM_GE(column_count,1);
837
for (col=0; j<column_count; ++j) {
839
expected_string = base;
840
expected_string += itoa(row,buf);
841
expected_string += itoa(col,buf);
842
CONFIRM_EQ(tablerow.getNextString(status),expected_string);
847
CONFIRM_EQ(row_count,kERROR_COUNT);
848
CONFIRM_EQ(column_count,kERROR_COUNT);
849
row_count=column_count=0;
855
//--------------------------------------------------------------------------
857
for (j=0; j<200; ++j)
859
row = row_count ? (randi(row_count * 3) - row_count) : (randi(200) - 100);
860
col = column_count ? (randi(column_count * 3) - column_count) : (randi(200) - 100);
861
status = U_ZERO_ERROR;
862
string = kErrorUChars;
863
ResourceBundle array2d=theBundle.get(tag, status);
864
if(U_SUCCESS(status)){
865
ResourceBundle tablerow=array2d.get(row, status);
866
if(U_SUCCESS(status)) {
867
UnicodeString t=tablerow.getStringEx(col, status);
868
if(U_SUCCESS(status)){
873
expected_status = (row >= 0 && row < row_count && col >= 0 && col < column_count) ?
874
expected_resource_status: U_MISSING_RESOURCE_ERROR;
875
CONFIRM_UErrorCode(status,expected_status);
877
if (U_SUCCESS(status)){
879
expected_string = base;
880
expected_string += itoa(row,buf);
881
expected_string += itoa(col,buf);
883
expected_string = kErrorUChars;
885
CONFIRM_EQ(string,expected_string);
889
//--------------------------------------------------------------------------
892
uprv_strcpy(tag, "tagged_array_");
893
uprv_strcat(tag, frag);
895
action = param[i].name;
901
status = U_ZERO_ERROR;
903
ResourceBundle tags=theBundle.get(tag, status);
904
CONFIRM_UErrorCode(status, expected_resource_status);
906
if (U_SUCCESS(status)) {
907
UResType bundleType=tags.getType();
908
CONFIRM_EQ(bundleType, RES_TABLE);
910
tag_count=tags.getSize();
911
CONFIRM_GE((int32_t)tag_count, (int32_t)0);
913
for(index=0; index <tag_count; index++){
914
ResourceBundle tagelement=tags.get(index, status);
915
UnicodeString key=tagelement.getKey();
916
UnicodeString value=tagelement.getNextString(status);
917
logln("tag = " + key + ", value = " + value );
918
if(key.startsWith("tag") && value.startsWith(base)){
926
for(index=0; index <tag_count; index++){
927
ResourceBundle tagelement=tags.get(index, status);
928
const char *tkey=NULL;
929
UnicodeString value=tagelement.getNextString(&tkey, status);
930
UnicodeString key(tkey);
931
logln("tag = " + key + ", value = " + value );
932
if(value.startsWith(base)){
946
//--------------------------------------------------------------------------
949
action = param[i].name;
955
for (index=-20; index<20; ++index)
958
status = U_ZERO_ERROR;
959
string = kErrorUChars;
961
uprv_strcpy(item_tag, "tag");
962
uprv_strcat(item_tag, itoa(index,buf));
963
ResourceBundle tags=theBundle.get(tag, status);
964
if(U_SUCCESS(status)){
965
ResourceBundle tagelement=tags.get(item_tag, status);
966
if(!U_FAILURE(status)){
967
UResType elementType=tagelement.getType();
968
CONFIRM_EQ(elementType, (int32_t)RES_STRING);
969
const char* key=tagelement.getKey();
970
CONFIRM_EQ((UnicodeString)key, (UnicodeString)item_tag);
971
UnicodeString t=tagelement.getString(status);
972
if(!U_FAILURE(status)){
977
CONFIRM_UErrorCode(status,U_MISSING_RESOURCE_ERROR);
980
if (status != U_MISSING_RESOURCE_ERROR) {
982
expected_string = base;
983
expected_string += buf;
984
CONFIRM_EQ(string,expected_string);
990
CONFIRM_EQ(count, tag_count);
993
return (UBool)(failOrig == fail);
997
NewResourceBundleTest::record_pass()
1002
NewResourceBundleTest::record_fail()