home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 6 / AACD06.ISO / AACD / Programming / ICU / src / icu / source / test / cintltst / cg7coll.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-10-19  |  17.3 KB  |  420 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 CG7COLL.C
  15. *
  16. * Modification History:
  17. *        Name                     Description            
  18. *     Madhu Katragadda            Ported for C API
  19. *********************************************************************************
  20. /**
  21.  * G7CollationTest is a third level test class.  This test performs the examples 
  22.  * mentioned on the Taligent international demos web site.  
  23.  * Sample Rules: & Z < p , P 
  24.  * Effect :  Making P sort after Z.
  25.  *
  26.  * Sample Rules: & c < ch , cH, Ch, CH 
  27.  * Effect : As well as adding sequences of characters that act as a single character (this is
  28.  * known as contraction), you can also add characters that act like a sequence of
  29.  * characters (this is known as expansion).  
  30.  * 
  31.  * Sample Rules: & Question'-'mark ; '?' & Hash'-'mark ; '#' & Ampersand ; '&' 
  32.  * Effect : Expansion and contraction can actually be combined.  
  33.  * 
  34.  * Sample Rules: & aa ; a'-' & ee ; e'-' & ii ; i'-' & oo ; o'-' & uu ; u'-'
  35.  * Effect : sorted sequence as the following,
  36.  * aardvark  
  37.  * a-rdvark  
  38.  * abbot  
  39.  * coop  
  40.  * co-p  
  41.  * cop 
  42.  */
  43. #include "utypes.h"
  44. #include "ucol.h"
  45. #include "uloc.h"
  46. #include "cintltst.h"
  47. #include "cg7coll.h"
  48. #include "ccolltst.h"
  49. #include "ustring.h"
  50. #include <string.h>
  51. #include <stdio.h>
  52. #include <memory.h>
  53.  
  54.  
  55. const char* locales[8] = {
  56.         "en_US",
  57.         "en_GB",
  58.         "en_CA",
  59.         "fr_FR",
  60.         "fr_CA",
  61.         "de_DE",
  62.         "it_IT",
  63.         "ja_JP"
  64. };
  65.  
  66.  
  67.  
  68. const static UChar testCases[][MAX_TOKEN_LEN] = {
  69.     { 0x0062 /*'b'*/, 0x006c /*'l'*/, 0x0061 /*'a'*/, 0x0062 /*'c'*/, 0x006b /*'k'*/, 
  70.         0x002d /*'-'*/,  0x0062 /*'b'*/, 0x0069 /*'i'*/, 0x0072 /*'r'*/, 0x0064 /*'d'*/, 0x0073/*'s'*/, 0x0000},  /* 0 */
  71.     { 0x0050 /*'P'*/, 0x0061 /*'a'*/, 0x0074/*'t'*/, 0x0000},                                                    /* 1 */
  72.     { 0x0070 /*'p'*/, 0x00E9, 0x0063 /*'c'*/, 0x0068 /*'h'*/, 0x00E9, 0x0000},                                    /* 2 */
  73.     { 0x0070 /*'p'*/, 0x00EA, 0x0063 /*'c'*/, 0x0068 /*'h'*/, 0x0065 /*'e'*/, 0x0000},                           /* 3 */
  74.     { 0x0070 /*'p'*/, 0x00E9, 0x0063 /*'c'*/, 0x0068 /*'h'*/, 0x0065 /*'e'*/, 0x0072 /*'r'*/, 0x0000},            /* 4 */
  75.     { 0x0070 /*'p'*/, 0x00EA, 0x0063 /*'c'*/, 0x0068 /*'h'*/, 0x0065 /*'e'*/, 0x0072 /*'r'*/, 0x0000},            /* 5 */
  76.     { 0x0054 /*'T'*/, 0x006f /*'o'*/, 0x0064 /*'d'*/, 0x0000},                                                    /* 6 */
  77.     { 0x0054 /*'T'*/, 0x00F6, 0x006e /*'n'*/, 0x0065 /*'e'*/, 0x0000},                                            /* 7 */
  78.     { 0x0054 /*'T'*/, 0x006f /*'o'*/, 0x0066 /*'f'*/, 0x0075 /*'u'*/, 0x0000},                                   /* 8 */
  79.     {  0x0062 /*'b'*/, 0x006c /*'l'*/, 0x0061 /*'a'*/, 0x0062 /*'c'*/, 0x006b /*'k'*/, 
  80.         0x0062 /*'b'*/, 0x0069 /*'i'*/, 0x0072 /*'r'*/, 0x0064 /*'d'*/, 0x0073 /*'s'*/, 0x0000},                    /* 9 */
  81.     { 0x0054 /*'T'*/, 0x006f /*'o'*/, 0x006e /*'n'*/, 0x0000},                                                    /* 10 */
  82.     { 0x0050  /*'P'*/, 0x0041 /*'A'*/, 0x0054 /*'T'*/, 0x0000},                                                    /* 11 */
  83.     { 0x0062 /*'b'*/, 0x006c /*'l'*/, 0x0061 /*'a'*/, 0x0062 /*'c'*/, 0x006b /*'k'*/, 
  84.       0x0062  /*'b'*/, 0x0069 /*'i'*/, 0x0072 /*'r'*/, 0x0064 /*'d'*/, 0x0000},                                    /* 12 */
  85.     { 0x0062 /*'b'*/, 0x006c /*'l'*/, 0x0061 /*'a'*/, 0x0062 /*'c'*/, 0x006b /*'k'*/, 
  86.         0x002d /*'-'*/,  0x0062 /*'b'*/, 0x0069 /*'i'*/, 0x0072 /*'r'*/, 0x0064 /*'d'*/, 0x0000},                /* 13 */
  87.     {0x0070 /*'p'*/, 0x0061 /*'a'*/, 0x0074 /*'t'*/, 0x0000},                                                    /* 14 */
  88.     /* Additional tests */
  89.     { 0x0063 /*'c'*/, 0x007a /*'z'*/, 0x0061 /*'a'*/, 0x0072 /*'r'*/, 0x0000 },                                 /* 15 */
  90.     { 0x0063 /*'c'*/, 0x0068 /*'h'*/, 0x0075 /*'u'*/, 0x0072 /*'r'*/, 0x006f /*'o'*/, 0x0000 },                  /* 16 */
  91.     { 0x0063 /*'c'*/, 0x0061 /*'a'*/, 0x0074 /*'t'*/, 0x000 },                                                    /* 17 */ 
  92.     { 0x0064 /*'d'*/, 0x0061 /*'a'*/, 0x0072 /*'r'*/, 0x006e /*'n'*/, 0x0000 },                                 /* 18 */
  93.     { 0x003f /*'?'*/, 0x0000 },                                                                                /* 19 */
  94.     { 0x0071 /*'q'*/, 0x0075 /*'u'*/, 0x0069 /*'i'*/, 0x0063 /*'c'*/, 0x006b /*'k'*/, 0x0000 },                  /* 20 */
  95.     { 0x0023 /*'#'*/, 0x0000 },                                                                                /* 21 */
  96.     { 0x0026 /*'&'*/, 0x0000 },                                                                                /* 22 */
  97.     { 0x0061 /*'a'*/, 0x0061 /*'a'*/, 0x0072 /*'r'*/, 0x0064 /*'d'*/, 0x0076 /*'v'*/, 0x0061 /*'a'*/, 
  98.                 0x0072/*'r'*/, 0x006b/*'k'*/, 0x0000},                                                        /* 23 */
  99.     {  0x0061 /*'a'*/, 0x002d /*'-'*/, 0x0072 /*'r'*/, 0x0064 /*'d'*/, 0x0076 /*'v'*/, 0x0061 /*'a'*/, 
  100.                 0x0072/*'r'*/, 0x006b/*'k'*/, 0x0000},                                                        /* 24 */
  101.     { 0x0061 /*'a'*/, 0x0062 /*'b'*/, 0x0062 /*'b'*/, 0x006f /*'o'*/, 0x0074 /*'t'*/, 0x0000},                   /* 25 */
  102.     { 0x0063 /*'c'*/, 0x006f /*'o'*/, 0x006f /*'o'*/, 0x0070 /*'p'*/, 0x0000},                                 /* 26 */
  103.     { 0x0063 /*'c'*/, 0x006f /*'o'*/, 0x002d /*'-'*/, 0x0070 /*'p'*/, 0x0000},                                 /* 27 */
  104.     { 0x0063 /*'c'*/, 0x006f  /*'o'*/, 0x0070 /*'p'*/, 0x0000},                                                /* 28 */
  105.     { 0x007a /*'z'*/, 0x0065  /*'e'*/, 0x0062 /*'b'*/, 0x0072 /*'r'*/, 0x0061 /*'a'*/, 0x0000}                    /* 29 */
  106. };
  107.  
  108. const static int32_t results[TESTLOCALES][TOTALTESTSET] = {
  109.     { 12, 13, 9, 0, 14, 1, 11, 2, 3, 4, 5, 6, 8, 10, 7, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31 }, /* en_US */
  110.     { 12, 13, 9, 0, 14, 1, 11, 2, 3, 4, 5, 6, 8, 10, 7, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31 }, /* en_GB */
  111.     { 12, 13, 9, 0, 14, 1, 11, 2, 3, 4, 5, 6, 8, 10, 7, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31 }, /* en_CA */
  112.     { 12, 13, 9, 0, 14, 1, 11, 3, 2, 4, 5, 6, 8, 10, 7, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31 }, /* fr_FR */
  113.     { 12, 13, 9, 0, 14, 1, 11, 3, 2, 4, 5, 6, 8, 10, 7, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31 }, /* fr_CA */
  114.     { 12, 13, 9, 0, 14, 1, 11, 2, 3, 4, 5, 6, 8, 10, 7, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31 }, /* de_DE */
  115.     { 12, 13, 9, 0, 14, 1, 11, 2, 3, 4, 5, 6, 8, 10, 7, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31 }, /* it_IT */
  116.     { 12, 13, 9, 0, 14, 1, 11, 2, 3, 4, 5, 6, 8, 10, 7, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31 }, /* ja_JP */
  117.     /* new table collation with rules "& Z < p, P"  loop to FIXEDTESTSET */
  118.     { 12, 13, 9, 0, 6, 8, 10, 7, 14, 1, 11, 2, 3, 4, 5, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31 }, 
  119.     /* new table collation with rules "& C < ch , cH, Ch, CH " loop to TOTALTESTSET */
  120.     { 19, 22, 21, 23, 25, 24, 12, 13, 9, 0, 17, 26, 28, 27, 15, 16, 18, 14, 1, 11, 2, 3, 4, 5, 20, 6, 8, 10, 7, 29 },
  121.     /* new table collation with rules "& Question-mark ; ? & Hash-mark ; # & Ampersand ; '&'  " loop to TOTALTESTSET */
  122.     { 23, 25, 22, 24, 12, 13, 9, 0, 17, 16, 26, 28, 27, 15, 18, 21, 14, 1, 11, 2, 3, 4, 5, 19, 20, 6, 8, 10, 7, 29 },
  123.     /* analogous to Japanese rules " & aa ; a- & ee ; e- & ii ; i- & oo ; o- & uu ; u- " */  /* loop to TOTALTESTSET */
  124.     { 19, 22, 21, 23, 24, 25, 12, 13, 9, 0, 17, 16, 26, 27, 28, 15, 18, 14, 1, 11, 2, 3, 4, 5, 20, 6, 8, 10, 7, 29 }
  125. };
  126. UChar* 
  127. my_strncpy(UChar     *dst, 
  128.      const UChar     *src, 
  129.      int32_t     n) 
  130. {
  131.   UChar *anchor = dst;     /* save the start of result string */
  132.   
  133.   if (!n) return dst;
  134.   while(n--)
  135.       *dst++ = *src++;
  136.   *dst = 0x0000;
  137.   return anchor;
  138. }
  139.  
  140. UChar* 
  141. my_strcat(UChar     *dst, 
  142.      const UChar     *src,
  143.      int32_t n)
  144. {
  145.   UChar *anchor = dst;       /* save a pointer to start of dst */
  146.   
  147.   if (!n) return dst;
  148.  
  149.   dst += n;
  150.   while (*src != 0x0000) 
  151.       *dst++ = *src++;
  152.   *dst = 0x0000;
  153.   
  154.   return anchor;
  155. }
  156. void addRuleBasedCollTest(TestNode** root)
  157. {
  158.     addTest(root, &TestG7Locales, "tscoll/cg7coll/TestG7Locales");
  159.     addTest(root, &TestDemo1, "tscoll/cg7coll/TestDemo1");
  160.     addTest(root, &TestDemo2, "tscoll/cg7coll/TestDemo2");
  161.     addTest(root, &TestDemo3, "tscoll/cg7coll/TestDemo3");
  162.     addTest(root, &TestDemo4, "tscoll/cg7coll/TestDemo4");
  163.  
  164.     
  165. }
  166. void doTest(UCollator *myCollation, const UChar source[], const UChar target[], UCollationResult result)
  167. {
  168.     int32_t sortklen, temp;
  169.     UCollationResult compareResult, keyResult;
  170.     uint8_t *sortKey1, *sortKey2;
  171.     
  172.     compareResult = ucol_strcoll(myCollation, source, u_strlen(source), target, u_strlen(target));
  173.     
  174.     sortklen=ucol_getSortKey(myCollation, source, u_strlen(source),  NULL, 0);
  175.     sortKey1=(uint8_t*)malloc(sizeof(uint8_t) * (sortklen+1));
  176.     ucol_getSortKey(myCollation, source, u_strlen(source), sortKey1, sortklen+1);
  177.     
  178.     sortklen=ucol_getSortKey(myCollation, target, u_strlen(target),  NULL, 0);
  179.     sortKey2=(uint8_t*)malloc(sizeof(uint8_t) * (sortklen+1));
  180.     ucol_getSortKey(myCollation, target, u_strlen(target), sortKey2, sortklen+1);
  181.     
  182.  
  183.     temp= memcmp(sortKey1, sortKey2, sortklen);
  184.     if(temp < 0) keyResult=UCOL_LESS;
  185.     else if(temp > 0) keyResult= UCOL_GREATER;
  186.     else keyResult = UCOL_EQUAL;
  187.     reportCResult( source, target, sortKey1, sortKey2, compareResult, keyResult, result );
  188. }
  189.  
  190. void TestG7Locales()
  191. {
  192.     UCollator *myCollation, *tblColl1;
  193.     UErrorCode status = U_ZERO_ERROR;
  194.     const UChar *defRules;
  195.     int32_t i, rlen, j, n;
  196.     log_verbose("Testing  ucol_openRules for all the locales\n");
  197.     for (i = 0; i < 8; i++)
  198.     {
  199.         status = U_ZERO_ERROR;
  200.         myCollation = ucol_open(locales[i], &status);
  201.         if (U_FAILURE(status))
  202.         {
  203.             log_err("Error in creating collator in %s:  %s\n", locales[i], myErrorName(status));
  204.             continue;
  205.         }
  206.  
  207.         defRules = ucol_getRules(myCollation, &rlen);
  208.         status = U_ZERO_ERROR;
  209.         tblColl1 = ucol_openRules(defRules, rlen, UCOL_NO_NORMALIZATION, 
  210.                    UCOL_DEFAULT_STRENGTH, &status);
  211.         if (U_FAILURE(status))
  212.         {
  213.             
  214.             log_err("Error in creating collator in %s:  %s\n", locales[i], myErrorName(status));
  215.             continue;
  216.         }
  217.  
  218.         
  219.         log_verbose("Locale  %s\n", locales[i]);
  220.         log_verbose("  tests start...\n");
  221.  
  222.         j = 0;
  223.         n = 0;
  224.         for (j = 0; j < FIXEDTESTSET; j++)
  225.         {
  226.             for (n = j+1; n < FIXEDTESTSET; n++)
  227.             {
  228.                 doTest(tblColl1, testCases[results[i][j]], testCases[results[i][n]], UCOL_LESS);
  229.             }
  230.         }
  231.  
  232.         ucol_close(myCollation);
  233.         ucol_close(tblColl1);
  234.     }
  235. }
  236.  
  237. void TestDemo1()
  238. {
  239.     UCollator *col, *myCollation;
  240.     const UChar *baseRules;
  241.     UChar *newRules, *temp;
  242.     int32_t len, rlen, j, n;
  243.  
  244.     UErrorCode status = U_ZERO_ERROR;
  245.     log_verbose("Demo Test 1 : Create a new table collation with rules \" & Z < p, P \" \n");
  246.     status = U_ZERO_ERROR;
  247.     col = ucol_open(NULL, &status);
  248.     if(U_FAILURE(status)){
  249.         log_err("Error in creation of Collator in Demo1  :%s\n", myErrorName(status));
  250.         return;
  251.     }
  252.  
  253.     baseRules = ucol_getRules(col, &rlen);
  254.     temp=(UChar*)malloc(sizeof(UChar) * 15);
  255.     u_uastrcpy(temp, "& Z < p, P");
  256.  
  257.     len=rlen + u_strlen(temp);
  258.     newRules=(UChar*)malloc(sizeof(UChar) * (len+1));
  259.     my_strncpy(newRules, baseRules, rlen);
  260.     my_strcat(newRules, temp, rlen);
  261.     myCollation = ucol_openRules(newRules, len, UCOL_NO_NORMALIZATION, 
  262.                                                     UCOL_DEFAULT_STRENGTH, &status);
  263.  
  264.     if (U_FAILURE(status))
  265.     {
  266.         log_err( "Demo Test 1 Rule collation object creation failed. : %s\n", myErrorName(status));
  267.         return;
  268.     }
  269.  
  270.     j = 0;
  271.     n = 0;
  272.     for (j = 0; j < FIXEDTESTSET; j++)
  273.     {
  274.         for (n = j+1; n < FIXEDTESTSET; n++)
  275.         {
  276.             doTest(myCollation, testCases[results[8][j]], testCases[results[8][n]], UCOL_LESS);
  277.         }
  278.     }
  279.  
  280.     ucol_close(myCollation); 
  281.     ucol_close(col);
  282.     free(newRules);
  283. }
  284. void TestDemo2()
  285. {
  286.     UCollator *col, *myCollation;
  287.     UErrorCode status = U_ZERO_ERROR;
  288.     const UChar *baseRules;
  289.     UChar *newRules, *temp;
  290.     int32_t len, rlen, j, n;
  291.  
  292.     log_verbose("Demo Test 2 : Create a new table collation with rules \"& C < ch , cH, Ch, CH\"");
  293.     status = U_ZERO_ERROR;
  294.     col = ucol_open(NULL, &status);
  295.     if(U_FAILURE(status)){
  296.         log_err("Error in creation of Collator in Demo1  : %s\n", myErrorName(status));
  297.         return;
  298.     }
  299.     baseRules = ucol_getRules(col, &rlen);
  300.     temp=(UChar*)malloc(sizeof(UChar) * 70);
  301.     u_uastrcpy(temp, "& C < ch , cH, Ch, CH");
  302.  
  303.     len=rlen + u_strlen(temp);
  304.     newRules=(UChar*)malloc(sizeof(UChar) * (len+1));
  305.     my_strncpy(newRules, baseRules, rlen);
  306.     my_strcat(newRules, temp, rlen);
  307.     myCollation = ucol_openRules(newRules, len, UCOL_NO_NORMALIZATION, 
  308.                                                     UCOL_DEFAULT_STRENGTH, &status);
  309.  
  310.     if (U_FAILURE(status))
  311.     {
  312.         log_err( "Demo Test 2 Rule collation object creation failed.: %s\n", myErrorName(status));
  313.         return;
  314.     }
  315.     j = 0;
  316.     for (j; j < TOTALTESTSET; j++)
  317.     {
  318.         for (n = j+1; n < TOTALTESTSET; n++)
  319.         {
  320.             doTest(myCollation, testCases[results[9][j]], testCases[results[9][n]], UCOL_LESS);
  321.         }
  322.     }
  323.     ucol_close(myCollation); 
  324.     ucol_close(col);
  325.     free(newRules);
  326.     
  327. }
  328.  
  329. void TestDemo3()
  330. {
  331.     UCollator *col, *myCollation;
  332.     UErrorCode status = U_ZERO_ERROR;
  333.     const UChar *baseRules;
  334.     UChar *newRules, *temp;
  335.     int32_t rlen, j, n, len;
  336.     
  337.     log_verbose("Demo Test 3 : Create a new table collation with rules \"& Question'-'mark ; '?' & Hash'-'mark ; '#' & Ampersand ; '&'\" \n");
  338.     status = U_ZERO_ERROR;
  339.     col = ucol_open(NULL, &status);
  340.     if(U_FAILURE(status)){
  341.         log_err("Error in creation of Collator in Demo3  : %s\n", myErrorName(status));
  342.         return;
  343.     }
  344.     baseRules = ucol_getRules(col, &rlen);
  345.     temp=(UChar*)malloc(sizeof(UChar) * 70);
  346.     u_uastrcpy(temp, "& Question'-'mark ; '?' & Hash'-'mark ; '#' & Ampersand ; '&'");
  347.     
  348.     len=rlen + u_strlen(temp);
  349.     newRules=(UChar*)malloc(sizeof(UChar) * (len+1));
  350.     my_strncpy(newRules, baseRules, rlen);
  351.     my_strcat(newRules, temp, rlen);
  352.     myCollation = ucol_openRules(newRules, len, UCOL_NO_NORMALIZATION, 
  353.                                                     UCOL_DEFAULT_STRENGTH, &status);
  354.  
  355.     if (U_FAILURE(status))
  356.     {
  357.         log_err( "Demo Test 3 Rule collation object creation failed.: %s\n", myErrorName(status));
  358.         return;
  359.     }
  360.  
  361.     j = 0;
  362.     for (j = 0; j < TOTALTESTSET; j++)
  363.     {
  364.         for (n = j+1; n < TOTALTESTSET; n++)
  365.         {
  366.             doTest(myCollation, testCases[results[10][j]], testCases[results[10][n]], UCOL_LESS);
  367.         }
  368.     }
  369.     ucol_close(myCollation); 
  370.     ucol_close(col);
  371.     free(temp);
  372.     free(newRules);
  373.     
  374. }
  375.  
  376. void TestDemo4()
  377. {
  378.     UCollator *col, *myCollation;
  379.     UErrorCode status = U_ZERO_ERROR;
  380.     const UChar *baseRules;
  381.     UChar *newRules, *temp;
  382.     int32_t rlen, j, n, len;
  383.     
  384.     log_verbose("Demo Test 4 : Create a new table collation with rules \" & aa ; a'-' & ee ; e'-' & ii ; i'-' & oo ; o'-' & uu ; u'-' \"\n");
  385.     status = U_ZERO_ERROR;
  386.     col = ucol_open(NULL, &status);
  387.     if(U_FAILURE(status)){
  388.         log_err("Error in creation of Collator in Demo1  : %s\n", myErrorName(status));
  389.         return;
  390.     }
  391.     baseRules = ucol_getRules(col, &rlen);
  392.     temp=(UChar*)malloc(sizeof(UChar) * 90);
  393.     u_uastrcpy(temp, " & aa ; a'-' & ee ; e'-' & ii ; i'-' & oo ; o'-' & uu ; u'-' ");
  394.     
  395.     len=rlen + u_strlen(temp);
  396.     newRules=(UChar*)malloc(sizeof(UChar) * (len+1));
  397.     my_strncpy(newRules, baseRules, rlen);
  398.     my_strcat(newRules, temp, rlen);
  399.     myCollation = ucol_openRules(newRules, len, UCOL_NO_NORMALIZATION, 
  400.                                                     UCOL_DEFAULT_STRENGTH, &status);
  401.  
  402.     if (U_FAILURE(status))
  403.     {
  404.         log_err( "Demo Test 4 Rule collation object creation failed.: %s\n", myErrorName(status));
  405.         return;
  406.     }
  407.     j;
  408.     for (j = 0; j < TOTALTESTSET; j++)
  409.     {
  410.         for (n = j+1; n < TOTALTESTSET; n++)
  411.         {
  412.             doTest(myCollation, testCases[results[11][j]], testCases[results[11][n]], UCOL_LESS);
  413.         }
  414.     }
  415.     ucol_close(myCollation); 
  416.     ucol_close(col);
  417.     free(temp);
  418.     free(newRules);
  419. }
  420.