Back to index

glibc  2.9
dat_wcscoll.c
Go to the documentation of this file.
00001 /*
00002  *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
00003  *
00004  *      FILE: dat_wcscoll.c
00005  *
00006  *      WCSCOLL:  int       wcscoll (const wchar_t *ws1, const wchar_t *ws2);
00007  */
00008 
00009 /*
00010  *  CAUTION:
00011  *          When LC_COLLATE (or LC_ALL) is set for ja_JP.EUC,
00012  *          wcscoll() core-dumps for big values such as 0x3041
00013  *          (0x0041 is okay) in glibc 2.1.2.
00014  *
00015  *  NOTE:
00016  *    a) When 0 is expected as a return value, set ret_flg=1.
00017  *      - the return value is compared with an expected value: ret_val.
00018  *    b) When a positive value is expected as a return value,
00019  *      set ret_flg=0 and set cmp_flg=+1.
00020  *      - the return value is not compared with the expected value
00021  *        (can not be compared); instead, the test program checks
00022  *        if the return value is positive when cmp_flg=+1.
00023  *    c) When a negative value is expected as a return value,
00024  *      ......
00025  *    d) When data contains invalid values, set err_val to the expected errno.
00026  *      Set ret_flg=0 and cmp_flg=0 so that it doesn't compare
00027  *      the return value with an expected value or doesn't check
00028  *      the sign of the return value.
00029  *
00030  *
00031  *          -------------------------------------------
00032  *          CASE  err_val   ret_flg  ret_val      cmp_flg
00033  *          -------------------------------------------
00034  *           a)      0       1       0        0
00035  *           b)      0       0       0       +1
00036  *           c)      0       0       0       -1
00037  *           d)    EINVAL    0       0        0
00038  *          -------------------------------------------
00039  */
00040 
00041 
00042 TST_WCSCOLL tst_wcscoll_loc [] = {
00043 
00044     {  { Twcscoll, TST_LOC_de },
00045        {
00046          { /*input.*/ { { 0x00E1,0x00E2,0x00E3,0x0000 },
00047                       { 0x00E1,0x00E2,0x00E3,0x0000 }, },  /* #1 */
00048            /*expect*/ { 0,1,0, 0,                  },
00049          },
00050          { /*input.*/ { { 0x0000,0x00E1,0x00E3,0x0000 },
00051                       { 0x0000,0x00E2,0x00E3,0x0000 }, },  /* #2 */
00052            /*expect*/ { 0,1,0, 0,                  },
00053          },
00054          { /*input.*/ { { 0x00E1,0x00E1,0x00E3,0x0000 },
00055                       { 0x0000,0x00E2,0x00E3,0x0000 }, },  /* #3 */
00056            /*expect*/ { 0,0,0, +1,                 },
00057          },
00058          { /*input.*/ { { 0x0000,0x00E2,0x00E3,0x0000 },
00059                       { 0x00E1,0x00E1,0x00E3,0x0000 }, },  /* #4 */
00060            /*expect*/ { 0,0,0, -1,                 },
00061          },
00062          { /*input.*/ { { 0x00E1,0x0042,0x00E3,0x0000 },
00063                       { 0x00E1,0x0061,0x00E3,0x0000 }, },  /* #5 */
00064            /*expect*/ { 0,0,0, +1,                 },
00065          },
00066          { /*input.*/ { { 0x00E1,0x0061,0x00E3,0x0000 },
00067                       { 0x00E1,0x0042,0x00E3,0x0000 }, },  /* #6 */
00068            /*expect*/ { 0,0,0, -1,                 },
00069          },
00070          { /*input.*/ { { 0x00E1,0x00E2,0x0000          },
00071                       { 0x00E1,0x00E2,0x00E9,0x0000 }, },  /* #7 */
00072            /*expect*/ { 0,0,0, -1,                 },
00073          },
00074          { /*input.*/ { { 0x00E1,0x00E2,0x00E9,0x0000 },
00075                       { 0x00E1,0x00E2,0x0000            }, },  /* #8 */
00076            /*expect*/ { 0,0,0, +1,                 },
00077          },
00078          { /*input.*/ { { 0x00E1,0x0092,0x00E9,0x0000 },
00079                       { 0x00E1,0x008E,0x00E9,0x0000 }, },  /* #9 */
00080            /*expect*/ { 0,0,0, +1,               },
00081          },
00082          { /*input.*/ { { 0x00E1,0x008E,0x00E9,0x0000 },
00083                       { 0x00E1,0x0092,0x00E9,0x0000 }, },  /* #10 */
00084            /*expect*/ { 0,0,0, -1,               },
00085          },
00086          { .is_last = 1 }
00087        }
00088     },
00089     {  { Twcscoll, TST_LOC_enUS },
00090        {
00091          { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
00092                       { 0x0041,0x0042,0x0043,0x0000 }, },  /* #1 */
00093            /*expect*/ { 0,1,0, 0,                  },
00094          },
00095          { /*input.*/ { { 0x0000,0x0041,0x0043,0x0000 },
00096                       { 0x0000,0x0042,0x0043,0x0000 }, },  /* #2 */
00097            /*expect*/ { 0,1,0, 0,                  },
00098          },
00099          { /*input.*/ { { 0x0041,0x0041,0x0043,0x0000 },
00100                       { 0x0000,0x0042,0x0043,0x0000 }, },  /* #3 */
00101            /*expect*/ { 0,0,0, +1,                 },
00102          },
00103          { /*input.*/ { { 0x0000,0x0042,0x0043,0x0000 },
00104                       { 0x0041,0x0041,0x0043,0x0000 }, },  /* #4 */
00105            /*expect*/ { 0,0,0, -1,                 },
00106          },
00107 #ifdef SHOJI_IS_RIGHT
00108          /* <WAIVER> */ /* assume ascii */
00109          { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
00110                       { 0x0041,0x0061,0x0043,0x0000 }, },  /* #5 */
00111            /*expect*/ { 0,0,0, -1,                 },
00112          },
00113          /* <WAIVER> */ /* assume ascii */
00114          { /*input.*/ { { 0x0041,0x0061,0x0043,0x0000 },
00115                       { 0x0041,0x0042,0x0043,0x0000 }, },  /* #6 */
00116            /*expect*/ { 0,0,0, +1,                 },
00117          },
00118 #else
00119          /* XXX Correct order is lowercase before uppercase.  */
00120          { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
00121                       { 0x0041,0x0061,0x0043,0x0000 }, },  /* #5 */
00122            /*expect*/ { 0,0,0, +1,                 },
00123          },
00124          { /*input.*/ { { 0x0041,0x0061,0x0043,0x0000 },
00125                       { 0x0041,0x0042,0x0043,0x0000 }, },  /* #6 */
00126            /*expect*/ { 0,0,0, -1,                 },
00127          },
00128 #endif
00129          { /*input.*/ { { 0x0041,0x0042,0x0000          },
00130                       { 0x0041,0x0042,0x0049,0x0000 }, },  /* #7 */
00131            /*expect*/ { 0,0,0, -1,                 },
00132          },
00133          { /*input.*/ { { 0x0041,0x0042,0x0049,0x0000 },
00134                       { 0x0041,0x0042,0x0000            }, },  /* #8 */
00135            /*expect*/ { 0,0,0, +1,                 },
00136          },
00137 #ifdef SHOJI_IS_RIGHT
00138          { /*input.*/ { { 0x0041,0x0092,0x0049,0x0000 },
00139                       { 0x0041,0x008E,0x0049,0x0000 }, },  /* #9 */
00140            /*expect*/ { 0,0,0, +1,               },
00141          },
00142          { /*input.*/ { { 0x0041,0x008E,0x0049,0x0000 },
00143                       { 0x0041,0x0092,0x0049,0x0000 }, },  /* #10 */
00144            /*expect*/ { 0,0,0, -1,               },
00145          },
00146 #else
00147          /* Do not assume position of character out of range.  */
00148          { /*input.*/ { { 0x0041,0x0092,0x0049,0x0000 },
00149                       { 0x0041,0x008E,0x0049,0x0000 }, },  /* #9 */
00150            /*expect*/ { 0,0,0, 0,                },
00151          },
00152          { /*input.*/ { { 0x0041,0x008E,0x0049,0x0000 },
00153                       { 0x0041,0x0092,0x0049,0x0000 }, },  /* #10 */
00154            /*expect*/ { 0,0,0, 0,                },
00155          },
00156 #endif
00157          { .is_last = 1 }
00158        }
00159     },
00160     {  { Twcscoll, TST_LOC_eucJP },
00161        {
00162          { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },
00163                       { 0x3041,0x3042,0x3043,0x0000 }, },  /* #1 */
00164            /*expect*/ { 0,1,0, 0,                  },
00165          },
00166          { /*input.*/ { { 0x0000,0x3041,0x3043,0x0000 },
00167                       { 0x0000,0x3042,0x3043,0x0000 }, },  /* #2 */
00168            /*expect*/ { 0,1,0, 0,                  },
00169          },
00170          { /*input.*/ { { 0x3041,0x3041,0x3043,0x0000 },
00171                       { 0x0000,0x3042,0x3043,0x0000 }, },  /* #3 */
00172            /*expect*/ { 0,0,0, +1,                 },
00173          },
00174          { /*input.*/ { { 0x0000,0x3042,0x3043,0x0000 },
00175                       { 0x3041,0x3041,0x3043,0x0000 }, },  /* #4 */
00176            /*expect*/ { 0,0,0, -1,                 },
00177          },
00178          { /*input.*/ { { 0x3041,0x0042,0x3043,0x0000 },
00179                       { 0x3041,0x0061,0x3043,0x0000 }, },  /* #5 */
00180            /*expect*/ { 0,0,0, -1,                 },
00181          },
00182          { /*input.*/ { { 0x3041,0x0061,0x3043,0x0000 },
00183                       { 0x3041,0x0042,0x3043,0x0000 }, },  /* #6 */
00184            /*expect*/ { 0,0,0, +1,                 },
00185          },
00186          { /*input.*/ { { 0x3041,0x3042,0xFF71,0x0000 },
00187                       { 0x3041,0x3042,0x30A2,0x0000 }, },  /* #7 */
00188            /*expect*/ { 0,0,0, -1,                 },
00189          },
00190          { /*input.*/ { { 0x3041,0x3042,0x30A2,0x0000 },
00191                       { 0x3041,0x3042,0xFF71,0x0000 }, },  /* #8 */
00192            /*expect*/ { 0,0,0, +1,                 },
00193          },
00194          { /*input.*/ { { 0x30FF,0x3092,0x3049,0x0000 },
00195                       { 0x3041,0x308E,0x3049,0x0000 }, },  /* #9 */
00196            /*expect*/ { 0,0,0, -1,               },
00197          },
00198          { /*input.*/ { { 0x3041,0x308E,0x3049,0x0000 },
00199                       { 0x30FF,0x3092,0x3049,0x0000 }, },  /* #10 */
00200            /*expect*/ { 0,0,0, +1,               },
00201          },
00202          { .is_last = 1 }
00203        }
00204     },
00205     {  { Twcscoll, TST_LOC_end } }
00206 };