(root)/
glibc-2.38/
localedata/
tests-mbwc/
dat_wcstombs.c
       1  /*
       2   *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
       3   *
       4   *	 FILE:	dat_wcstombs.c
       5   *
       6   *	 WCSTOMBS:  size_t wcstombs (char *s, const wchar_t *ws, size_t n)
       7   */
       8  
       9  
      10  /*
      11   *  CAUTION:
      12   *	     Do not use a value 0x01 for string data. The test program
      13   *	     uses it.
      14   *
      15   */
      16  
      17  
      18  TST_WCSTOMBS tst_wcstombs_loc [] = {
      19    {
      20      { Twcstombs, TST_LOC_de },
      21      {
      22        /* #01 : Any chars including a null char should not be stored in s.  */
      23        { /*input.*/ { 1,1,	       { 0x00C4,0x00D6,0x00DC,0x0000 }, 0 },
      24  	/*expect*/ { 0,1,0,	 ""					  },
      25        },
      26        /* #02 : Only one chars should be stored in s. No null termination.  */
      27        { /*input.*/ { 1,1,	       { 0x00C4,0x00D6,0x00DC,0x0000 },	1 },
      28  	/*expect*/ { 0,1,1,	 ""					  },
      29        },
      30        /* #03 : Only two chars should be stored in s. No null termination.  */
      31        { /*input.*/ { 1,1,	       { 0x00C4,0x00D6,0x00DC,0x0000 },	2 },
      32  	/*expect*/ { 0,1,2,	 "��"					  },
      33        },
      34        /* #04 : Only three chars should be stored in s. No null
      35  	       termination.  */
      36        { /*input.*/ { 1,1,	       { 0x00C4,0x00D6,0x00DC,0x0000 },	3 },
      37  	/*expect*/ { 0,1,3,	 "���"					  },
      38        },
      39        /* #05 : Only three chars should be stored in s with a null
      40  	       termination.  */
      41        { /*input.*/ { 1,1,	       { 0x00C4,0x00D6,0x00DC,0x0000 },	4 },
      42  	/*expect*/ { 0,1,3,	 "���"					  },
      43        },
      44        /* #06 : Only three chars should be stored in s with a null
      45  	       termination.  */
      46        { /*input.*/ { 1,1,	       { 0x00C4,0x00D6,0x00DC,0x0000 },	5 },
      47  	/*expect*/ { 0,1,3,	 "���"					  },
      48        },
      49        /* #07 : Invalid mb sequence. No chars should be stored in s. */
      50        { /*input.*/ { 1,1,	       { 0x0201,0x0221,0x0000,0x0000 },	2 },
      51  	/*expect*/ { EILSEQ,1,(size_t)-1,	 ""			  },
      52        },
      53        /* #08 : s is a null pointer, no chars should be stored in s.  */
      54        { /*input.*/ { 0,1,	       { 0x00C4,0x00D6,0x00DC,0x0000 }, 0 },
      55  	/*expect*/ { 0,1,3,	 ""					  },
      56        },
      57        /* #09 : s is a null pointer, no chars should be stored in s.  */
      58        { /*input.*/ { 0,1,	       { 0x00C4,0x00D6,0x00DC,0x0000 }, 1 },
      59  	/*expect*/ { 0,1,3,	 ""					  },
      60        },
      61        /* #10 : s is a null pointer, no chars should be stored in s.  */
      62        { /*input.*/ { 0,1,	       { 0x00C4,0x00D6,0x00DC,0x0000 }, 5 },
      63  	/*expect*/ { 0,1,3,	 ""					  },
      64        },
      65        /* #11 : s is a null pointer. No chars should be stored in s.  */
      66        { /*input.*/ { 0,1,	       { 0x0201,0x0221,0x0000,0x0000 }, 5 },
      67  	/*expect*/ { EILSEQ,1,(size_t)-1,	 ""			  },
      68        },
      69        /* #12 : ws is a null wc string, no chars should be stored in s.  */
      70        { /*input.*/ { 1,1,	       { 0x0000 },			5 },
      71  	/*expect*/ { 0,1,0,	 ""					  },
      72        },
      73        /* #13 : s is a null pointer, no chars should be stored in s.  */
      74        { /*input.*/ { 0,1,	       { 0x0000 },			5 },
      75  	/*expect*/ { 0,1,0,	 ""					  },
      76        },
      77        { .is_last = 1 }
      78      }
      79    },
      80    {
      81      { Twcstombs, TST_LOC_enUS },
      82      {
      83        /* #01 : Any chars including a null char should not be stored in s.  */
      84        { /*input.*/ { 1,1,	       { 0x00C4,0x0042,0x0043,0x0000 },	0  },
      85  	/*expect*/ { 0,1,0,	 ""					   },
      86        },
      87        /* #02 : Only one chars should be stored in s. No null termination.  */
      88        { /*input.*/ { 1,1,	       { 0x0041,0x0042,0x0043,0x0000 }, 1  },
      89  	/*expect*/ { 0,1,1,	 "A"					   },
      90        },
      91        /* #03 : Only two chars should be stored in s. No null termination.  */
      92        { /*input.*/ { 1,1,	       { 0x0041,0x0042,0x0043,0x0000 }, 2  },
      93  	/*expect*/ { 0,1,2,	 "AB"					   },
      94        },
      95        /* #04 : Only three chars should be stored in s. No null
      96  	       termination.  */
      97        { /*input.*/ { 1,1,	       { 0x0041,0x0042,0x0043,0x0000 }, 3  },
      98  	/*expect*/ { 0,1,3,	 "ABC"					   },
      99        },
     100        /* #05 : Only three chars should be stored in s with a null
     101  	       termination.  */
     102        { /*input.*/ { 1,1,	       { 0x0041,0x0042,0x0043,0x0000 }, 4  },
     103  	/*expect*/ { 0,1,3,	 "ABC"					   },
     104        },
     105        /* #06 : Only three chars should be stored in s with a null
     106  	       termination.  */
     107        { /*input.*/ { 1,1,	       { 0x0041,0x0042,0x0043,0x0000 }, 5  },
     108  	/*expect*/ { 0,1,3,	 "ABC"					   },
     109        },
     110        /* #07 : Invalid mb sequence. No chars should be stored in s.  */
     111        { /*input.*/ { 1,1,	       { 0x0201,0x0221,0x0000,0x0000 }, 2  },
     112  	/*expect*/ { EILSEQ,1,(size_t)-1,	 ""			   },
     113        },
     114        /* #08 : s is a null pointer, no chars should be stored in s.  */
     115        { /*input.*/ { 0,1,	       { 0x0041,0x0042,0x0043,0x0000 }, 0  },
     116  	/*expect*/ { 0,1,3,	 ""					   },
     117        },
     118        /* #09 : s is a null pointer, no chars should be stored in s.  */
     119        { /*input.*/ { 0,1,	       { 0x0041,0x0042,0x0043,0x0000 }, 1  },
     120  	/*expect*/ { 0,1,3,	 ""					   },
     121        },
     122        /* #10 : s is a null pointer, no chars should be stored in s.  */
     123        { /*input.*/ { 0,1,	       { 0x0041,0x0042,0x0043,0x0000 }, 5  },
     124  	/*expect*/ { 0,1,3,	 ""					   },
     125        },
     126        /* #11 : s is a null pointer. No chars should be stored in s.  */
     127        { /*input.*/ { 0,1,	       { 0x0201,0x0221,0x0000,0x0000 }, 5  },
     128  	/*expect*/ { EILSEQ,1,(size_t)-1,	 ""			   },
     129        },
     130        /* #12 : ws is a null wc string, no chars should be stored in s.  */
     131        { /*input.*/ { 1,1,	       { 0x0000 },			5, },
     132  	/*expect*/ { 0,1,0,	 ""			                   },
     133        },
     134        /* #13 : s is a null pointer, no chars should be stored in s.  */
     135        { /*input.*/ { 0,1,	       { 0x0000 },			5  },
     136  	/*expect*/ { 0,1,0,	 ""					   },
     137        },
     138        { .is_last = 1 }
     139      }
     140    },
     141    {
     142      { Twcstombs, TST_LOC_eucJP },
     143      {
     144  
     145        /* #01 : Any chars including a null char should not be stored in s.  */
     146        { /*input.*/ { 1,1,	       { 0x3042,0x3044,0xFF73,0x0000 }, 0  },
     147  	/*expect*/ { 0,1,0,	 ""					   },
     148        },
     149        /* #02 : Only one chars should be stored in s. No null termination.  */
     150        { /*input.*/ { 1,1,	       { 0x3042,0x3044,0xFF73,0x0000 }, 2  },
     151  	/*expect*/ { 0,1,2,	     "\244\242"				   },
     152        },
     153        /* #03 : Only two chars should be stored in s. No null termination.  */
     154        { /*input.*/ { 1,1,	       { 0x3042,0x3044,0xFF73,0x0000 }, 4  },
     155  	/*expect*/ { 0,1,4,	     "\244\242\244\244"			   },
     156        },
     157        /* #04 : Only three chars should be stored in s. No null
     158  	       termination.  */
     159        { /*input.*/ { 1,1,	       { 0x3042,0x3044,0xFF73,0x0000 }, 6  },
     160  	/*expect*/ { 0,1,6,	     "\244\242\244\244\216\263"		   },
     161        },
     162        /* #05 : Only three chars should be stored in s with a null
     163  	       termination.  */
     164        { /*input.*/ { 1,1,	       { 0x3042,0x3044,0xFF73,0x0000 }, 7  },
     165  	/*expect*/ { 0,1,6,	     "\244\242\244\244\216\263"		   },
     166        },
     167        /* #06 : Only three chars should be stored in s with a null
     168  	       termination.  */
     169        { /*input.*/ { 1,1,	       { 0x3042,0x3044,0xFF73,0x0000 }, 8  },
     170  	/*expect*/ { 0,1,6,	     "\244\242\244\244\216\263"		   },
     171        },
     172        /* #07 : Invalid mb sequence. No chars should be stored in s.  */
     173        { /*input.*/ { 1,1,	       { 0x0201,0x0221,0x0000,0x0000 }, 2  },
     174  	/*expect*/ { EILSEQ,1,-1,	 ""				   },
     175        },
     176        /* #08 : s is a null pointer, no chars should be stored in s.  */
     177        { /*input.*/ { 0,1,	       { 0x3042,0x3044,0xFF73,0x0000 }, 0  },
     178  	/*expect*/ { 0,1,6,	 ""					   },
     179        },
     180        /* #09 : s is a null pointer, no chars should be stored in s.  */
     181        { /*input.*/ { 0,1,	       { 0x3042,0x3044,0xFF73,0x0000 }, 1  },
     182  	/*expect*/ { 0,1,6,	 ""					   },
     183        },
     184        /* #10 : s is a null pointer, no chars should be stored in s.  */
     185        { /*input.*/ { 0,1,	       { 0x3042,0x3044,0xFF73,0x0000 }, 8  },
     186  	/*expect*/ { 0,1,6,	 ""					   },
     187        },
     188        /* #11 : s is a null pointer. No chars should be stored in s.  */
     189        { /*input.*/ { 0,1,	       { 0x0201,0x0221,0x0000,0x0000 }, 5  },
     190  	/*expect*/ { EILSEQ,1,(size_t)-1,	 ""			   },
     191        },
     192        /* #12 : ws is a null wc string, no chars should be stored in s.  */
     193        { /*input.*/ { 1,1,	       { 0x0000 },			5  },
     194  	/*expect*/ { 0,1,0,	 ""					   },
     195        },
     196        /* #13 : s is a null pointer, no chars should be stored in s.  */
     197        { /*input.*/ { 0,1,	       { 0x0000 },			5  },
     198  	/*expect*/ { 0,1,0,	 ""					   },
     199        },
     200        { .is_last = 1 }
     201      }
     202    },
     203    {
     204      { Twcstombs, TST_LOC_end }
     205    }
     206  };