/******************************************************************** * COPYRIGHT: * Copyright (c) 1997-2001, International Business Machines Corporation and * others. All Rights Reserved. ********************************************************************/ /******************************************************************************** * * File CTSTDEP.C * * Modification History: * Name Description * Ram Viswanadha Creation * * Test for deprecated formatting APIs. * * Note: This test tests all deprecated C API which follow the method of application * complication using preporcessor magic suggested by SRL.Compilation of this test * will fail for every release when U_USE_DEPRECATED_FORMAT_API is set, as a reminder * for updating macros for deprecated APIs and eventual removal of those APIs. ********************************************************************************* */ #ifndef U_USE_DEPRECATED_FORMAT_API #define U_USE_DEPRECATED_FORMAT_API 1 #endif #include "unicode/unum.h" #include "unicode/ucol.h" #include "unicode/udat.h" #include "unicode/ustring.h" #include "unicode/utrans.h" #include "unicode/uchar.h" #include #include "cintltst.h" #include #include static void TestDeprecatedCollationAPI(void); static void TestDeprecatedNumFmtAPI(void); static void TestDeprecatedDateFmtAPI(void); static void TestDeprecatedUErrorCode(void); static void TestDeprecatedUCharScript(void); const static char cnt1[][10] = { "AA", "AC", "AZ", "AQ", "AB", "ABZ", "ABQ", "Z", "ABC", "Q", "B" }; const static char cnt2[][10] = { "DA", "DAD", "DAZ", "MAR", "Z", "DAVIS", "MARK", "DAV", "DAVI" }; void addTestDeprecatedAPI(TestNode** root); void addTestDeprecatedAPI(TestNode** root) { addTest(root, &TestDeprecatedCollationAPI, "ctstdep/TestDeprecatedCollationAPI"); addTest(root, &TestDeprecatedNumFmtAPI, "ctstdep/TestDeprecatedNumFmtAPI"); addTest(root, &TestDeprecatedDateFmtAPI, "ctstdep/TestDeprecatedDateFmtAPI"); addTest(root, &TestDeprecatedDateFmtAPI, "ctstdep/TestDeprecatedUErrorCode"); addTest(root, &TestDeprecatedDateFmtAPI, "ctstdep/TestDeprecatedUCharScript"); } /* *TODO: The ucol_openRules method which does not take UParseError as one of its params * has been deprecated in 2.0 release.Please remove this API by 10/1/2002 */ static void TestDeprecatedCollationAPI(void) { UErrorCode status = U_ZERO_ERROR; UChar temp[90]; UChar t1[90]; UChar t2[90]; UCollator *coll = NULL; uint32_t i = 0, j = 0; uint32_t size = 0; u_uastrcpy(temp, " & Z < ABC < Q < B"); coll = ucol_openRules(temp, u_strlen(temp), UCOL_OFF, UCOL_DEFAULT_STRENGTH, &status); if(U_SUCCESS(status)) { size = sizeof(cnt1)/sizeof(cnt1[0]); for(i = 0; i < size-1; i++) { for(j = i+1; j < size; j++) { UCollationElements *iter; u_uastrcpy(t1, cnt1[i]); u_uastrcpy(t2, cnt1[j]); iter = ucol_openElements(coll, t2, u_strlen(t2), &status); if (U_FAILURE(status)) { log_err("Creation of iterator failed\n"); break; } free(iter); } } } ucol_close(coll); u_uastrcpy(temp, " & Z < DAVIS < MARK