Back to index

glibc  2.9
dat_strcoll.c
Go to the documentation of this file.
00001 /*
00002  *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
00003  *
00004  *      FILE: dat_strcoll.c
00005  *
00006  *      STRCOLL:  int strcoll (const char *s1, const char *s2);
00007  */
00008 
00009 /*
00010    NOTE:
00011 
00012    If a return value is expected to be 0, set ret_flg=1 and the
00013    expected value = 0.      If a return value is expected to be a
00014    positive/negative value, set ret_flg=0, and set the expected value
00015    = +1/-1.
00016    There is inconsistensy between tst_strcoll() and tst_wcscoll()(it
00017    has cmp_flg) for input data. I'll fix it.
00018 
00019    Assuming en_US to be en_US.ascii. (maybe, should be iso8859-1).
00020 
00021 
00022 
00023    ASCII CODE  : A,B,C, ...  , a, b, c, ...       B,a:-1         a,B:+1
00024    DICTIONARY : A,a,B,b,C,c,....  a,B:-1 B,a:+1 */
00025 
00026 TST_STRCOLL tst_strcoll_loc [] = {
00027   {
00028     { Tstrcoll, TST_LOC_de },
00029     {
00030       { /*input.*/ { "BCDEFG", "BCDEFG"       },  /* #1 */
00031        /*expect*/ { 0,1,0,                      },
00032       },
00033       { /*input.*/ { "XX  XX", "XX B XX"       },  /* #2 */
00034        /*expect*/ { 0,0,-1,                     },
00035       },
00036       { /*input.*/ { "XX B XX", "XX  XX"       },  /* #3 */
00037        /*expect*/ { 0,0,+1,                     },
00038       },
00039       { /*input.*/ { "B",   "a"                 },  /* #4 */
00040        /*expect*/ { 0,0,+1,                     },
00041       },
00042       { /*input.*/ { "a",   "B"                 },  /* #5 */
00043        /*expect*/ { 0,0,-1,                     },
00044       },
00045       { /*input.*/ { "b",   "A"                 },  /* #6 */
00046        /*expect*/ { 0,0,+1,                     },
00047       },
00048       { /*input.*/ { "A",   "b"                 },  /* #7 */
00049        /*expect*/ { 0,0,-1,                     },
00050       },
00051       { /*input.*/ { "",   "B"                 },  /* #8 */
00052        /*expect*/ { 0,0,-1,                     },
00053       },
00054       { /*input.*/ { "B",   ""                 },  /* #9 */
00055        /*expect*/ { 0,0,+1,                     },
00056       },
00057       { .is_last = 1 } /* Last element.  */
00058     }
00059   },
00060   {
00061     { Tstrcoll, TST_LOC_enUS },
00062     {
00063       { /*input.*/ { "ABCDEFG", "ABCDEFG"       },  /* #1 */
00064        /*expect*/ { 0,1,0,                      },
00065       },
00066       { /*input.*/ { "XX a XX", "XX B XX"       },  /* #2 */
00067        /*expect*/ { 0,0,-1,                     },
00068       },
00069       { /*input.*/ { "XX B XX", "XX a XX"       },  /* #3 */
00070        /*expect*/ { 0,0,+1,                     },
00071       },
00072       {
00073        /* <WAIVER> */
00074        /*input.*/ { "B",    "a"                 },  /* #4 */
00075 #ifdef SHOJI_IS_RIGHT
00076        /*expect*/ { 0,0,-1,                     },
00077 #else
00078                  /* XXX We are not testing the C locale.  */
00079        /*expect*/ { 0,0,+1,                     },
00080 #endif
00081       },
00082       {
00083        /* <WAIVER> */
00084        /*input.*/ { "a",    "B"                 },  /* #5 */
00085 #ifdef SHOJI_IS_RIGHT
00086        /*expect*/ { 0,0,+1,                     },
00087 #else
00088                  /* XXX We are not testing the C locale.  */
00089        /*expect*/ { 0,0,-1,                     },
00090 #endif
00091       },
00092       { /*input.*/ { "b",   "A"                 },  /* #6 */
00093        /*expect*/ { 0,0,+1,                     },
00094       },
00095       { /*input.*/ { "A",   "b"                 },  /* #7 */
00096        /*expect*/ { 0,0,-1,                     },
00097       },
00098 #ifdef NO_WAIVER
00099       /* XXX I do not yet know whether strcoll really should reject
00100         characters outside the multibyte character range.  */
00101       {
00102        /* #8 */  /* <WAIVER> */
00103        /*input.*/ { "\244\242\244\244\244\246\244\250\244\252", "ABCDEFG" },
00104        /*expect*/ { EINVAL,0,0,                 },
00105       },
00106       {
00107        /* #9 */  /* <WAIVER> */
00108        /*input.*/ { "ABCZEFG", "\244\242\244\244\244\246\244\250\244\252" },
00109        /*expect*/ { EINVAL,0,0,                 },
00110       },
00111 #endif
00112       { .is_last = 1 } /* Last element.  */
00113     }
00114   },
00115   {
00116     { Tstrcoll, TST_LOC_eucJP },
00117     {
00118       { /*input.*/ { "\244\242\244\244\244\246\244\250\244\252",
00119                    "\244\242\244\244\244\246\244\250\244\252" },  /* #1 */
00120        /*expect*/ { 0,1,0,                      },
00121       },
00122       { /*input.*/ { "\244\242\244\244\244\246\244\250\244\252",
00123                    "\244\242\244\244\244\363\244\250\244\252" },  /* #2 */
00124        /*expect*/ { 0,0,-1,                     },
00125       },
00126       { /*input.*/ { "\244\242\244\244\244\363\244\250\244\252",
00127                    "\244\242\244\244\244\246\244\250\244\252" },  /* #3 */
00128        /*expect*/ { 0,0,+1,                     },
00129       },
00130       { /*input.*/ { "B",   "a"                 },  /* #4 */
00131        /*expect*/ { 0,0,-1,                     },
00132       },
00133       { /*input.*/ { "a",   "B"                 },  /* #5 */
00134        /*expect*/ { 0,0,+1,                     },
00135       },
00136       { /*input.*/ { "b",   "A"                 },  /* #6 */
00137        /*expect*/ { 0,0,+1,                     },
00138       },
00139       { /*input.*/ { "A",   "b"                 },  /* #7 */
00140        /*expect*/ { 0,0,-1,                     },
00141       },
00142 #ifdef NO_WAIVER
00143       /* XXX I do not yet know whether strcoll really should reject
00144         characters outside the multibyte character range.  */
00145       {
00146        /* <WAIVER> */
00147        /*input.*/ { "\200\216\217", "ABCDEFG"          },  /* #8 */
00148        /*expect*/ { EINVAL,0,0,                 },
00149       },
00150       {
00151        /* <WAIVER> */
00152        /*input.*/ { "ABCZEFG", "\200\216\217"          },  /* #9 */
00153        /*expect*/ { EINVAL,0,0,                 },
00154       },
00155 #endif
00156       { .is_last = 1 } /* Last element.  */
00157     }
00158   },
00159   {
00160     { Tstrcoll, TST_LOC_end }
00161   }
00162 };