X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/374ca955a76ecab1204ca8bfa63ff9238d998416..46f4442e9a5a4f3b98b7c1083586332f6a8a99a4:/icuSources/test/cintltst/spreptst.c diff --git a/icuSources/test/cintltst/spreptst.c b/icuSources/test/cintltst/spreptst.c index 9d82c03b..8a2fa968 100644 --- a/icuSources/test/cintltst/spreptst.c +++ b/icuSources/test/cintltst/spreptst.c @@ -1,7 +1,7 @@ /* ******************************************************************************* * - * Copyright (C) 2003, International Business Machines + * Copyright (C) 2003-2008, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* @@ -37,6 +37,8 @@ static void Test_nfs4_mixed_prep_data(void); static void Test_nfs4_cs_prep(void); static void Test_nfs4_cis_prep(void); static void Test_nfs4_mixed_prep(void); +static void TestBEAMWarning(void); +static void TestCoverage(void); void addUStringPrepTest(TestNode** root) @@ -47,11 +49,19 @@ addUStringPrepTest(TestNode** root) addTest(root, &Test_nfs4_cs_prep, "spreptst/Test_nfs4_cs_prep"); addTest(root, &Test_nfs4_cis_prep, "spreptst/Test_nfs4_cis_prep"); addTest(root, &Test_nfs4_mixed_prep, "spreptst/Test_nfs4_mixed_prep"); + addTest(root, &TestBEAMWarning, "spreptst/TestBEAMWarning"); + addTest(root, &TestCoverage, "spreptst/TestCoverage"); } static void Test_nfs4_cs_prep_data(void){ UErrorCode errorCode = U_ZERO_ERROR; + loadTestData(&errorCode); + if(U_FAILURE(errorCode)) { + log_data_err("Could not load testdata.dat, status = %s\n", u_errorName(errorCode)); + return; + } + log_verbose("Testing nfs4_cs_prep_ci.txt\n"); doStringPrepTest("nfscsi","nfs4_cs_prep_ci.txt", USPREP_DEFAULT, &errorCode); @@ -70,6 +80,12 @@ Test_nfs4_cis_prep_data(void){ static void Test_nfs4_mixed_prep_data(void){ UErrorCode errorCode = U_ZERO_ERROR; + loadTestData(&errorCode); + if(U_FAILURE(errorCode)) { + log_data_err("Could not load testdata.dat, status = %s\n", u_errorName(errorCode)); + return; + } + log_verbose("Testing nfs4_mixed_prep_s.txt\n"); doStringPrepTest("nfsmxs","nfs4_mixed_prep_s.txt", USPREP_DEFAULT, &errorCode); @@ -79,7 +95,7 @@ Test_nfs4_mixed_prep_data(void){ } -static struct ConformanceTestCases +static const struct ConformanceTestCases { const char *comment; const char *in; @@ -290,6 +306,12 @@ unescapeData(const char* src, int32_t srcLen, static void Test_nfs4_cis_prep(void){ int32_t i=0; + UErrorCode loadStatus = U_ZERO_ERROR; + loadTestData(&loadStatus); + if (U_FAILURE(loadStatus)) { + log_data_err("Test could not initialize. Got %s\n", u_errorName(loadStatus)); + return; + } for(i=0;i< (int32_t)(sizeof(conformanceTestCases)/sizeof(conformanceTestCases[0]));i++){ const char* src = conformanceTestCases[i].in; @@ -403,6 +425,13 @@ static const char* mixed_prep_data[] ={ static void Test_nfs4_mixed_prep(void){ + UErrorCode loadStatus = U_ZERO_ERROR; + loadTestData(&loadStatus); + if (U_FAILURE(loadStatus)) { + log_data_err("Test could not initialize. Got %s\n", u_errorName(loadStatus)); + return; + } + { int32_t i=0; char src[MAX_BUFFER_SIZE]; @@ -453,6 +482,13 @@ Test_nfs4_mixed_prep(void){ static void Test_nfs4_cs_prep(void){ + UErrorCode errorCode = U_ZERO_ERROR; + loadTestData(&errorCode); + if(U_FAILURE(errorCode)) { + log_data_err("Could not load testdata.dat, status = %s\n", u_errorName(errorCode)); + return; + } + { /* BiDi checking is turned off */ const char *source = "\\uC138\\uACC4\\uC758\\uBAA8\\uB4E0\\uC0AC\\uB78C\\uB4E4\\uC774\\u0644\\u064A\\u0647\\uD55C\\uAD6D\\uC5B4\\uB97C\\uC774\\uD574\\uD55C\\uB2E4\\uBA74"; @@ -550,6 +586,49 @@ Test_nfs4_cs_prep(void){ } } + + +static void TestBEAMWarning(){ + UErrorCode status = U_ZERO_ERROR; + UParseError parseError; + UStringPrepProfile* profile = NULL; + /* get the test data path */ + const char *testdatapath = NULL; + UChar src =0x0000; + testdatapath = loadTestData(&status); + if(U_FAILURE(status)) { + log_data_err("Could not load testdata.dat, status = %s\n", u_errorName(status)); + return; + } + /* open the profile */ + profile = usprep_open(testdatapath, "nfscis", &status); + usprep_prepare(profile,&src , 0, NULL, 0, USPREP_DEFAULT, &parseError, &status); + + usprep_close(profile); +} + +static void TestCoverage(void) { + UErrorCode status = U_USELESS_COLLATOR_ERROR; + UParseError parseError; + + usprep_open(NULL, NULL, &status); + if (status != U_USELESS_COLLATOR_ERROR) { + log_err("usprep_open didn't react correctly to a bad UErrorCode\n"); + } + usprep_prepare(NULL, NULL, 0, NULL, 0, USPREP_DEFAULT, &parseError, &status); + if (status != U_USELESS_COLLATOR_ERROR) { + log_err("usprep_prepare didn't react correctly to a bad UErrorCode\n"); + } + status = U_ZERO_ERROR; + usprep_prepare(NULL, NULL, 0, NULL, 0, USPREP_DEFAULT, &parseError, &status); + if (status != U_ILLEGAL_ARGUMENT_ERROR) { + log_err("usprep_prepare didn't check its arguments\n"); + } + + /* Don't crash */ + usprep_close(NULL); +} + #endif /*