Back to index

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