| OLD | NEW |
| 1 /* | 1 /* |
| 2 ******************************************************************************* | 2 ******************************************************************************* |
| 3 * | 3 * |
| 4 * Copyright (C) 2003-2010, International Business Machines | 4 * Copyright (C) 2003-2014, International Business Machines |
| 5 * Corporation and others. All Rights Reserved. | 5 * Corporation and others. All Rights Reserved. |
| 6 * | 6 * |
| 7 ******************************************************************************* | 7 ******************************************************************************* |
| 8 * file name: spreptst.c | 8 * file name: spreptst.c |
| 9 * encoding: US-ASCII | 9 * encoding: US-ASCII |
| 10 * tab size: 8 (not used) | 10 * tab size: 8 (not used) |
| 11 * indentation:4 | 11 * indentation:4 |
| 12 * | 12 * |
| 13 * created on: 2003jul11 | 13 * created on: 2003jul11 |
| 14 * created by: Ram Viswanadha | 14 * created by: Ram Viswanadha |
| 15 */ | 15 */ |
| 16 #include <stdlib.h> | 16 #include <stdlib.h> |
| 17 #include <string.h> | 17 #include <string.h> |
| 18 #include "unicode/utypes.h" | 18 #include "unicode/utypes.h" |
| 19 | 19 |
| 20 #if !UCONFIG_NO_IDNA | 20 #if !UCONFIG_NO_IDNA |
| 21 | 21 |
| 22 #include "unicode/ustring.h" | 22 #include "unicode/ustring.h" |
| 23 #include "unicode/usprep.h" | 23 #include "unicode/usprep.h" |
| 24 #include "cstring.h" | 24 #include "cstring.h" |
| 25 #include "cintltst.h" | 25 #include "cintltst.h" |
| 26 #include "nfsprep.h" | 26 #include "nfsprep.h" |
| 27 | 27 |
| 28 | |
| 29 #define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0])) | |
| 30 | |
| 31 void addUStringPrepTest(TestNode** root); | 28 void addUStringPrepTest(TestNode** root); |
| 32 void doStringPrepTest(const char* binFileName, const char* txtFileName, | 29 void doStringPrepTest(const char* binFileName, const char* txtFileName, |
| 33 int32_t options, UErrorCode* errorCode); | 30 int32_t options, UErrorCode* errorCode); |
| 34 | 31 |
| 35 static void Test_nfs4_cs_prep_data(void); | 32 static void Test_nfs4_cs_prep_data(void); |
| 36 static void Test_nfs4_cis_prep_data(void); | 33 static void Test_nfs4_cis_prep_data(void); |
| 37 static void Test_nfs4_mixed_prep_data(void); | 34 static void Test_nfs4_mixed_prep_data(void); |
| 38 static void Test_nfs4_cs_prep(void); | 35 static void Test_nfs4_cs_prep(void); |
| 39 static void Test_nfs4_cis_prep(void); | 36 static void Test_nfs4_cis_prep(void); |
| 40 static void Test_nfs4_mixed_prep(void); | 37 static void Test_nfs4_mixed_prep(void); |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 if (U_FAILURE(loadStatus)) { | 434 if (U_FAILURE(loadStatus)) { |
| 438 log_data_err("Test could not initialize. Got %s\n", u_errorName(loadStat
us)); | 435 log_data_err("Test could not initialize. Got %s\n", u_errorName(loadStat
us)); |
| 439 return; | 436 return; |
| 440 } | 437 } |
| 441 | 438 |
| 442 { | 439 { |
| 443 int32_t i=0; | 440 int32_t i=0; |
| 444 char src[MAX_BUFFER_SIZE]; | 441 char src[MAX_BUFFER_SIZE]; |
| 445 int32_t srcLen; | 442 int32_t srcLen; |
| 446 | 443 |
| 447 for(i=0; i< LENGTHOF(mixed_prep_data); i++){ | 444 for(i=0; i< UPRV_LENGTHOF(mixed_prep_data); i++){ |
| 448 int32_t destLen=0; | 445 int32_t destLen=0; |
| 449 char* dest = NULL; | 446 char* dest = NULL; |
| 450 UErrorCode status = U_ZERO_ERROR; | 447 UErrorCode status = U_ZERO_ERROR; |
| 451 UParseError parseError; | 448 UParseError parseError; |
| 452 srcLen = unescapeData(mixed_prep_data[i], (int32_t)strlen(mixed_prep
_data[i]), src, MAX_BUFFER_SIZE, &status); | 449 srcLen = unescapeData(mixed_prep_data[i], (int32_t)strlen(mixed_prep
_data[i]), src, MAX_BUFFER_SIZE, &status); |
| 453 if(U_FAILURE(status)){ | 450 if(U_FAILURE(status)){ |
| 454 log_err("Conversion of data at index %i failed. Error: %s\n", i,
u_errorName(status)); | 451 log_err("Conversion of data at index %i failed. Error: %s\n", i,
u_errorName(status)); |
| 455 continue; | 452 continue; |
| 456 } | 453 } |
| 457 destLen = nfs4_mixed_prepare(src, srcLen, NULL, 0, &parseError, &sta
tus); | 454 destLen = nfs4_mixed_prepare(src, srcLen, NULL, 0, &parseError, &sta
tus); |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 static void TestStringPrepProfiles(void) { | 751 static void TestStringPrepProfiles(void) { |
| 755 UErrorCode status = U_ZERO_ERROR; | 752 UErrorCode status = U_ZERO_ERROR; |
| 756 const char *profileName = NULL; | 753 const char *profileName = NULL; |
| 757 UChar src[SPREP_PROFILE_TEST_MAX_LENGTH]; | 754 UChar src[SPREP_PROFILE_TEST_MAX_LENGTH]; |
| 758 UChar expected[SPREP_PROFILE_TEST_MAX_LENGTH]; | 755 UChar expected[SPREP_PROFILE_TEST_MAX_LENGTH]; |
| 759 UChar result[SPREP_PROFILE_TEST_MAX_LENGTH]; | 756 UChar result[SPREP_PROFILE_TEST_MAX_LENGTH]; |
| 760 int32_t srcLength, resultLength, expectedLength; | 757 int32_t srcLength, resultLength, expectedLength; |
| 761 int32_t i, testNum = 0; | 758 int32_t i, testNum = 0; |
| 762 UStringPrepProfile *sprep = NULL; | 759 UStringPrepProfile *sprep = NULL; |
| 763 | 760 |
| 764 for (i = 0; i < LENGTHOF(profile_test_case); i++) { | 761 for (i = 0; i < UPRV_LENGTHOF(profile_test_case); i++) { |
| 765 if (uprv_strstr(profile_test_case[i], "RFC")) { | 762 if (uprv_strstr(profile_test_case[i], "RFC")) { |
| 766 if (sprep != NULL) { | 763 if (sprep != NULL) { |
| 767 usprep_close(sprep); | 764 usprep_close(sprep); |
| 768 sprep = NULL; | 765 sprep = NULL; |
| 769 } | 766 } |
| 770 profileName = profile_test_case[i]; | 767 profileName = profile_test_case[i]; |
| 771 sprep = usprep_openByType(getTypeFromProfileName(profileName), &stat
us); | 768 sprep = usprep_openByType(getTypeFromProfileName(profileName), &stat
us); |
| 772 if (U_FAILURE(status)) { | 769 if (U_FAILURE(status)) { |
| 773 log_data_err("Unable to open String Prep Profile with: %s\n", pr
ofileName); | 770 log_data_err("Unable to open String Prep Profile with: %s\n", pr
ofileName); |
| 774 break; | 771 break; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 811 #endif | 808 #endif |
| 812 | 809 |
| 813 /* | 810 /* |
| 814 * Hey, Emacs, please set the following: | 811 * Hey, Emacs, please set the following: |
| 815 * | 812 * |
| 816 * Local Variables: | 813 * Local Variables: |
| 817 * indent-tabs-mode: nil | 814 * indent-tabs-mode: nil |
| 818 * End: | 815 * End: |
| 819 * | 816 * |
| 820 */ | 817 */ |
| OLD | NEW |