home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 6 / AACD06.ISO / AACD / Programming / ICU / src / icu / source / test / cintltst / cloctst.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-10-19  |  23.4 KB  |  693 lines

  1. /*
  2. *****************************************************************************************
  3. *                                                                                       *
  4. * COPYRIGHT:                                                                            *
  5. *   (C) Copyright Taligent, Inc.,  1996                                                 *
  6. *   (C) Copyright International Business Machines Corporation,  1999                    *
  7. *   Licensed Material - Program-Property of IBM - All Rights Reserved.                  *
  8. *   US Government Users Restricted Rights - Use, duplication, or disclosure             *
  9. *   restricted by GSA ADP Schedule Contract with IBM Corp.                              *
  10. *                                                                                       *
  11. *****************************************************************************************
  12. ********************************************************************************
  13. *
  14. * File CLOCTST.C
  15. *
  16. * Modification History:
  17. *        Name                     Description            
  18. *     Madhu Katragadda            Ported for C API
  19. *********************************************************************************
  20. */
  21. #include "utypes.h"
  22. #include "utypes.h"
  23. #include "cloctst.h"
  24. #include "uloc.h"
  25. #include <stdio.h>
  26. #include <string.h>
  27. #include "ustring.h"
  28. #include "cintltst.h"
  29.  
  30. void PrintDataTable();
  31.  
  32. static char* rawData2[23][5];
  33.  
  34. static UChar*** dataTable=0;
  35. enum {
  36.     ENGLISH = 0,
  37.     FRENCH = 1,
  38.     CROATIAN = 2,
  39.     GREEKS = 3,
  40.     NORWEGIAN = 4,
  41.     MAX_LOCALES = 4
  42. };
  43.  
  44. enum {
  45.     LANG = 0,
  46.     CTRY = 1,
  47.     VAR = 2,
  48.     NAME = 3,
  49.     LANG3 = 4,
  50.     CTRY3 = 5,
  51.     LCID = 6,
  52.     DLANG_EN = 7,
  53.     DCTRY_EN = 8,
  54.     DVAR_EN = 9,
  55.     DNAME_EN = 10,
  56.     DLANG_FR = 11,
  57.     DCTRY_FR = 12,
  58.     DVAR_FR = 13,
  59.     DNAME_FR = 14,
  60.     DLANG_HR = 15,
  61.     DCTRY_HR = 16,
  62.     DVAR_HR = 17,
  63.     DNAME_HR = 18,
  64.     DLANG_EL = 19,
  65.     DCTRY_EL = 20,
  66.     DVAR_EL = 21,
  67.     DNAME_EL = 22
  68. };
  69.  
  70.  
  71. void addLocaleTest(TestNode** root)
  72. {
  73.     setUpDataTable();
  74.     
  75.     addTest(root, &TestBasicGetters, "tsutil/cloctst/TestBasicGetters");
  76.     addTest(root, &TestDisplayNames, "tsutil/cloctst/TestDisplayNames");
  77.     addTest(root, &TestGetAvailableLocales, "tsutil/cloctst/TestGetAvailableLocales");
  78.     addTest(root, &TestDataDirectory, "tsutil/cloctst/TestDataDirectory");
  79.     addTest(root, &TestISOFunctions, "tsutil/cloctst/TestISOFunctions");
  80. }
  81.         
  82.  
  83. /* testing uloc(), uloc_getName(), uloc_getLanguage(), uloc_getVariant(), uloc_getCountry() */
  84. void TestBasicGetters() {
  85.     int32_t i;
  86.     int32_t cap;
  87.     UErrorCode status = U_ZERO_ERROR;
  88.     char *testLocale = 0;
  89.     char *temp = 0, *name = 0;
  90.     log_verbose("Testing Basic Getters\n");
  91.     for (i = 0; i <= MAX_LOCALES; i++) {
  92.         testLocale=(char*)malloc(sizeof(char) * (strlen(rawData2[NAME][i])+1));
  93.         strcpy(testLocale,rawData2[NAME][i]);
  94.         
  95.         log_verbose("Testing   %s  .....\n", testLocale);
  96.         cap=uloc_getLanguage(testLocale, NULL, 0, &status);
  97.         if(status==U_BUFFER_OVERFLOW_ERROR){
  98.             status=U_ZERO_ERROR;
  99.             temp=(char*)malloc(sizeof(char) * (cap+1));
  100.             uloc_getLanguage(testLocale, temp, cap, &status);
  101.         }
  102.         if(U_FAILURE(status)){
  103.             log_err("ERROR: in uloc_getLanguage  %s\n", myErrorName(status));
  104.         }
  105.         if (0 !=strcmp(temp,rawData2[LANG][i]))    {
  106.             log_err("  Language code mismatch: %s versus  %s\n", temp, rawData2[LANG][i]); 
  107.                         
  108.         }
  109.         
  110.         
  111.         cap=uloc_getCountry(testLocale, temp, cap, &status);
  112.         if(status==U_BUFFER_OVERFLOW_ERROR){
  113.             status=U_ZERO_ERROR;
  114.             temp=(char*)realloc(temp, sizeof(char) * (cap+1));
  115.             uloc_getCountry(testLocale, temp, cap, &status);
  116.         }
  117.         if(U_FAILURE(status)){
  118.             log_err("ERROR: in uloc_getCountry  %s\n", myErrorName(status));
  119.         }
  120.         if (0 != strcmp(temp, rawData2[CTRY][i])) {
  121.             log_err(" Country code mismatch:  %s  versus   %s\n", temp, rawData2[CTRY][i]);
  122.             
  123.           }
  124.  
  125.         cap=uloc_getVariant(testLocale, temp, cap, &status);
  126.         if(status==U_BUFFER_OVERFLOW_ERROR){
  127.             status=U_ZERO_ERROR;
  128.             temp=(char*)realloc(temp, sizeof(char) * (cap+1));
  129.             uloc_getVariant(testLocale, temp, cap, &status);
  130.         }
  131.         if(U_FAILURE(status)){
  132.             log_err("ERROR: in uloc_getVariant  %s\n", myErrorName(status));
  133.         }
  134.         if (0 != strcmp(temp, rawData2[VAR][i])) {
  135.             
  136.             log_err("Variant code mismatch:  %s  versus   %s\n", temp, rawData2[VAR][i]);
  137.                         
  138.           }
  139.         
  140.            
  141.         cap=uloc_getName(testLocale, NULL, 0, &status);
  142.         if(status==U_BUFFER_OVERFLOW_ERROR){
  143.             status=U_ZERO_ERROR;
  144.             name=(char*)malloc(sizeof(char) * (cap+1));
  145.             uloc_getName(testLocale, name, cap, &status);
  146.         }
  147.         if(U_FAILURE(status)){
  148.             log_err("ERROR: in uloc_getName   %s\n", myErrorName(status));
  149.         }
  150.         if (0 != strcmp(name, rawData2[NAME][i])){
  151.             log_err(" Mismatch in getName:  %s  versus   %s\n", name, rawData2[NAME][i]);
  152.         }
  153.  
  154.     
  155.         free(temp);
  156.         free(name);
  157.         
  158.     free(testLocale);
  159.     }
  160.   
  161. }
  162. /* testing uloc_getISO3Language(), uloc_getISO3Country(),  */
  163. void TestSimpleResourceInfo() {
  164.  
  165.     int32_t i;
  166.     char* testLocale = 0;
  167.     UChar* expected = 0;
  168.     
  169.     const char* temp;
  170.     testLocale=(char*)malloc(sizeof(char) * 1);
  171.     expected=(UChar*)malloc(sizeof(UChar) * 1);
  172.     
  173.     log_verbose("Testing getISO3Language and getISO3Country\n");
  174.     for (i = 0; i <= MAX_LOCALES; i++) {
  175.         
  176.         testLocale=(char*)realloc(testLocale, sizeof(char) * (u_strlen(dataTable[NAME][i])+1));
  177.         u_austrcpy(testLocale, dataTable[NAME][i]);
  178.              
  179.         log_verbose("Testing   %s ......\n", testLocale);
  180.             
  181.         temp=uloc_getISO3Language(testLocale);
  182.         expected=(UChar*)realloc(expected, sizeof(UChar) * (strlen(temp) + 1));
  183.         u_uastrcpy(expected,temp);
  184.         if (0 != u_strcmp(expected, dataTable[LANG3][i])) {
  185.              log_err("  ISO-3 language code mismatch:  %s versus  %s\n",  austrdup(expected),
  186.                                                             austrdup(dataTable[LANG3][i]));
  187.          } 
  188.         
  189.         temp=uloc_getISO3Country(testLocale);
  190.         expected=(UChar*)realloc(expected, sizeof(UChar) * (strlen(temp) + 1));
  191.         u_uastrcpy(expected,temp);
  192.         if (0 != u_strcmp(expected, dataTable[CTRY3][i])) {
  193.             log_err("  ISO-3 Country code mismatch:  %s versus  %s\n",  austrdup(expected),
  194.                                                             austrdup(dataTable[CTRY3][i]));
  195.         } 
  196.           
  197.     }
  198.     
  199.  free(expected);
  200.  free(testLocale);
  201. }
  202. void TestDisplayNames() 
  203. {
  204.   /* sfb 990721 
  205.      Can't just save a pointer to the default locale.  
  206.      Although the pointer won't change, the contents will, so the
  207.      restore at the end doesn't actually restore the original.
  208.   */
  209.     const char *saveDefault;
  210.     char *defaultLocale;
  211.     
  212.     UErrorCode err = U_ZERO_ERROR;
  213.     
  214.  
  215.     saveDefault = uloc_getDefault();
  216.     defaultLocale = (char*) malloc(strlen(saveDefault) + 1);
  217.     if(defaultLocale == 0) {
  218.       log_err("out of memory");
  219.       return;
  220.     }
  221.     strcpy(defaultLocale, saveDefault);
  222.  
  223.     uloc_setDefault("en_US", &err);
  224.     if (U_FAILURE(err)) {
  225.         log_err("uloc_setDefault returned error code ");
  226.         return;
  227.     }
  228.     
  229.     
  230.     log_verbose("Testing getDisplayName for different locales\n");
  231.     log_verbose("With default = en_US...\n");
  232.    
  233.     log_verbose("  In default locale...\n");
  234.     doTestDisplayNames(" ", DLANG_EN, FALSE);
  235.     log_verbose("  In locale = en_US...\n");
  236.     doTestDisplayNames("en_US", DLANG_EN, FALSE);
  237.     log_verbose("  In locale = fr_FR....\n");
  238.     doTestDisplayNames("fr_FR", DLANG_FR, FALSE);
  239.     log_verbose("  In locale = hr_HR...\n");
  240.     doTestDisplayNames("hr_HR", DLANG_HR, FALSE);
  241.     log_verbose("  In locale = gr_EL..\n");
  242.     doTestDisplayNames("el_GR", DLANG_EL, FALSE);
  243.  
  244.    uloc_setDefault("fr_FR", &err);
  245.     if (U_FAILURE(err)) {
  246.         log_err("Locale::setDefault returned error code  %s\n", myErrorName(err));
  247.         return;
  248.     }
  249.     
  250.     log_verbose("With default = fr_FR...\n");
  251.     
  252.     log_verbose("  In default locale...\n");
  253.     doTestDisplayNames(" ", DLANG_FR, TRUE);
  254.     log_verbose("  In locale = en_US...\n");
  255.     doTestDisplayNames("en_US", DLANG_EN, TRUE);
  256.     log_verbose("  In locale = fr_FR....\n");
  257.     doTestDisplayNames("fr_FR", DLANG_FR, TRUE);
  258.     log_verbose("  In locale = hr_HR...\n");
  259.     doTestDisplayNames("hr_HR", DLANG_HR, TRUE);
  260.     log_verbose("  In locale = el_GR...\n");
  261.     doTestDisplayNames("el_GR", DLANG_EL, TRUE);
  262.  
  263.     uloc_setDefault(defaultLocale, &err);
  264.     if (U_FAILURE(err)) {
  265.         log_err("Locale::setDefault returned error code  %s\n", myErrorName(err));
  266.         return;
  267.     }
  268.  
  269.     free(defaultLocale);
  270.  
  271. }
  272.  
  273.  
  274. /* test for uloc_getAvialable()  and uloc_countAvilable()*/
  275. void TestGetAvailableLocales()
  276. {
  277.  
  278.     const char *locList;
  279.     int32_t locCount,i;
  280.     
  281.     log_verbose("Testing the no of avialable locales\n");
  282.     locCount=uloc_countAvailable();
  283.     if (locCount == 0)
  284.         log_err("countAvailable() returned an empty list!\n");
  285.     
  286.     /* use something sensible w/o hardcoding the count */
  287.     else if(locCount < 0){ 
  288.         log_err("countAvailable() returned a wrong value!= %d\n", locCount);
  289.     }
  290.     else{
  291.         log_info("Number of locales returned = %d\n", locCount);
  292.         
  293.     }
  294.     for(i=0;i<locCount;i++){
  295.         locList=uloc_getAvailable(i);
  296.         
  297.         log_verbose(" %s\n", locList);
  298.     }
  299. }
  300.  
  301. /* test for uloc_getDataDirectory, uloc_setDataDirectory, uloc_getISO3Language */
  302. void TestDataDirectory()
  303. {
  304.  
  305.     char            oldDirectory[80];
  306.     const char     *temp,*testValue1,*testValue2,*testValue3;
  307.     UErrorCode       err = U_ZERO_ERROR;
  308.     const char path[40] ="d:\\icu\\source\\test\\intltest\\" ; /*give the required path */
  309.  
  310.     
  311.     log_verbose("Testing getDataDirectory()\n");
  312.     temp = uloc_getDataDirectory();
  313.     strcpy(oldDirectory, temp);
  314.         
  315.     testValue1=uloc_getISO3Language("en_US");
  316.     log_verbose("first fetch of language retrieved  %s\n", testValue1);
  317.     
  318.     if (0 != strcmp(testValue1,"eng")){
  319.         log_err("Initial check of ISO3 language failed: expected \"eng\", got  %s \n", testValue1);
  320.         
  321.     }
  322.  
  323.     /*defining the path for DataDirectory */
  324.     log_verbose("Testing setDataDirectory\n");
  325.     uloc_setDataDirectory( path );
  326.     if(strcmp(path, uloc_getDataDirectory())==0)
  327.         log_verbose("setDataDirectory working fine\n");
  328.     else
  329.         log_err("Error in setDataDirectory. Directory not set correctly");
  330.         
  331.     testValue2=uloc_getISO3Language("en_US");
  332.     log_verbose("second fetch of language retrieved  %s \n", testValue2);
  333.         
  334.     uloc_setDataDirectory(oldDirectory);
  335.     testValue3=uloc_getISO3Language("en_US");
  336.     log_verbose("third fetch of language retrieved  %s \n", testValue3);
  337.         
  338.     if (0 != strcmp(testValue3,"eng")) {
  339.        log_err("get/setDataDirectory() failed: expected \"eng\", got \" %s  \" \n", testValue3);
  340.        
  341.        }
  342.  
  343.     
  344. }
  345.  
  346.  
  347.  
  348. /*=========================================================== */
  349.  
  350. void doTestDisplayNames(const char* inLocale,
  351.                                     int32_t compareIndex,
  352.                                     int32_t defaultIsFrench)
  353. {
  354.     UErrorCode status = U_ZERO_ERROR;
  355.     int32_t i;
  356.     int32_t maxresultsize;
  357.     
  358.     char* testLocale;
  359.    
  360.     
  361.     UChar  *testLang  = 0;
  362.     UChar  *testCtry = 0;
  363.     UChar  *testVar = 0;
  364.     UChar  *testName = 0;
  365.    
  366.  
  367.     UChar*  expectedLang = 0;
  368.     UChar*  expectedCtry = 0;
  369.     UChar*  expectedVar = 0;
  370.     UChar*  expectedName = 0;
  371.     char temp[5];
  372.     const char* defaultDefaultLocale=" ";
  373.     
  374.     
  375.        
  376.     uloc_getLanguage(uloc_getDefault(), temp, 5, &status);
  377.     if(U_FAILURE(status)){
  378.         log_err("ERROR: in getDefault  %s \n", myErrorName(status));
  379.     }
  380.     if (defaultIsFrench && 0 != strcmp(temp, "fr"))    {
  381.         log_err("Default locale should be French, but it's really  %s\n", temp);
  382.         
  383.     }
  384.     else if (!defaultIsFrench && 0 != strcmp(temp, "en")){  
  385.     
  386.         log_err("Default locale should be English, but it's really  %s\n", temp);
  387.         
  388.     }
  389.  
  390.    testLocale = (char*)malloc(sizeof(char)   * 1);
  391.   
  392.    
  393.    for(i=0;i<MAX_LOCALES; ++i)
  394.    {
  395.        testLocale=(char*)realloc(testLocale, sizeof(char) * (u_strlen(dataTable[NAME][i])+1));
  396.        u_austrcpy(testLocale,dataTable[NAME][i]);
  397.     
  398.         log_verbose("Testing.....  %s\n", testLocale);
  399.                 
  400.         if (strcmp(inLocale, defaultDefaultLocale)==0) {
  401.             maxresultsize=0;
  402.             maxresultsize=uloc_getDisplayLanguage(testLocale, NULL, NULL, maxresultsize, &status);
  403.             if(status==U_BUFFER_OVERFLOW_ERROR)
  404.             {
  405.                 status=U_ZERO_ERROR;
  406.                 testLang=(UChar*)malloc(sizeof(UChar) * (maxresultsize + 1));
  407.                 uloc_getDisplayLanguage(testLocale, NULL, testLang, maxresultsize, &status);
  408.  
  409.  
  410.             }
  411.             if(U_FAILURE(status)){
  412.                     log_err("Error in getDisplayLanguage()  %s\n", myErrorName(status));
  413.                     
  414.             }
  415.             maxresultsize=0;
  416.             maxresultsize=uloc_getDisplayCountry(testLocale, NULL, NULL, maxresultsize, &status);
  417.             if(status==U_BUFFER_OVERFLOW_ERROR)
  418.             {
  419.                 status=U_ZERO_ERROR;
  420.                 testCtry=(UChar*)malloc(sizeof(UChar) * (maxresultsize + 1));
  421.                 uloc_getDisplayCountry(testLocale, NULL, testCtry, maxresultsize, &status);
  422.             }
  423.             if(U_FAILURE(status)){
  424.                     log_err("Error in getDisplayCountry()  %s\n", myErrorName(status));
  425.                     
  426.             }
  427.             
  428.             maxresultsize=0;
  429.             maxresultsize=uloc_getDisplayVariant(testLocale, NULL, NULL, maxresultsize, &status);
  430.             if(status==U_BUFFER_OVERFLOW_ERROR)
  431.             {
  432.                 status=U_ZERO_ERROR;
  433.                 testVar=(UChar*)malloc(sizeof(UChar) * (maxresultsize+1));
  434.                 uloc_getDisplayVariant(testLocale, NULL, testVar, maxresultsize, &status);
  435.             }
  436.             if(U_FAILURE(status)){
  437.                     log_err("Error in getDisplayVariant()  %s\n", myErrorName(status));
  438.                 
  439.             }
  440.             maxresultsize=0;
  441.             maxresultsize=uloc_getDisplayName(testLocale, NULL, NULL, maxresultsize, &status);
  442.             if(status==U_BUFFER_OVERFLOW_ERROR)
  443.             {
  444.                 status=U_ZERO_ERROR;
  445.                 testName=(UChar*)malloc(sizeof(UChar) * (maxresultsize+1));
  446.                 uloc_getDisplayName(testLocale, NULL, testName, maxresultsize, &status);
  447.             }
  448.             if(U_FAILURE(status)){
  449.                     log_err("Error in getDisplayName()  %s\n", myErrorName(status));
  450.                 
  451.             }
  452.            
  453.         }
  454.         else {
  455.             maxresultsize=0;
  456.             maxresultsize=uloc_getDisplayLanguage(testLocale, inLocale, NULL, maxresultsize, &status);
  457.             if(status==U_BUFFER_OVERFLOW_ERROR)
  458.             {
  459.                 status=U_ZERO_ERROR;
  460.                 testLang=(UChar*)malloc(sizeof(UChar) * (maxresultsize+1));
  461.                 uloc_getDisplayLanguage(testLocale, inLocale, testLang, maxresultsize, &status);
  462.             }
  463.             if(U_FAILURE(status)){
  464.                 log_err("Error in getDisplayLanguage()  %s\n", myErrorName(status));
  465.             }
  466.  
  467.             maxresultsize=0;
  468.             maxresultsize=uloc_getDisplayCountry(testLocale, inLocale, NULL, maxresultsize, &status);
  469.             if(status==U_BUFFER_OVERFLOW_ERROR)
  470.             {
  471.                 status=U_ZERO_ERROR;
  472.                 testCtry=(UChar*)malloc(sizeof(UChar) * (maxresultsize+1));
  473.                 uloc_getDisplayCountry(testLocale, inLocale, testCtry, maxresultsize, &status);
  474.             }
  475.             if(U_FAILURE(status)){
  476.                 log_err("Error in getDisplayCountry()  %s\n", myErrorName(status));
  477.             }
  478.             
  479.             maxresultsize=0;
  480.             maxresultsize=uloc_getDisplayVariant(testLocale, inLocale, NULL, maxresultsize, &status);
  481.             if(status==U_BUFFER_OVERFLOW_ERROR)
  482.             {
  483.                 status=U_ZERO_ERROR;
  484.                 testVar=(UChar*)malloc(sizeof(UChar) * (maxresultsize+1));
  485.                 uloc_getDisplayVariant(testLocale, inLocale, testVar, maxresultsize, &status);
  486.             }
  487.             if(U_FAILURE(status)){
  488.                     log_err("Error in getDisplayVariant()  %s\n", myErrorName(status));
  489.             }
  490.             
  491.             maxresultsize=0;
  492.             maxresultsize=uloc_getDisplayName(testLocale, inLocale, NULL, maxresultsize, &status);
  493.             if(status==U_BUFFER_OVERFLOW_ERROR)
  494.             {
  495.                 status=U_ZERO_ERROR;
  496.                 testName=(UChar*)malloc(sizeof(UChar) * (maxresultsize+1));
  497.                 uloc_getDisplayName(testLocale, inLocale, testName, maxresultsize, &status);
  498.             }
  499.             if(U_FAILURE(status)){
  500.                 log_err("Error in getDisplayName()  %s\n", myErrorName(status));
  501.             }
  502.  
  503.         }
  504.     
  505.         expectedLang=dataTable[compareIndex][i];
  506.         if(u_strlen(expectedLang) == 0 && defaultIsFrench)  
  507.             expectedLang=dataTable[DLANG_FR][i];
  508.         if(u_strlen(expectedLang)== 0)
  509.             expectedLang=dataTable[DLANG_EN][i];
  510.  
  511.     
  512.         expectedCtry=dataTable[compareIndex + 1][i];
  513.         if(u_strlen(expectedCtry) == 0 && defaultIsFrench)
  514.             expectedCtry=dataTable[DCTRY_FR][i];
  515.         if(u_strlen(expectedCtry)== 0)
  516.             expectedCtry=dataTable[DCTRY_EN][i];    
  517.    
  518.         expectedVar=dataTable[compareIndex + 2][i];
  519.         if(u_strlen(expectedVar) == 0 && defaultIsFrench)
  520.             expectedVar=dataTable[DVAR_FR][i];
  521.         if(u_strlen(expectedCtry)== 0)
  522.             expectedVar=dataTable[DVAR_EN][i];
  523.         
  524.         
  525.         expectedName=dataTable[compareIndex + 3][i];
  526.         if(u_strlen(expectedName) ==0 && defaultIsFrench)
  527.             expectedName=dataTable[DNAME_FR][i];
  528.         if(u_strlen(expectedName) == 0)
  529.             expectedName=dataTable[DNAME_EN][i];
  530.        
  531.         
  532.      if (0 !=u_strcmp(testLang,expectedLang))  {
  533.             log_err(" Display Language mismatch: %s  versus  %s\n", austrdup(testLang), austrdup(expectedLang));
  534.             
  535.           }
  536.         
  537.         if (0 != u_strcmp(testCtry,expectedCtry))   {
  538.             log_err(" Display Country mismatch: %s  versus  %s\n", austrdup(testCtry), austrdup(expectedCtry));
  539.             
  540.           }
  541.         
  542.         if (0 != u_strcmp(testVar,expectedVar))    {
  543.             log_err(" Display Variant mismatch: %s  versus  %s\n", austrdup(testVar), austrdup(expectedVar));
  544.             
  545.           }
  546.        
  547.         if(0 != u_strcmp(testName, expectedName))    {    
  548.             log_err(" Display Name mismatch: %s  versus  %s\n", austrdup(testName), austrdup(expectedName));
  549.         }
  550.        
  551.     free(testName);
  552.     free(testLang);
  553.     free(testCtry);
  554.     free(testVar);
  555.  
  556.     }
  557.     free(testLocale);
  558. }
  559. /* test for uloc_getISOLanguages, uloc_getISOCountries */
  560. void TestISOFunctions()
  561. {
  562.  
  563.  
  564.  
  565.     int32_t count  = 0;
  566.     
  567.     bool_t done = FALSE;
  568.     
  569.     const char* const* str=uloc_getISOLanguages();
  570.     const char* const* str1=uloc_getISOCountries();
  571.     /*  test getISOLanguages*/
  572.     count = 0;
  573.     done = FALSE;
  574.     /*str=uloc_getISOLanguages(); */
  575.     log_verbose("Testing ISO Languages: \n");
  576.     
  577.     while(!done){
  578.         
  579.         if(*(str+count++) == 0)
  580.     
  581.             done = TRUE;
  582.                 
  583.         
  584.     }
  585.     count--;
  586.     if(count!=142)
  587.         
  588.         log_err("There is an error in getISOLanguages %d\n", count);
  589.     
  590.     log_verbose("Testing ISO Countries");
  591.     count=0;
  592.     done=FALSE;
  593.     while(!done)
  594.     {
  595.         if(*(str1 + count++)==0)
  596.             done=TRUE;
  597.             
  598.     
  599.     }
  600.     count--;
  601.     if(count!=239)
  602.         log_err("There is an error in getISOCountries %d \n", count);
  603.     
  604.   
  605. }
  606.  
  607.  
  608.  
  609. /*---------------------------------------------------
  610.   table of valid data
  611.  --------------------------------------------------- */
  612.  
  613.  
  614. static  char* rawData2[23][5] = {
  615.     /* language code */
  616.     {   "en",   "fr",   "hr",   "el",   "no"    },
  617.     /* country code */
  618.     {   "US",   "FR",   "HR",   "GR",   "NO"    },
  619.     /* variant code */
  620.     {   "",     "",     "",     "",     "NY"    },
  621.     /* full name */
  622.     {   "en_US",    "fr_FR",    "hr_HR",    "el_GR",    "no_NO_NY"  },
  623.     /* ISO-3 language */
  624.     {   "eng",  "fra",  "hrv",  "ell",  "nor"   },
  625.     /* ISO-3 country */
  626.     {   "USA",  "FRA",  "HRV",  "GRC",  "NOR"   },
  627.     /* LCID (not currently public) */
  628.     {   "409", "40c", "41a", "408", "814"  },
  629.  
  630.     /* display langage (English) */
  631.     {   "English",  "French",   "Croatian", "Greek",    "Norwegian" },
  632.     /* display country (English) */
  633.     {   "United States",    "France",   "Croatia",  "Greece",   "Norway"    },
  634.     /* display variant (English) */
  635.     {   "",     "",     "",     "",     "Nynorsk"    },
  636.     /* display name (English) */
  637.     {   "English (United States)", "French (France)", "Croatian (Croatia)", "Greek (Greece)", "Norwegian (Norway, Nynorsk)" },
  638.  
  639.     /* display langage (French) */
  640.     {   "anglais",  "français",   "", "grec",    "norvégien" },
  641.     /* display country (French) */
  642.     {   "États-Unis",    "France",   "",  "Grèce",   "Norvège"    },
  643.     /* display variant (French) */
  644.     {   "",     "",     "",     "",     "Nynorsk"    },
  645.     /* display name (French) */
  646.     {   "anglais (États-Unis)", "français (France)", "", "grec (Grèce)", "norvégien (Norvège, Nynorsk)" },
  647.  
  648.     /* display langage (Croatian) */
  649.     {   "",  "", "hrvatski", "",    "" },
  650.     /* display country (Croatian)  */
  651.     {   "",    "",   "Hrvatska",  "",   ""    },
  652.     /* display variant (Croatian) */
  653.     {   "",     "",     "",     "",     ""    },
  654.     /* display name (Croatian) */
  655.     {   "", "", "hrvatski (Hrvatska)", "", "" },
  656.  
  657.     /* display langage (Greek) [actual values listed below] */
  658.     {   "",  "", "", "",    "" },
  659.     /* display country (Greek) [actual values listed below] */
  660.     {   "",    "",   "",  "",   ""    },
  661.     /* display variant (Greek) */
  662.     {   "",     "",     "",     "",     ""    },
  663.     /* display name (Greek) [actual values listed below] */
  664.     {   "", "", "", "", "" }
  665. };
  666.  
  667. static UChar greekDisplayLanguage[] = { 0x03b5, 0x03bb, 0x03bb, 0x03b7, 0x03bd, 0x03b9, 0x03ba, 0x03ac, 0 };
  668. static UChar greekDisplayCountry[] = { 0x0395, 0x03bb, 0x03bb, 0x03ac, 0x03b4, 0x03b1, 0 };
  669. static UChar greekDisplayName[] = { 0x03b5, 0x03bb, 0x03bb, 0x03b7, 0x03bd, 0x03b9, 0x03ba,
  670.     0x03ac, ' ', '(', 0x0395, 0x03bb, 0x03bb, 0x03ac, 0x03b4, 0x03b1, ')', 0 };
  671.     
  672.  
  673. void setUpDataTable()
  674. {
  675.     int32_t i,j;
  676.     dataTable = calloc(sizeof(UChar**),23);
  677.  
  678.         for (i = 0; i < 23; i++) {
  679.           dataTable[i] = calloc(sizeof(UChar*),5);
  680.             for (j = 0; j < 5; j++){
  681.                 dataTable[i][j] = (UChar*) malloc(sizeof(UChar)*(strlen(rawData2[i][j])+1));
  682.                 u_uastrcpy(dataTable[i][j],rawData2[i][j]);
  683.             }
  684.         }
  685.         dataTable[DLANG_EL][GREEKS]=(UChar*)realloc(dataTable[DLANG_EL][GREEKS],sizeof(UChar)*(u_strlen(greekDisplayLanguage)+1)); 
  686.     u_strncpy(dataTable[DLANG_EL][GREEKS],greekDisplayLanguage,8);
  687.         dataTable[DCTRY_EL][GREEKS]=(UChar*)realloc(dataTable[DCTRY_EL][GREEKS],sizeof(UChar)*(u_strlen(greekDisplayCountry)+1));
  688.     u_strncpy(dataTable[DCTRY_EL][GREEKS],greekDisplayCountry,6);
  689.         dataTable[DNAME_EL][GREEKS]=(UChar*)realloc(dataTable[DNAME_EL][GREEKS],sizeof(UChar)*(u_strlen(greekDisplayName)+1));        
  690.     u_strncpy(dataTable[DNAME_EL][GREEKS],greekDisplayName,17);
  691.     
  692. }
  693.