Blame localedata/tests-mbwc/dat_wcstombs.c

Packit 6c4009
/*
Packit 6c4009
 *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
Packit 6c4009
 *
Packit 6c4009
 *	 FILE:	dat_wcstombs.c
Packit 6c4009
 *
Packit 6c4009
 *	 WCSTOMBS:  size_t wcstombs (char *s, const wchar_t *ws, size_t n)
Packit 6c4009
 */
Packit 6c4009
Packit 6c4009
Packit 6c4009
/*
Packit 6c4009
 *  CAUTION:
Packit 6c4009
 *	     Do not use a value 0x01 for string data. The test program
Packit 6c4009
 *	     uses it.
Packit 6c4009
 *
Packit 6c4009
 */
Packit 6c4009
Packit 6c4009
Packit 6c4009
TST_WCSTOMBS tst_wcstombs_loc [] = {
Packit 6c4009
  {
Packit 6c4009
    { Twcstombs, TST_LOC_de },
Packit 6c4009
    {
Packit 6c4009
      /* #01 : Any chars including a null char should not be stored in s.  */
Packit 6c4009
      { /*input.*/ { 1,1,	       { 0x00C4,0x00D6,0x00DC,0x0000 }, 0 },
Packit 6c4009
	/*expect*/ { 0,1,0,	 ""					  },
Packit 6c4009
      },
Packit 6c4009
      /* #02 : Only one chars should be stored in s. No null termination.  */
Packit 6c4009
      { /*input.*/ { 1,1,	       { 0x00C4,0x00D6,0x00DC,0x0000 },	1 },
Packit 6c4009
	/*expect*/ { 0,1,1,	 "Ä"					  },
Packit 6c4009
      },
Packit 6c4009
      /* #03 : Only two chars should be stored in s. No null termination.  */
Packit 6c4009
      { /*input.*/ { 1,1,	       { 0x00C4,0x00D6,0x00DC,0x0000 },	2 },
Packit 6c4009
	/*expect*/ { 0,1,2,	 "ÄÖ"					  },
Packit 6c4009
      },
Packit 6c4009
      /* #04 : Only three chars should be stored in s. No null
Packit 6c4009
	       termination.  */
Packit 6c4009
      { /*input.*/ { 1,1,	       { 0x00C4,0x00D6,0x00DC,0x0000 },	3 },
Packit 6c4009
	/*expect*/ { 0,1,3,	 "ÄÖÜ"					  },
Packit 6c4009
      },
Packit 6c4009
      /* #05 : Only three chars should be stored in s with a null
Packit 6c4009
	       termination.  */
Packit 6c4009
      { /*input.*/ { 1,1,	       { 0x00C4,0x00D6,0x00DC,0x0000 },	4 },
Packit 6c4009
	/*expect*/ { 0,1,3,	 "ÄÖÜ"					  },
Packit 6c4009
      },
Packit 6c4009
      /* #06 : Only three chars should be stored in s with a null
Packit 6c4009
	       termination.  */
Packit 6c4009
      { /*input.*/ { 1,1,	       { 0x00C4,0x00D6,0x00DC,0x0000 },	5 },
Packit 6c4009
	/*expect*/ { 0,1,3,	 "ÄÖÜ"					  },
Packit 6c4009
      },
Packit 6c4009
      /* #07 : Invalid mb sequence. No chars should be stored in s. */
Packit 6c4009
      { /*input.*/ { 1,1,	       { 0x0201,0x0221,0x0000,0x0000 },	2 },
Packit 6c4009
	/*expect*/ { EILSEQ,1,(size_t)-1,	 ""			  },
Packit 6c4009
      },
Packit 6c4009
      /* #08 : s is a null pointer, no chars should be stored in s.  */
Packit 6c4009
      { /*input.*/ { 0,1,	       { 0x00C4,0x00D6,0x00DC,0x0000 }, 0 },
Packit 6c4009
	/*expect*/ { 0,1,3,	 ""					  },
Packit 6c4009
      },
Packit 6c4009
      /* #09 : s is a null pointer, no chars should be stored in s.  */
Packit 6c4009
      { /*input.*/ { 0,1,	       { 0x00C4,0x00D6,0x00DC,0x0000 }, 1 },
Packit 6c4009
	/*expect*/ { 0,1,3,	 ""					  },
Packit 6c4009
      },
Packit 6c4009
      /* #10 : s is a null pointer, no chars should be stored in s.  */
Packit 6c4009
      { /*input.*/ { 0,1,	       { 0x00C4,0x00D6,0x00DC,0x0000 }, 5 },
Packit 6c4009
	/*expect*/ { 0,1,3,	 ""					  },
Packit 6c4009
      },
Packit 6c4009
      /* #11 : s is a null pointer. No chars should be stored in s.  */
Packit 6c4009
      { /*input.*/ { 0,1,	       { 0x0201,0x0221,0x0000,0x0000 }, 5 },
Packit 6c4009
	/*expect*/ { EILSEQ,1,(size_t)-1,	 ""			  },
Packit 6c4009
      },
Packit 6c4009
      /* #12 : ws is a null wc string, no chars should be stored in s.  */
Packit 6c4009
      { /*input.*/ { 1,1,	       { 0x0000 },			5 },
Packit 6c4009
	/*expect*/ { 0,1,0,	 ""					  },
Packit 6c4009
      },
Packit 6c4009
      /* #13 : s is a null pointer, no chars should be stored in s.  */
Packit 6c4009
      { /*input.*/ { 0,1,	       { 0x0000 },			5 },
Packit 6c4009
	/*expect*/ { 0,1,0,	 ""					  },
Packit 6c4009
      },
Packit 6c4009
      { .is_last = 1 }
Packit 6c4009
    }
Packit 6c4009
  },
Packit 6c4009
  {
Packit 6c4009
    { Twcstombs, TST_LOC_enUS },
Packit 6c4009
    {
Packit 6c4009
      /* #01 : Any chars including a null char should not be stored in s.  */
Packit 6c4009
      { /*input.*/ { 1,1,	       { 0x00C4,0x0042,0x0043,0x0000 },	0  },
Packit 6c4009
	/*expect*/ { 0,1,0,	 ""					   },
Packit 6c4009
      },
Packit 6c4009
      /* #02 : Only one chars should be stored in s. No null termination.  */
Packit 6c4009
      { /*input.*/ { 1,1,	       { 0x0041,0x0042,0x0043,0x0000 }, 1  },
Packit 6c4009
	/*expect*/ { 0,1,1,	 "A"					   },
Packit 6c4009
      },
Packit 6c4009
      /* #03 : Only two chars should be stored in s. No null termination.  */
Packit 6c4009
      { /*input.*/ { 1,1,	       { 0x0041,0x0042,0x0043,0x0000 }, 2  },
Packit 6c4009
	/*expect*/ { 0,1,2,	 "AB"					   },
Packit 6c4009
      },
Packit 6c4009
      /* #04 : Only three chars should be stored in s. No null
Packit 6c4009
	       termination.  */
Packit 6c4009
      { /*input.*/ { 1,1,	       { 0x0041,0x0042,0x0043,0x0000 }, 3  },
Packit 6c4009
	/*expect*/ { 0,1,3,	 "ABC"					   },
Packit 6c4009
      },
Packit 6c4009
      /* #05 : Only three chars should be stored in s with a null
Packit 6c4009
	       termination.  */
Packit 6c4009
      { /*input.*/ { 1,1,	       { 0x0041,0x0042,0x0043,0x0000 }, 4  },
Packit 6c4009
	/*expect*/ { 0,1,3,	 "ABC"					   },
Packit 6c4009
      },
Packit 6c4009
      /* #06 : Only three chars should be stored in s with a null
Packit 6c4009
	       termination.  */
Packit 6c4009
      { /*input.*/ { 1,1,	       { 0x0041,0x0042,0x0043,0x0000 }, 5  },
Packit 6c4009
	/*expect*/ { 0,1,3,	 "ABC"					   },
Packit 6c4009
      },
Packit 6c4009
      /* #07 : Invalid mb sequence. No chars should be stored in s.  */
Packit 6c4009
      { /*input.*/ { 1,1,	       { 0x0201,0x0221,0x0000,0x0000 }, 2  },
Packit 6c4009
	/*expect*/ { EILSEQ,1,(size_t)-1,	 ""			   },
Packit 6c4009
      },
Packit 6c4009
      /* #08 : s is a null pointer, no chars should be stored in s.  */
Packit 6c4009
      { /*input.*/ { 0,1,	       { 0x0041,0x0042,0x0043,0x0000 }, 0  },
Packit 6c4009
	/*expect*/ { 0,1,3,	 ""					   },
Packit 6c4009
      },
Packit 6c4009
      /* #09 : s is a null pointer, no chars should be stored in s.  */
Packit 6c4009
      { /*input.*/ { 0,1,	       { 0x0041,0x0042,0x0043,0x0000 }, 1  },
Packit 6c4009
	/*expect*/ { 0,1,3,	 ""					   },
Packit 6c4009
      },
Packit 6c4009
      /* #10 : s is a null pointer, no chars should be stored in s.  */
Packit 6c4009
      { /*input.*/ { 0,1,	       { 0x0041,0x0042,0x0043,0x0000 }, 5  },
Packit 6c4009
	/*expect*/ { 0,1,3,	 ""					   },
Packit 6c4009
      },
Packit 6c4009
      /* #11 : s is a null pointer. No chars should be stored in s.  */
Packit 6c4009
      { /*input.*/ { 0,1,	       { 0x0201,0x0221,0x0000,0x0000 }, 5  },
Packit 6c4009
	/*expect*/ { EILSEQ,1,(size_t)-1,	 ""			   },
Packit 6c4009
      },
Packit 6c4009
      /* #12 : ws is a null wc string, no chars should be stored in s.  */
Packit 6c4009
      { /*input.*/ { 1,1,	       { 0x0000 },			5, },
Packit 6c4009
	/*expect*/ { 0,1,0,	 ""			                   },
Packit 6c4009
      },
Packit 6c4009
      /* #13 : s is a null pointer, no chars should be stored in s.  */
Packit 6c4009
      { /*input.*/ { 0,1,	       { 0x0000 },			5  },
Packit 6c4009
	/*expect*/ { 0,1,0,	 ""					   },
Packit 6c4009
      },
Packit 6c4009
      { .is_last = 1 }
Packit 6c4009
    }
Packit 6c4009
  },
Packit 6c4009
  {
Packit 6c4009
    { Twcstombs, TST_LOC_eucJP },
Packit 6c4009
    {
Packit 6c4009
Packit 6c4009
      /* #01 : Any chars including a null char should not be stored in s.  */
Packit 6c4009
      { /*input.*/ { 1,1,	       { 0x3042,0x3044,0xFF73,0x0000 }, 0  },
Packit 6c4009
	/*expect*/ { 0,1,0,	 ""					   },
Packit 6c4009
      },
Packit 6c4009
      /* #02 : Only one chars should be stored in s. No null termination.  */
Packit 6c4009
      { /*input.*/ { 1,1,	       { 0x3042,0x3044,0xFF73,0x0000 }, 2  },
Packit 6c4009
	/*expect*/ { 0,1,2,	     "\244\242"				   },
Packit 6c4009
      },
Packit 6c4009
      /* #03 : Only two chars should be stored in s. No null termination.  */
Packit 6c4009
      { /*input.*/ { 1,1,	       { 0x3042,0x3044,0xFF73,0x0000 }, 4  },
Packit 6c4009
	/*expect*/ { 0,1,4,	     "\244\242\244\244"			   },
Packit 6c4009
      },
Packit 6c4009
      /* #04 : Only three chars should be stored in s. No null
Packit 6c4009
	       termination.  */
Packit 6c4009
      { /*input.*/ { 1,1,	       { 0x3042,0x3044,0xFF73,0x0000 }, 6  },
Packit 6c4009
	/*expect*/ { 0,1,6,	     "\244\242\244\244\216\263"		   },
Packit 6c4009
      },
Packit 6c4009
      /* #05 : Only three chars should be stored in s with a null
Packit 6c4009
	       termination.  */
Packit 6c4009
      { /*input.*/ { 1,1,	       { 0x3042,0x3044,0xFF73,0x0000 }, 7  },
Packit 6c4009
	/*expect*/ { 0,1,6,	     "\244\242\244\244\216\263"		   },
Packit 6c4009
      },
Packit 6c4009
      /* #06 : Only three chars should be stored in s with a null
Packit 6c4009
	       termination.  */
Packit 6c4009
      { /*input.*/ { 1,1,	       { 0x3042,0x3044,0xFF73,0x0000 }, 8  },
Packit 6c4009
	/*expect*/ { 0,1,6,	     "\244\242\244\244\216\263"		   },
Packit 6c4009
      },
Packit 6c4009
      /* #07 : Invalid mb sequence. No chars should be stored in s.  */
Packit 6c4009
      { /*input.*/ { 1,1,	       { 0x0201,0x0221,0x0000,0x0000 }, 2  },
Packit 6c4009
	/*expect*/ { EILSEQ,1,-1,	 ""				   },
Packit 6c4009
      },
Packit 6c4009
      /* #08 : s is a null pointer, no chars should be stored in s.  */
Packit 6c4009
      { /*input.*/ { 0,1,	       { 0x3042,0x3044,0xFF73,0x0000 }, 0  },
Packit 6c4009
	/*expect*/ { 0,1,6,	 ""					   },
Packit 6c4009
      },
Packit 6c4009
      /* #09 : s is a null pointer, no chars should be stored in s.  */
Packit 6c4009
      { /*input.*/ { 0,1,	       { 0x3042,0x3044,0xFF73,0x0000 }, 1  },
Packit 6c4009
	/*expect*/ { 0,1,6,	 ""					   },
Packit 6c4009
      },
Packit 6c4009
      /* #10 : s is a null pointer, no chars should be stored in s.  */
Packit 6c4009
      { /*input.*/ { 0,1,	       { 0x3042,0x3044,0xFF73,0x0000 }, 8  },
Packit 6c4009
	/*expect*/ { 0,1,6,	 ""					   },
Packit 6c4009
      },
Packit 6c4009
      /* #11 : s is a null pointer. No chars should be stored in s.  */
Packit 6c4009
      { /*input.*/ { 0,1,	       { 0x0201,0x0221,0x0000,0x0000 }, 5  },
Packit 6c4009
	/*expect*/ { EILSEQ,1,(size_t)-1,	 ""			   },
Packit 6c4009
      },
Packit 6c4009
      /* #12 : ws is a null wc string, no chars should be stored in s.  */
Packit 6c4009
      { /*input.*/ { 1,1,	       { 0x0000 },			5  },
Packit 6c4009
	/*expect*/ { 0,1,0,	 ""					   },
Packit 6c4009
      },
Packit 6c4009
      /* #13 : s is a null pointer, no chars should be stored in s.  */
Packit 6c4009
      { /*input.*/ { 0,1,	       { 0x0000 },			5  },
Packit 6c4009
	/*expect*/ { 0,1,0,	 ""					   },
Packit 6c4009
      },
Packit 6c4009
      { .is_last = 1 }
Packit 6c4009
    }
Packit 6c4009
  },
Packit 6c4009
  {
Packit 6c4009
    { Twcstombs, TST_LOC_end }
Packit 6c4009
  }
Packit 6c4009
};