OLD | NEW |
1 /******************************************************************** | 1 /******************************************************************** |
2 * COPYRIGHT: | 2 * COPYRIGHT: |
3 * Copyright (c) 1997-2013, International Business Machines Corporation and | 3 * Copyright (c) 1997-2014, International Business Machines Corporation and |
4 * others. All Rights Reserved. | 4 * others. All Rights Reserved. |
5 ********************************************************************/ | 5 ********************************************************************/ |
6 /******************************************************************************* | 6 /******************************************************************************* |
7 * | 7 * |
8 * File CRESTST.C | 8 * File CRESTST.C |
9 * | 9 * |
10 * Modification History: | 10 * Modification History: |
11 * Name Description | 11 * Name Description |
12 * Madhu Katragadda Ported for C API | 12 * Madhu Katragadda Ported for C API |
13 * 06/14/99 stephen Updated for RB API changes (no suffix). | 13 * 06/14/99 stephen Updated for RB API changes (no suffix). |
14 ******************************************************************************** | 14 ******************************************************************************** |
15 */ | 15 */ |
16 | 16 |
17 | 17 |
18 #include "unicode/utypes.h" | 18 #include "unicode/utypes.h" |
19 #include "cintltst.h" | 19 #include "cintltst.h" |
20 #include "unicode/ustring.h" | 20 #include "unicode/ustring.h" |
21 #include "cstring.h" | 21 #include "cstring.h" |
22 #include "filestrm.h" | 22 #include "filestrm.h" |
23 #include <stdlib.h> | 23 #include <stdlib.h> |
24 | 24 |
25 #define RESTEST_HEAP_CHECK 0 | 25 #define RESTEST_HEAP_CHECK 0 |
26 | 26 |
27 #include "unicode/ures.h" | 27 #include "unicode/ures.h" |
28 #include "crestst.h" | 28 #include "crestst.h" |
29 #include "unicode/ctest.h" | 29 #include "unicode/ctest.h" |
30 | 30 |
31 #include "ucol_imp.h" /* collation */ | |
32 | |
33 #define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0])) | |
34 | |
35 static void TestOpenDirect(void); | 31 static void TestOpenDirect(void); |
36 static void TestFallback(void); | 32 static void TestFallback(void); |
37 static void TestTable32(void); | 33 static void TestTable32(void); |
38 static void TestFileStream(void); | 34 static void TestFileStream(void); |
39 /*****************************************************************************/ | 35 /*****************************************************************************/ |
40 | 36 |
41 const UChar kERROR[] = { 0x0045 /*E*/, 0x0052 /*'R'*/, 0x0052 /*'R'*/, | 37 const UChar kERROR[] = { 0x0045 /*E*/, 0x0052 /*'R'*/, 0x0052 /*'R'*/, |
42 0x004F /*'O'*/, 0x0052/*'R'*/, 0x0000 /*'\0'*/}; | 38 0x004F /*'O'*/, 0x0052/*'R'*/, 0x0000 /*'\0'*/}; |
43 | 39 |
44 /*****************************************************************************/ | 40 /*****************************************************************************/ |
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 break; | 705 break; |
710 } | 706 } |
711 | 707 |
712 if(number>=0 && number!=parsedNumber) { | 708 if(number>=0 && number!=parsedNumber) { |
713 log_err("\"%s\" at %d in testdata/testtable32.res has a string/int v
alue of %d, expected %d\n", | 709 log_err("\"%s\" at %d in testdata/testtable32.res has a string/int v
alue of %d, expected %d\n", |
714 key, i, number, parsedNumber); | 710 key, i, number, parsedNumber); |
715 } | 711 } |
716 } | 712 } |
717 | 713 |
718 /* search for some items by key */ | 714 /* search for some items by key */ |
719 for(i=0; i<LENGTHOF(testcases); ++i) { | 715 for(i=0; i<UPRV_LENGTHOF(testcases); ++i) { |
720 item=ures_getByKey(res, testcases[i].key, item, &errorCode); | 716 item=ures_getByKey(res, testcases[i].key, item, &errorCode); |
721 if(U_FAILURE(errorCode)) { | 717 if(U_FAILURE(errorCode)) { |
722 log_err("unable to find the key \"%s\" in testdata/testtable32.res -
%s\n", | 718 log_err("unable to find the key \"%s\" in testdata/testtable32.res -
%s\n", |
723 testcases[i].key, u_errorName(errorCode)); | 719 testcases[i].key, u_errorName(errorCode)); |
724 continue; | 720 continue; |
725 } | 721 } |
726 | 722 |
727 switch(ures_getType(item)) { | 723 switch(ures_getType(item)) { |
728 case URES_STRING: | 724 case URES_STRING: |
729 s=ures_getString(item, &length, &errorCode); | 725 s=ures_getString(item, &length, &errorCode); |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
991 } | 987 } |
992 | 988 |
993 res = ures_getByKey(rb, test[i].resourceKey, res, &status); | 989 res = ures_getByKey(rb, test[i].resourceKey, res, &status); |
994 if(U_FAILURE(status)) | 990 if(U_FAILURE(status)) |
995 { | 991 { |
996 log_err("Couldn't find the key %s. Error: %s\n", test[i].resourceKey
, u_errorName(status)); | 992 log_err("Couldn't find the key %s. Error: %s\n", test[i].resourceKey
, u_errorName(status)); |
997 ures_close(rb); | 993 ures_close(rb); |
998 status = U_ZERO_ERROR; | 994 status = U_ZERO_ERROR; |
999 continue; | 995 continue; |
1000 } | 996 } |
1001 | 997 |
1002 locale = ures_getLocaleByType(res, ULOC_REQUESTED_LOCALE, &status); | 998 locale = ures_getLocaleByType(res, ULOC_REQUESTED_LOCALE, &status); |
1003 if(locale) { | 999 if(U_SUCCESS(status) && locale != NULL) { |
1004 log_err("Requested locale should return NULL\n"); | 1000 log_err("Requested locale should return NULL\n"); |
1005 } | 1001 } |
| 1002 status = U_ZERO_ERROR; |
1006 locale = ures_getLocaleByType(res, ULOC_VALID_LOCALE, &status); | 1003 locale = ures_getLocaleByType(res, ULOC_VALID_LOCALE, &status); |
1007 if(!locale || strcmp(locale, test[i].validLocale) != 0) { | 1004 if(!locale || strcmp(locale, test[i].validLocale) != 0) { |
1008 log_err("Expected valid locale to be %s. Got %s\n", test[i].requeste
dLocale, locale); | 1005 log_err("Expected valid locale to be %s. Got %s\n", test[i].requeste
dLocale, locale); |
1009 } | 1006 } |
1010 locale = ures_getLocaleByType(res, ULOC_ACTUAL_LOCALE, &status); | 1007 locale = ures_getLocaleByType(res, ULOC_ACTUAL_LOCALE, &status); |
1011 if(!locale || strcmp(locale, test[i].actualLocale) != 0) { | 1008 if(!locale || strcmp(locale, test[i].actualLocale) != 0) { |
1012 log_err("Expected actual locale to be %s. Got %s\n", test[i].request
edLocale, locale); | 1009 log_err("Expected actual locale to be %s. Got %s\n", test[i].request
edLocale, locale); |
1013 } | 1010 } |
1014 ures_close(rb); | 1011 ures_close(rb); |
1015 } | 1012 } |
1016 ures_close(res); | 1013 ures_close(res); |
1017 } | 1014 } |
1018 | |
OLD | NEW |