Back to index

glibc  2.9
dat_wcsrtombs.c
Go to the documentation of this file.
00001 /*
00002  *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
00003  *
00004  *      FILE: dat_wcsrtombs.c
00005  *
00006  *      WCSTOMBS:  size_t wcsrtombs (char *s, const wchar_t **ws,
00007  *                                size_t n, mbstate *ps)
00008  */
00009 
00010 
00011 /*
00012  *  CAUTION:
00013  *          Do not use a value 0x01 for string data. The test program
00014  *          uses it.
00015  *
00016  */
00017 
00018 
00019 TST_WCSRTOMBS tst_wcsrtombs_loc [] = {
00020   {
00021     { Twcsrtombs, TST_LOC_de },
00022     {
00023       /* #01 : Any chars including a null char should not be stored in s.  */
00024       { /*input.*/ { 1,1,   { 0x00C4,0x00D6,0x00DC,0x0000 }, 0, 0, 0},
00025        /*expect*/ { 0,1,0,   ""                                },
00026       },
00027       /* #02 : Only one chars should be stored in s. No null termination.  */
00028       { /*input.*/ { 1,1,   { 0x00C4,0x00D6,0x00DC,0x0000 }, 1, 0, 0 },
00029        /*expect*/ { 0,1,1,   ""                                },
00030       },
00031       /* #03 : Only two chars should be stored in s. No null termination.  */
00032       { /*input.*/ { 1,1,   { 0x00C4,0x00D6,0x00DC,0x0000 }, 2, 0, 0 },
00033        /*expect*/ { 0,1,2,   ""                               },
00034       },
00035       /* #04 : Only three chars should be stored in s. No null
00036               termination.  */
00037       { /*input.*/ { 1,1,   { 0x00C4,0x00D6,0x00DC,0x0000 }, 3, 0, 0 },
00038        /*expect*/ { 0,1,3,   ""                              },
00039       },
00040       /* #05 : Only three chars should be stored in s with a null
00041               termination. */
00042       { /*input.*/ { 1,1,   { 0x00C4,0x00D6,0x00DC,0x0000 }, 4, 0, 0 },
00043        /*expect*/ { 0,1,3,   ""                              },
00044       },
00045       /* #06 : Only three chars should be stored in s with a null
00046               termination. */
00047       { /*input.*/ { 1,1,   { 0x00C4,0x00D6,0x00DC,0x0000 }, 5, 0, 0 },
00048        /*expect*/ { 0,1,3,   ""                              },
00049       },
00050       /* #07 : Invalid mb sequence. No chars should be stored in s.  */
00051       { /*input.*/ { 1,1,   { 0x0201,0x0221,0x0000,0x0000 }, 2, 0, 0 },
00052        /*expect*/ { EILSEQ,1,(size_t)-1,   ""                   },
00053       },
00054       /* #08 : s is a null pointer, no chars should be stored in s.  */
00055       { /*input.*/ { 0,1,   { 0x00C4,0x00D6,0x00DC,0x0000 }, 0, 0, 0 },
00056        /*expect*/ { 0,1,3,   ""                                 },
00057       },
00058       /* #09 : s is a null pointer, no chars should be stored in s.  */
00059       { /*input.*/ { 0,1,   { 0x00C4,0x00D6,0x00DC,0x0000 }, 1, 0, 0 },
00060        /*expect*/ { 0,1,3,   ""                                 },
00061       },
00062       /* #10 : s is a null pointer, no chars should be stored in s.  */
00063       { /*input.*/ { 0,1,   { 0x00C4,0x00D6,0x00DC,0x0000 }, 5, 0, 0 },
00064        /*expect*/ { 0,1,3,   ""                                 },
00065       },
00066       /* #11 : s is a null pointer. No chars should be stored in s.  */
00067       { /*input.*/ { 0,1,   { 0x0201,0x0221,0x0000,0x0000 }, 5, 0, 0 },
00068        /*expect*/ { EILSEQ,1,(size_t)-1,   ""                   },
00069       },
00070       /* #12 : ws is a null wc string, no chars should be stored in s.  */
00071       { /*input.*/ { 1,1,   { 0x0000 },                  5, 0, 0 },
00072        /*expect*/ { 0,1,0,   ""                                 },
00073       },
00074       /* #13 : s is a null pointer, no chars should be stored in s.  */
00075       { /*input.*/ { 0,1,   { 0x0000 },                  5, 0, 0 },
00076        /*expect*/ { 0,1,0,   ""                                 },
00077       },
00078       { .is_last = 1 }
00079     }
00080   },
00081   {
00082     { Twcsrtombs, TST_LOC_enUS },
00083     {
00084       /* #01 : Any chars including a null char should not be stored in s.  */
00085       { /*input.*/ { 1,1,   { 0x0041,0x0042,0x0043,0x0000 }, 0, 0, 0 },
00086        /*expect*/ { 0,1,0,   ""                                 },
00087       },
00088       /* #02 : Only one chars should be stored in s. No null termination.  */
00089       { /*input.*/ { 1,1,   { 0x0041,0x0042,0x0043,0x0000 }, 1, 0, 0 },
00090        /*expect*/ { 0,1,1,   "A"                                },
00091       },
00092       /* #03 : Only two chars should be stored in s. No null termination. */
00093       { /*input.*/ { 1,1,   { 0x0041,0x0042,0x0043,0x0000 }, 2, 0, 0 },
00094        /*expect*/ { 0,1,2,   "AB"                               },
00095       },
00096       /* #04 : Only three chars should be stored in s. No null
00097               termination.  */
00098       { /*input.*/ { 1,1,   { 0x0041,0x0042,0x0043,0x0000 }, 3, 0, 0 },
00099        /*expect*/ { 0,1,3,   "ABC"                              },
00100       },
00101       /* #05 : Only three chars should be stored in s with a null
00102               termination. */
00103       { /*input.*/ { 1,1,   { 0x0041,0x0042,0x0043,0x0000 }, 4, 0, 0 },
00104        /*expect*/ { 0,1,3,   "ABC"                              },
00105       },
00106       /* #06 : Only three chars should be stored in s with a null
00107               termination. */
00108       { /*input.*/ { 1,1,   { 0x0041,0x0042,0x0043,0x0000 }, 5, 0, 0 },
00109        /*expect*/ { 0,1,3,   "ABC"                              },
00110       },
00111       /* #07 : Invalid mb sequence. No chars should be stored in s.  */
00112       { /*input.*/ { 1,1,   { 0x0201,0x0221,0x0000,0x0000 }, 2, 0, 0 },
00113        /*expect*/ { EILSEQ,1,(size_t)-1,   ""                                },
00114       },
00115       /* #08 : s is a null pointer, no chars should be stored in s.  */
00116       { /*input.*/ { 0,1,   { 0x0041,0x0042,0x0043,0x0000 }, 0, 0, 0 },
00117        /*expect*/ { 0,1,3,   ""                                 },
00118       },
00119       /* #09 : s is a null pointer, no chars should be stored in s.  */
00120       { /*input.*/ { 0,1,   { 0x0041,0x0042,0x0043,0x0000 }, 1, 0, 0 },
00121        /*expect*/ { 0,1,3,   ""                                 },
00122       },
00123       /* #10 : s is a null pointer, no chars should be stored in s.  */
00124       { /*input.*/ { 0,1,   { 0x0041,0x0042,0x0043,0x0000 }, 5, 0, 0 },
00125        /*expect*/ { 0,1,3,   ""                                 },
00126       },
00127       /* #11 : s is a null pointer. No chars should be stored in s.  */
00128       { /*input.*/ { 0,1,   { 0x0201,0x0221,0x0000,0x0000 }, 5, 0, 0 },
00129        /*expect*/ { EILSEQ,1,(size_t)-1,   ""                   },
00130       },
00131       /* #12 : ws is a null wc string, no chars should be stored in s.  */
00132       { /*input.*/ { 1,1,   { 0x0000 },                  5, 0, 0 },
00133        /*expect*/ { 0,1,0,   ""                                 },
00134       },
00135       /* #13 : s is a null pointer, no chars should be stored in s.  */
00136       { /*input.*/ { 0,1,   { 0x0000 },                  5, 0, 0 },
00137        /*expect*/ { 0,1,0,   ""                                 },
00138       },
00139       { .is_last = 1 }
00140     }
00141   },
00142   {
00143     { Twcsrtombs, TST_LOC_eucJP },
00144     {
00145 
00146       /* #01 : Any chars including a null char should not be stored in s.  */
00147       { /*input.*/ { 1,1,   { 0x3042,0x3044,0xFF73,0x0000 }, 0, 0, 0 },
00148        /*expect*/ { 0,1,0,   ""                                 },
00149       },
00150       /* #02 : Only one chars should be stored in s. No null termination.  */
00151       { /*input.*/ { 1,1,   { 0x3042,0x3044,0xFF73,0x0000 }, 2, 0, 0 },
00152        /*expect*/ { 0,1,2,      "\244\242"                             },
00153       },
00154       /* #03 : Only two chars should be stored in s. No null termination.  */
00155       { /*input.*/ { 1,1,   { 0x3042,0x3044,0xFF73,0x0000 }, 4, 0, 0 },
00156        /*expect*/ { 0,1,4,      "\244\242\244\244"                     },
00157       },
00158       /* #04 : Only three chars should be stored in s. No null
00159               termination.  */
00160       { /*input.*/ { 1,1,   { 0x3042,0x3044,0xFF73,0x0000 }, 6, 0, 0 },
00161        /*expect*/ { 0,1,6,      "\244\242\244\244\216\263"             },
00162       },
00163       /* #05 : Only three chars should be stored in s with a null
00164               termination. */
00165       { /*input.*/ { 1,1,   { 0x3042,0x3044,0xFF73,0x0000 }, 7, 0, 0 },
00166        /*expect*/ { 0,1,6,      "\244\242\244\244\216\263"             },
00167       },
00168       /* #06 : Only three chars should be stored in s with a null
00169               termination. */
00170       { /*input.*/ { 1,1,   { 0x3042,0x3044,0xFF73,0x0000 }, 8, 0, 0 },
00171        /*expect*/ { 0,1,6,      "\244\242\244\244\216\263"             },
00172       },
00173       /* #07 : Invalid mb sequence. No chars should be stored in s.  */
00174       { /*input.*/ { 1,1,   { 0x0201,0x0221,0x0000,0x0000 }, 2, 0, 0 },
00175        /*expect*/ { EILSEQ,1,-1, ""                                    },
00176       },
00177       /* #08 : s is a null pointer, no chars should be stored in s.  */
00178       { /*input.*/ { 0,1,   { 0x3042,0x3044,0xFF73,0x0000 }, 0, 0, 0 },
00179        /*expect*/ { 0,1,6,   ""                                 },
00180       },
00181       /* #09 : s is a null pointer, no chars should be stored in s.  */
00182       { /*input.*/ { 0,1,   { 0x3042,0x3044,0xFF73,0x0000 }, 1, 0, 0 },
00183        /*expect*/ { 0,1,6,   ""                                 },
00184       },
00185       /* #10 : s is a null pointer, no chars should be stored in s.  */
00186       { /*input.*/ { 0,1,   { 0x3042,0x3044,0xFF73,0x0000 }, 8, 0, 0 },
00187        /*expect*/ { 0,1,6,   ""                                 },
00188       },
00189       /* #11 : s is a null pointer. No chars should be stored in s.  */
00190       { /*input.*/ { 0,1,   { 0x0201,0x0221,0x0000,0x0000 }, 5, 0, 0 },
00191        /*expect*/ { EILSEQ,1,(size_t)-1,   ""                   },
00192       },
00193       /* #12 : ws is a null wc string, no chars should be stored in s.  */
00194       { /*input.*/ { 1,1,   { 0x0000 },                  5, 0, 0 },
00195        /*expect*/ { 0,1,0,   ""                                 },
00196       },
00197       /* #13 : s is a null pointer, no chars should be stored in s.  */
00198       { /*input.*/ { 0,1,   { 0x0000 },                  5, 0, 0 },
00199        /*expect*/ { 0,1,0,   ""                                 },
00200       },
00201       { .is_last = 1 }
00202     }
00203   },
00204   {
00205     { Twcsrtombs, TST_LOC_end }
00206   }
00207 };