about summary refs log tree commit diff
path: root/localedata/tests-mbwc
diff options
context:
space:
mode:
authorAndreas Jaeger <aj@suse.de>2000-06-29 07:13:12 +0000
committerAndreas Jaeger <aj@suse.de>2000-06-29 07:13:12 +0000
commit2e23c3cc3fede8cc080af74f1b4f124b12955138 (patch)
tree40f76b9203246a3e70247b56743b442313179732 /localedata/tests-mbwc
parent4eeccd750dce53d7b168d227cb5cfcf70d674310 (diff)
downloadglibc-2e23c3cc3fede8cc080af74f1b4f124b12955138.tar.gz
glibc-2e23c3cc3fede8cc080af74f1b4f124b12955138.tar.xz
glibc-2e23c3cc3fede8cc080af74f1b4f124b12955138.zip
Update.
2000-06-29  Andreas Jaeger  <aj@suse.de>

	* Makefile (locale_test_suite): Add new test files.
	(tst_mblen-ENV): New.
	(tst_mbtowc-ENV): New.
	(tst_strcoll-ENV): New.
	(tst_strxfrm-ENV): New.
	(tst_wctomb-ENV): New.

	* tests-mbwc/tst_wctomb.c: New test file from Shoji Kuwabara
	<kuwahara@cthulhu.engr.sgi.com>.
	* tests-mbwc/dat_wctomb.c: Likewise.
	* tests-mbwc/tst_mbtowc.c: Likewise.
	* tests-mbwc/dat_mbtowc.c: Likewise.
	* tests-mbwc/tst_strxfrm.c: Likewise.
	* tests-mbwc/dat_strxfrm.c: Likewise.
	* tests-mbwc/dat_strcoll.c: Likewise.
	* tests-mbwc/tst_strcoll.c: Likewise.
	* tests-mbwc/tst_mblen.c: Likewise.
	* tests-mbwc/dat_mblen.c: Likewise.
Diffstat (limited to 'localedata/tests-mbwc')
-rw-r--r--localedata/tests-mbwc/dat_mbtowc.c327
-rw-r--r--localedata/tests-mbwc/dat_strcoll.c144
-rw-r--r--localedata/tests-mbwc/dat_strxfrm.c112
-rw-r--r--localedata/tests-mbwc/dat_wctomb.c139
-rw-r--r--localedata/tests-mbwc/tst_mbtowc.c126
-rw-r--r--localedata/tests-mbwc/tst_strcoll.c87
-rw-r--r--localedata/tests-mbwc/tst_strxfrm.c136
-rw-r--r--localedata/tests-mbwc/tst_wctomb.c99
8 files changed, 1170 insertions, 0 deletions
diff --git a/localedata/tests-mbwc/dat_mbtowc.c b/localedata/tests-mbwc/dat_mbtowc.c
new file mode 100644
index 0000000000..1e3359465c
--- /dev/null
+++ b/localedata/tests-mbwc/dat_mbtowc.c
@@ -0,0 +1,327 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *	 FILE:	dat_mbtowc.c
+ *
+ *	 MBTOWC:  int  mbtowc (wchar_t *wp, char *s, size_t n);
+ */
+
+/*  NOTE:
+ *
+ *	 int  mbtowc (wchar_t *wp, char *s, size_t n);
+ *
+ *	 where	     n: a maximum number of bytes
+ *		return: the number of bytes
+ *
+ *
+ *	  o When you feed a null pointer for a string (s) to the function,
+ *	    set s_flg=0 instead of putting just a 'NULL' there.
+ *	    Even if you put a 'NULL', it means a null string as well as "".
+ *
+ *	  o When s is a null pointer, the function checks state dependency.
+ *
+ *		state-dependent encoding      - return	NON-zero
+ *		state-independent encoding    - return	0
+ *
+ *	    If state-dependent encoding is expected, set
+ *
+ *		s_flg = 0,  ret_flg = 0,  ret_val = +1
+ *
+ *	    If state-independent encoding is expected, set
+ *
+ *		s_flg = 0,  ret_flg = 0,  ret_val = 0
+ *
+ *
+ *	    When you set ret_flg=1, the test program simply compares
+ *	    an actual return value with an expected value. You can
+ *	    check state-independent case (return value is 0) in that
+ *	    way, but you can not check state-dependent case. So when
+ *	    you check state- dependency in this test function:
+ *	    tst_mbtowc(), set ret_flg=0 always. It's a special case
+ *	    and the test function takes care of it.
+ *
+ *			  w_flg
+ *			  |	s: (a null string; can't be (char *)NULL)
+ *			  |	|
+ *	       input.	{ 1, 0, (char)NULL, MB_LEN_MAX	},
+ *			     |
+ *			     s_flg=0: makes _s_ a null pointer.
+ *
+ *	       expect	{ 0,0,0,x,     0x0000	  },
+ *			      | |
+ *			      | ret_val: 0/+1
+ *			      ret_flg=0
+ *
+ *
+ *    Test data for State dependent encodings:
+ *
+ *	  mbtowc( NULL, NULL, 0 );	 ... first  data
+ *	  mbtowc( &wc,	s1,  n1 );	 ... second data
+ *	  mbtowc( &wc,	s2,  n2 );	 ... third  data
+ * */
+
+#include <limits.h>
+
+TST_MBTOWC tst_mbtowc_loc [] = {
+  {
+    { Tmbtowc, TST_LOC_de },
+    {
+      { /*----------------- #01 -----------------*/
+	{
+	  {
+	    { 1, 1, "üäö",	    1	       },
+	    { 1, 1, "üäö",	    2	       },
+	    { 1, 1, "üäö",	    MB_LEN_MAX },
+	  }
+	},
+	{
+	  {
+	    { 0,	  0,  1,  1,   0x00FC },
+	    { 0,	  0,  1,  1,   0x00FC },
+	    { 0,	  0,  1,  1,   0x00FC },
+	  }
+	}
+      },
+      { /*----------------- #02 -----------------*/
+	{
+	  {
+	    { 1, 1, "\177",	    MB_LEN_MAX },
+	    { 1, 1, "\200",	    MB_LEN_MAX },
+	    { 1, 1, "\201",	    MB_LEN_MAX },
+	  }
+	},
+	{
+	  {
+	    { 0,	  0,  1,  1,   0x007F },
+	    { 1,	  0,  1,  1,   0x0080 },
+	    { 1,	  0,  1,  1,   0x0081 },
+	  }
+	}
+      },
+      { /*----------------- #03 -----------------*/
+	{
+	  {
+	    { 1, 1, "",	    MB_LEN_MAX },
+	    { 0, 1, "üäö",	    1	       },
+	    { 0, 1, "üäö",	    2	       },
+	  }
+	},
+	{
+	  {
+	    { 0,	  0,  1,  0,   0x0000 },
+	    { 0,	  0,  1,  1,   0x0000 },
+	    { 0,	  0,  1,  1,   0x0000 },
+	  }
+	}
+      },
+      { /*----------------- #04 -----------------*/
+	{
+	  {
+	    { 0, 1, "üäö",	    MB_LEN_MAX },
+	    { 0, 1, "\177",	    MB_LEN_MAX },
+	    { 0, 1, "",	    MB_LEN_MAX },
+	  }
+	},
+	{
+	  {
+	    { 0,	  0,  1,  1,   0x0000 },
+	    { 0,	  0,  1,  1,   0x0000 },
+	    { 0,	  0,  1,  0,   0x0000 },
+	  }
+	}
+      },
+      { /*----------------- #05 -----------------*/
+	{
+	  {
+	    { 0, 1, "üäö",	    MB_LEN_MAX },
+	    { 0, 1, "\177",	    MB_LEN_MAX },
+	    { 0, 0, (char)NULL, MB_LEN_MAX },
+	  }
+	},
+	{
+	  {
+	    { 0,	  0,  1,  1,   0x0000 },
+	    { 0,	  0,  1,  1,   0x0000 },
+	    { 0,	  0,  0,  0,   0x0000 },
+	  }
+	}
+      },
+      { is_last: 1 }
+    }
+  },
+  {
+    { Tmbtowc, TST_LOC_enUS },
+    {
+      { /*----------------- #01 -----------------*/
+	{
+	  {
+	    { 1, 1, "ABC",	    1	       },
+	    { 1, 1, "ABC",	    2	       },
+	    { 1, 1, "ABC",	    MB_LEN_MAX },
+	  }
+	},
+	{
+	  {
+	    { 0,	  0,  1,  1,   0x0041 },
+	    { 0,	  0,  1,  1,   0x0041 },
+	    { 0,	  0,  1,  1,   0x0041 },
+	  }
+	}
+      },
+      { /*----------------- #02 -----------------*/
+	{
+	  {
+	    { 1, 1, "\177",	    MB_LEN_MAX },
+	    { 1, 1, "\200",	    MB_LEN_MAX },
+	    { 1, 1, "\201",	    MB_LEN_MAX },
+	  }
+	},
+	{
+	  {
+	    { 0,	  0,  1,  1,   0x007F },
+	    { 1, EILSEQ,  1, -1,   0x0000 },
+	    { 1, EILSEQ,  1, -1,   0x0000 },
+	  }
+	}
+      },
+      { /*----------------- #03 -----------------*/
+	{
+	  {
+	    { 1, 1, "",	    MB_LEN_MAX },
+	    { 0, 1, "ABC",	    1	       },
+	    { 0, 1, "ABC",	    2	       },
+	  }
+	},
+	{
+	  {
+	    { 0,	  0,  1,  0,   0x0000 },
+	    { 0,	  0,  1,  1,   0x0000 },
+	    { 0,	  0,  1,  1,   0x0000 },
+	  }
+	}
+      },
+      { /*----------------- #04 -----------------*/
+	{
+	  {
+	    { 0, 1, "ABC",	    MB_LEN_MAX },
+	    { 0, 1, "\177",	    MB_LEN_MAX },
+	    { 0, 1, "",	    MB_LEN_MAX },
+	  }
+	},
+	{
+	  {
+	    { 0,	  0,  1,  1,   0x0000 },
+	    { 0,	  0,  1,  1,   0x0000 },
+	    { 0,	  0,  1,  0,   0x0000 },
+	  }
+	}
+      },
+      { /*----------------- #05 -----------------*/
+	{
+	  {
+	    { 0, 1, "ABC",	    MB_LEN_MAX },
+	    { 0, 1, "\177",	    MB_LEN_MAX },
+	    { 0, 0, (char)NULL, MB_LEN_MAX },
+	  }
+	},
+	{
+	  {
+	    { 0,	  0,  1,  1,   0x0000 },
+	    { 0,	  0,  1,  1,   0x0000 },
+	    { 0,	  0,  0,  0,   0x0000 },
+	  }
+	}
+      },
+      { is_last: 1 }
+    }
+  },
+  {
+    { Tmbtowc, TST_LOC_eucJP },
+    {
+      { /*----------------- #01 -----------------*/
+	{
+	  {
+	    { 1, 1, "\244\242A",      1          },
+	    { 1, 1, "\244\242A",      2          },
+	    { 1, 1, "\244\242A",      MB_LEN_MAX },
+	  }
+	},
+	{
+	  {
+	    { 1, EILSEQ,  1, -1,   0x0000 },
+	    { 0,	  0,  1,  2,   0x3042 },
+	    { 0,	  0,  1,  2,   0x3042 },
+	  }
+	}
+      },
+      { /*----------------- #02 -----------------*/
+	{
+	  {
+	    { 1, 1, "\177\244\242",   MB_LEN_MAX },
+	    { 1, 1, "\200\244\242",   MB_LEN_MAX },
+	    { 1, 1, "\201\244\242",   MB_LEN_MAX },
+	  }
+	},
+	{
+	  {
+	    { 0,	  0,  1, +1,   0x007F },
+	    { 1, EILSEQ,  1, -1,   0x0000 },
+	    { 1, EILSEQ,  1, -1,   0x0000 },
+	  }
+	}
+      },
+      { /*----------------- #03 -----------------*/
+	{
+	  {
+	    { 1, 1, "",         MB_LEN_MAX },
+	    { 0, 1, "\244\242A",      1          },
+	    { 0, 1, "\244\242A",      2          },
+	  }
+	},
+	{
+	  {
+	    { 0,	  0,  1,  0,   0x0000 },
+	    { 1, EILSEQ,  1, -1,   0x0000 },
+	    { 0,	  0,  1,  2,   0x0000 },
+	  }
+	}
+      },
+      { /*----------------- #04 -----------------*/
+	{
+	  {
+	    { 0, 1, "\244\242A",      MB_LEN_MAX },
+	    { 0, 1, "\177\244\242",   MB_LEN_MAX },
+	    { 0, 1, "",         MB_LEN_MAX },
+	  }
+	},
+	{
+	  {
+	    { 0,	  0,  1,  2,   0x0000 },
+	    { 0,	  0,  1, +1,   0x0000 },
+	    { 0,	  0,  1,  0,   0x0000 },
+	  }
+	}
+      },
+      { /*----------------- #05 -----------------*/
+	{
+	  {
+	    { 0, 1, "\244\242A",      MB_LEN_MAX },
+	    { 0, 1, "\177\244\242",   MB_LEN_MAX },
+	    { 0, 0, (char)NULL, MB_LEN_MAX },
+	  }
+	},
+	{
+	  {
+	    { 0,	  0,  1,  2,   0x0000 },
+	    { 0,	  0,  1, +1,   0x0000 },
+	    { 0,	  0,  0,  0,   0x0000 },
+	  }
+	}
+      },
+      { is_last: 1 }
+    }
+  },
+  {
+    { Tmbtowc, TST_LOC_end }
+  }
+};
diff --git a/localedata/tests-mbwc/dat_strcoll.c b/localedata/tests-mbwc/dat_strcoll.c
new file mode 100644
index 0000000000..6d7e7e5ee2
--- /dev/null
+++ b/localedata/tests-mbwc/dat_strcoll.c
@@ -0,0 +1,144 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *	 FILE: dat_strcoll.c
+ *
+ *	 STRCOLL:  int strcoll (const char *s1, const char *s2);
+ */
+
+/*
+   NOTE:
+
+   If a return value is expected to be 0, set ret_flg=1 and the
+   expected value = 0.	If a return value is expected to be a
+   positive/negative value, set ret_flg=0, and set the expected value
+   = +1/-1.
+   There is inconsistensy between tst_strcoll() and tst_wcscoll()(it
+   has cmp_flg) for input data. I'll fix it.
+
+   Assuming en_US to be en_US.ascii. (maybe, should be iso8859-1).
+
+
+
+   ASCII CODE  : A,B,C, ...  , a, b, c, ...	 B,a:-1	  a,B:+1
+   DICTIONARY : A,a,B,b,C,c,....  a,B:-1 B,a:+1 */
+
+TST_STRCOLL tst_strcoll_loc [] = {
+  {
+    { Tstrcoll, TST_LOC_de },
+    {
+      { /*input.*/ { "ÄBCDEFG", "ÄBCDEFG"	      },  /* #1 */
+	/*expect*/ { 1,0,1,0,			      },
+      },
+      { /*input.*/ { "XX Ä XX", "XX B XX"	      },  /* #2 */
+	/*expect*/ { 1,0,0,-1,			      },
+      },
+      { /*input.*/ { "XX B XX", "XX Ä XX"	      },  /* #3 */
+	/*expect*/ { 1,0,0,+1,			      },
+      },
+      { /*input.*/ { "B",	"a"		      },  /* #4 */
+	/*expect*/ { 1,0,0,+1,			      },
+      },
+      { /*input.*/ { "a",	"B"		      },  /* #5 */
+	/*expect*/ { 1,0,0,-1,			      },
+      },
+      { /*input.*/ { "b",	"A"		      },  /* #6 */
+	/*expect*/ { 1,0,0,+1,			      },
+      },
+      { /*input.*/ { "A",	"b"		      },  /* #7 */
+	/*expect*/ { 1,0,0,-1,			      },
+      },
+      { /*input.*/ { "ä",	"B"		      },  /* #8 */
+	/*expect*/ { 1,0,0,-1,			      },
+      },
+      { /*input.*/ { "B",	"ä"		      },  /* #9 */
+	/*expect*/ { 1,0,0,+1,			      },
+      },
+      { is_last: 1 } /* Last element.  */
+    }
+  },
+  {
+    { Tstrcoll, TST_LOC_enUS },
+    {
+      { /*input.*/ { "ABCDEFG", "ABCDEFG"	      },  /* #1 */
+	/*expect*/ { 1,0,1,0,			      },
+      },
+      { /*input.*/ { "XX a XX", "XX B XX"	      },  /* #2 */
+	/*expect*/ { 1,0,0,-1,			      },
+      },
+      { /*input.*/ { "XX B XX", "XX a XX"	      },  /* #3 */
+	/*expect*/ { 1,0,0,+1,			      },
+      },
+      {
+	/* <WAIVER> */
+	/*input.*/ { "B",	"a"		      },  /* #4 */
+	/*expect*/ { 1,0,0,-1,			      },
+      },
+      {
+	/* <WAIVER> */
+	/*input.*/ { "a",	"B"		      },  /* #5 */
+	/*expect*/ { 1,0,0,+1,			      },
+      },
+      { /*input.*/ { "b",	"A"		      },  /* #6 */
+	/*expect*/ { 1,0,0,+1,			      },
+      },
+      { /*input.*/ { "A",	"b"		      },  /* #7 */
+	/*expect*/ { 1,0,0,-1,			      },
+      },
+      {
+	/* #8 */  /* <WAIVER> */
+	/*input.*/ { "\244\242\244\244\244\246\244\250\244\252", "ABCDEFG" },
+	/*expect*/ { 1,EINVAL,0,0,		      },
+      },
+      {
+	/* #9 */  /* <WAIVER> */
+	/*input.*/ { "ABCZEFG", "\244\242\244\244\244\246\244\250\244\252" },
+	/*expect*/ { 1,EINVAL,0,0,		      },
+      },
+      { is_last: 1 } /* Last element.  */
+    }
+  },
+  {
+    { Tstrcoll, TST_LOC_eucJP },
+    {
+      { /*input.*/ { "\244\242\244\244\244\246\244\250\244\252",
+		     "\244\242\244\244\244\246\244\250\244\252" },  /* #1 */
+	/*expect*/ { 1,0,1,0,			      },
+      },
+      { /*input.*/ { "\244\242\244\244\244\246\244\250\244\252",
+		     "\244\242\244\244\244\363\244\250\244\252" },  /* #2 */
+	/*expect*/ { 1,0,0,-1,			      },
+      },
+      { /*input.*/ { "\244\242\244\244\244\363\244\250\244\252",
+		     "\244\242\244\244\244\246\244\250\244\252" },  /* #3 */
+	/*expect*/ { 1,0,0,+1,			      },
+      },
+      { /*input.*/ { "B",	"a"		      },  /* #4 */
+	/*expect*/ { 1,0,0,-1,			      },
+      },
+      { /*input.*/ { "a",	"B"		      },  /* #5 */
+	/*expect*/ { 1,0,0,+1,			      },
+      },
+      { /*input.*/ { "b",	"A"		      },  /* #6 */
+	/*expect*/ { 1,0,0,+1,			      },
+      },
+      { /*input.*/ { "A",	"b"		      },  /* #7 */
+	/*expect*/ { 1,0,0,-1,			      },
+      },
+      {
+	/* <WAIVER> */
+	/*input.*/ { "\200\216\217", "ABCDEFG"	      },  /* #8 */
+	/*expect*/ { 1,EINVAL,0,0,		      },
+      },
+      {
+	/* <WAIVER> */
+	/*input.*/ { "ABCZEFG", "\200\216\217"	      },  /* #9 */
+	/*expect*/ { 1,EINVAL,0,0,		      },
+      },
+      { is_last: 1 } /* Last element.  */
+    }
+  },
+  {
+    { Tstrcoll, TST_LOC_end }
+  }
+};
diff --git a/localedata/tests-mbwc/dat_strxfrm.c b/localedata/tests-mbwc/dat_strxfrm.c
new file mode 100644
index 0000000000..2737f50383
--- /dev/null
+++ b/localedata/tests-mbwc/dat_strxfrm.c
@@ -0,0 +1,112 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN CLIBRARY
+ *
+ *	 FILE:	dat_strxfrm.c
+ *
+ *	 STRXFRM:  size_t strxfrm (char *s1, const char s2, size_t n);
+ */
+
+
+/*
+ *  NOTE:
+ *
+ *  Return value and errno value are checked only for 2nd string:
+ *  org2[]; n1 and n2 don't mean bytes to be translated.
+ *  It means a buffer size including a null character.
+ *  Results of this test depens on results of strcoll().
+ *  If you got errors, check both test results.
+ *
+ *  The buffer size should be enough to contain a string including a
+ *  null char.	Returns the number of bytes of the string (NOT
+ *  including a null char).
+ */
+
+
+
+TST_STRXFRM tst_strxfrm_loc [] = {
+  {
+    { Tstrxfrm, TST_LOC_de },
+    {
+      { /*inp*/ { "öÄäü", "öÄäü",	    17, 17 },  /* #01 */
+	/*exp*/ { 1,0,0,0,			   },
+      },
+      { /*inp*/ { "aA", "Aa",	    10, 10 },  /* #02 */
+	/*exp*/ { 1,0,0,0 ,			   },
+      },
+      { /*inp*/ { "Aa", "aA",	    10, 10 },  /* #03 */
+	/*exp*/ { 1,0,0,0,			   },
+      },
+      { /*inp*/ { "abc", "",	    13, 13 },  /* #04 */
+	/*exp*/ { 1,0,0,0,			   },
+      },
+      { /*inp*/ { "a", "B",		     7,	 7 },  /* #05 */
+	/*exp*/ { 1,0,0,0,			   },
+      },
+      { /*inp*/ { "B", "a",		     7,	 7 },  /* #06 */
+	/*exp*/ { 1,0,0,0,			   },
+      },
+      {
+	/* hiragana == latin1 */
+	/*inp*/ { "abc", "\244\241\244\242",  13,  9 },	 /* #07 */
+	/*exp*/ { 1,0,0,0,		       },
+      },
+      { is_last: 1 }
+    }
+  },
+  {
+    { Tstrxfrm, TST_LOC_enUS },
+    {
+      { /*inp*/ { "abcd", "abcd",	    17, 17 },  /* #01 */
+	/*exp*/ { 1,0,0,0,			   },
+      },
+      { /*inp*/ { "aA", "Aa",	    10, 10 },  /* #02 */
+	/*exp*/ { 1,0,0,0 ,			   },
+      },
+      { /*inp*/ { "Aa", "aA",	    10, 10 },  /* #03 */
+	/*exp*/ { 1,0,0,0,			   },
+      },
+      { /*inp*/ { "abc", "",	    13, 13 },  /* #04 */
+	/*exp*/ { 1,0,0,0,			   },
+      },
+      { /*inp*/ { "a", "B",		     7,	 7 },  /* #05 */
+	/*exp*/ { 1,0,0,0,			   },
+      },
+      { /*inp*/ { "B", "a",		     7,	 7 },  /* #06 */
+	/*exp*/ { 1,0,0,0,			   },
+      },
+      {
+	/* <WAIVER> */
+	/*inp*/ { "abc", "\244\241\244\242",  13,  9 },	 /* #07 */
+	/*exp*/ { 1,EINVAL,0,0,		       },
+      },
+      { is_last: 1 }
+    }
+  },
+  {
+    { Tstrxfrm, TST_LOC_eucJP },	 /* ??? */
+    {
+      {
+	/* #01 */
+	/*inp*/ { "\244\242\244\241",  "\244\241\244\242",   5,	 5 },
+	/*exp*/ { 1,0,0,0,		       },
+      },
+      {
+	/* #02 */
+	/*inp*/ { "\244\241\244\242",  "\244\242\244\241",   5,	 5 },
+	/*exp*/ { 1,0,0,0,		       },
+      },
+      {
+	/* #03 */
+	/*inp*/ { "\244\242\216\261",  "\216\261\244\242",   5,	 5 },
+	/*exp*/ { 1,0,0,0,		       },
+      },
+      { /*inp*/ { "AAA", "\216\217",	 5,  5 },  /* #04 */ /* <WAIVER> */
+	/*exp*/ { 1,EINVAL,0,0,		       },
+      },
+      { is_last: 1 }
+    }
+  },
+  {
+    { Tstrxfrm, TST_LOC_end }
+  }
+};
diff --git a/localedata/tests-mbwc/dat_wctomb.c b/localedata/tests-mbwc/dat_wctomb.c
new file mode 100644
index 0000000000..07e1d48402
--- /dev/null
+++ b/localedata/tests-mbwc/dat_wctomb.c
@@ -0,0 +1,139 @@
+/*
+ *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
+ *
+ *	 FILE:	dat_wctomb.c
+ *
+ *	 WCTOMB:  int wctomb (char *s, wchar_t wc)
+ */
+
+
+/*
+ *  FUNCTION:
+ *
+ *	  int  wctomb (char *s, wchar_t wc);
+ *
+ *	       return: the number of bytes
+ *
+ *  NOTE:
+ *
+ *	 o When you feed a null pointer for a string (s) to the function,
+ *	   set s_flg=0 instead of putting just a 'NULL' there.
+ *	   Even if you put a 'NULL', it means a null string as well as "".
+ *
+ *	 o When s is a null pointer, the function checks state dependency.
+ *
+ *	       state-dependent encoding	     - return  NON-zero
+ *	       state-independent encoding    - return  0
+ *
+ *	   If state-dependent encoding is expected, set
+ *
+ *	       s_flg = 0,  ret_flg = 0,	 ret_val = +1
+ *
+ *	   If state-independent encoding is expected, set
+ *
+ *	       s_flg = 0,  ret_flg = 0,	 ret_val = 0
+ *
+ *
+ *	   When you set ret_flg=1, the test program simply compares an
+ *	   actual return value with an expected value. You can check
+ *	   state-independent case (return value is 0) in that way, but
+ *	   you can not check state-dependent case. So when you check
+ *	   state- dependency in this test function: tst_wctomb(), set
+ *	   ret_flg=0 always. It's a special case, and the test
+ *	   function takes care of it.
+ *
+ *	      Input	  Expect
+ *
+ *		s_flg=0		  ret_flg=0
+ *		|		  |
+ *	      { 0, 0 },	  { 0, 0, 0,  x,  "" }
+ *		   |		      |
+ *		   not used	      ret_val: 0/+1
+ * (expected val)
+ */
+
+
+TST_WCTOMB tst_wctomb_loc [] = {
+  {
+    { Twctomb, TST_LOC_de },
+    {
+      /* #01 : normal case		   */
+      { /*input.*/ { 1,	   0x00C4  },
+	/*expect*/ { 0,0,1,1,  "Ä"	   },
+      },
+      /* #02 : normal case		   */
+      { /*input.*/ { 1,	   0x00DC  },
+	/*expect*/ { 0,0,1,1,  "Ü"	   },
+      },
+      /* #03 : normal case		   */
+      { /*input.*/ { 1,	   0x0092  },
+	/*expect*/ { 0,0,1,1,  "\222"  },
+      },
+      /* #04 : error case		   */
+      { /*input.*/ { 1,	   0x3041  },
+	/*expect*/ { 0,0,1,-1, ""	   },
+      },
+      /* #05 : state dependency	   */
+      { /*input.*/ { 0,	   0x0000  },
+	/*expect*/ { 0,0,0,0,  ""	   },
+      },
+      { is_last: 1 }
+    }
+  },
+  {
+    { Twctomb, TST_LOC_enUS },
+    {
+      /* #01 : normal case		   */
+      { /*input.*/ { 1,	   0x0041  },
+	/*expect*/ { 0,0,1,1,  "A"	   },
+      },
+      /* #02 : normal case		   */
+      { /*input.*/ { 1,	   0x0042  },
+	/*expect*/ { 0,0,1,1,  "B"	   },
+      },
+      /* #03 : error case		   */
+      /* <WAIVER> */
+      { /*input.*/ { 1,	   0x00C4  },
+	/*expect*/ { 0,0,1,-1, ""	   },
+      },
+      /* #04 : error case		   */
+      { /*input.*/ { 1,	   0x30A4  },
+	/*expect*/ { 0,0,1,-1, ""	   },
+      },
+      /* #05 : state dependency	   */
+      { /*input.*/ { 0,	   0x0000  },
+	/*expect*/ { 0,0,0,0,  ""	   },
+      },
+      { is_last: 1 }
+    }
+  },
+  {
+    { Twctomb, TST_LOC_eucJP },
+    {
+      /* #01 : normal case		   */
+      { /*input.*/ { 1,	   0x3042  },
+	/*expect*/ { 0,0,1,2,  "\244\242"   },
+      },
+      /* #02 : normal case		   */
+      { /*input.*/ { 1,	   0x3044  },
+	/*expect*/ { 0,0,1,2,  "\244\244"   },
+      },
+      /* #03 : normal case		   */
+      { /*input.*/ { 1,	   0x008E  },
+	/*expect*/ { 0,0,1,-1, ""	   },
+      },
+      /* #04 : jisX0212		   */
+      { /*input.*/ { 1,	   0x00C4	  },
+	/*expect*/ { 0,0,1,3,  "\217\252\243" }, /* jisx0210  returns 3 */
+      },
+      /* #05 : state dependency	   */
+      { /*input.*/ { 0,	   0x008E  },
+	/*expect*/ { 0,0,0,0,  ""	   },
+      },
+      { is_last: 1 }
+    }
+  },
+  {
+    { Twctomb, TST_LOC_end }
+  }
+};
diff --git a/localedata/tests-mbwc/tst_mbtowc.c b/localedata/tests-mbwc/tst_mbtowc.c
new file mode 100644
index 0000000000..c525941f60
--- /dev/null
+++ b/localedata/tests-mbwc/tst_mbtowc.c
@@ -0,0 +1,126 @@
+/*
+  MBTOWC: int mbtowc (wchar_t *wc, char *s, size_t n)
+*/
+
+#define TST_FUNCTION mbtowc
+
+#include "tsp_common.c"
+#include "dat_mbtowc.c"
+
+
+int
+tst_mbtowc (FILE * fp, int debug_flg)
+{
+  TST_DECL_VARS (int);
+  char w_flg, s_flg;
+  const char *s_in;
+  size_t n;
+  wchar_t wc, wc_ex, *wp;
+
+  TST_DO_TEST (mbtowc)
+  {
+    TST_HEAD_LOCALE (mbtowc, S_MBTOWC);
+    TST_DO_REC (mbtowc)
+    {
+      if (mbstowcs (NULL, "", 0) != 0)
+	{
+	  err_count++;
+	  Result (C_FAILURE, S_MBSTOWCS, CASE_3,
+		  "Initialization failed - skipping this test case.");
+	  continue;
+	}
+
+      TST_DO_SEQ (MBTOWC_SEQNUM)
+      {
+	TST_GET_ERRET_SEQ (mbtowc);
+	w_flg = TST_INPUT_SEQ (mbtowc).w_flg;
+	s_flg = TST_INPUT_SEQ (mbtowc).s_flg;
+	n = TST_INPUT_SEQ (mbtowc).n;
+
+	if (n == USE_MBCURMAX)
+	  {
+	    n = MB_CUR_MAX;
+	  }
+
+	if (s_flg == 0)
+	  s_in = NULL;
+	else
+	  s_in = TST_INPUT_SEQ (mbtowc).s;
+
+	wp = (wchar_t *) ((w_flg == 0) ? NULL : &wc);
+
+	TST_CLEAR_ERRNO;
+	ret = mbtowc (wp, s_in, n);
+	TST_SAVE_ERRNO;
+
+	if (debug_flg)
+	  {
+	    fprintf (stdout, "mbtowc() [ %s : %d ] ret = %d\n", locale,
+		     rec + 1, ret);
+	    fprintf (stdout, "			   errno      = %d\n",
+		     errno_save);
+	  }
+
+	TST_IF_RETURN (S_MBTOWC)
+	{
+	  if (s_in == NULL)
+	    {			/* state dependency */
+	      if (ret_exp == +1)
+		{		/* state-dependent  */
+		  if (ret != 0)
+		    {
+		      /* Non-zero: state-dependent encoding.  */
+		      Result (C_SUCCESS, S_MBTOWC, CASE_3, MS_PASSED);
+		    }
+		  else
+		    {
+		      err_count++;
+		      Result (C_FAILURE, S_MBTOWC, CASE_3,
+			      "should be state-dependent encoding, "
+			      "but a return value shows it is "
+			      "state-independent");
+		    }
+		}
+
+	      if (ret_exp == 0)
+		{		/* state-independent */
+		  if (ret == 0)
+		    {
+		      /* Non-zero: state-dependent encoding.  */
+		      Result (C_SUCCESS, S_MBTOWC, CASE_3, MS_PASSED);
+		    }
+		  else
+		    {
+		      err_count++;
+		      Result (C_FAILURE, S_MBTOWC, CASE_3,
+			      "should be state-independent encoding, "
+			      "but a return value shows it is "
+			      "state-dependent");
+		    }
+		}
+	    }
+	}
+
+	if ((wp == NULL || s_in == NULL || s_in[0] == 0) || ret <= 0)
+	  {
+	    continue;
+	  }
+
+	wc_ex = TST_EXPECT_SEQ (mbtowc).wc;
+
+	if (wc_ex == wc)
+	  {
+	    Result (C_SUCCESS, S_MBTOWC, CASE_4, MS_PASSED);
+	  }
+	else
+	  {
+	    err_count++;
+	    Result (C_FAILURE, S_MBTOWC, CASE_4,
+		    "converted wc is different from an expected wc");
+	  }
+      }
+    }
+  }
+
+  return err_count;
+}
diff --git a/localedata/tests-mbwc/tst_strcoll.c b/localedata/tests-mbwc/tst_strcoll.c
new file mode 100644
index 0000000000..4c5a84f697
--- /dev/null
+++ b/localedata/tests-mbwc/tst_strcoll.c
@@ -0,0 +1,87 @@
+/*
+  STRCOLL: int strcoll (const char *s1, const char *s2)
+*/
+
+#define TST_FUNCTION strcoll
+
+#include "tsp_common.c"
+#include "dat_strcoll.c"
+
+int
+tst_strcoll (FILE * fp, int debug_flg)
+{
+  TST_DECL_VARS (int);
+  const char *s1, *s2;
+
+  TST_DO_TEST (strcoll)
+  {
+    TST_HEAD_LOCALE (strcoll, S_STRCOLL);
+    TST_DO_REC (strcoll)
+    {
+      TST_GET_ERRET (strcoll);
+      s1 = TST_INPUT (strcoll).s1;
+      s2 = TST_INPUT (strcoll).s2;
+
+      TST_CLEAR_ERRNO;
+      ret = strcoll (s1, s2);
+      TST_SAVE_ERRNO;
+
+      if (debug_flg)
+	{
+	  fprintf (stdout, "strcoll() [ %s : %d ] ret = %d\n", locale,
+		   rec + 1, ret);
+	  fprintf (stdout, "			    errno = %d\n",
+		   errno_save);
+	  fprintf (stdout, "			    LC_COLLATE = %s\n",
+		   (setlocale (LC_COLLATE, NULL)) ? setlocale (LC_COLLATE,
+							       NULL) : "");
+	}
+
+      TST_IF_RETURN (S_STRCOLL)
+      {
+	if (ret_exp == +1)
+	  {
+	    if (ret > 0)
+	      {
+		Result (C_SUCCESS, S_STRCOLL, CASE_3, MS_PASSED);
+	      }
+	    else
+	      {
+		err_count++;
+		Result (C_FAILURE, S_STRCOLL, CASE_3,
+			"the return value should be greater than 0,"
+			" but is not ...");
+	      }
+	  }
+	else if (ret_exp == -1)
+	  {
+	    if (ret < 0)
+	      {
+		Result (C_SUCCESS, S_STRCOLL, CASE_3, MS_PASSED);
+	      }
+	    else
+	      {
+		err_count++;
+		Result (C_FAILURE, S_STRCOLL, CASE_3,
+			"the return value should less than 0, but not ...");
+	      }
+	  }
+	else if (ret_exp != 0)
+	  {
+	    if (debug_flg)
+	      {
+		fprintf (stderr, "*** Warning *** : tst_strcoll : "
+			 "(check the test data); should set ret_flg=1"
+			 " to check a return value");
+	      }
+
+	    warn_count++;
+	    Result (C_INVALID, S_WCSCHR, CASE_3, "(check the test data); "
+		    "should set ret_flg=1 to check a return value");
+	  }
+      }
+    }
+  }
+
+  return err_count;
+}
diff --git a/localedata/tests-mbwc/tst_strxfrm.c b/localedata/tests-mbwc/tst_strxfrm.c
new file mode 100644
index 0000000000..0a3789399c
--- /dev/null
+++ b/localedata/tests-mbwc/tst_strxfrm.c
@@ -0,0 +1,136 @@
+/*
+  STRXFRM: size_t strxfrm (char *s1, const char *s2, size_t n)
+*/
+
+#define TST_FUNCTION strxfrm
+
+#include "tsp_common.c"
+#include "dat_strxfrm.c"
+
+
+int
+tst_strxfrm (FILE * fp, int debug_flg)
+{
+  TST_DECL_VARS (size_t);
+  const char *org1, *org2;
+  char frm1[MBSSIZE], frm2[MBSSIZE];
+  size_t n1, n2;
+  int ret_coll, ret_cmp;
+
+  TST_DO_TEST (strxfrm)
+  {
+    TST_HEAD_LOCALE (strxfrm, S_STRXFRM);
+    TST_DO_REC (strxfrm)
+    {
+      TST_GET_ERRET (strxfrm);
+      org1 = TST_INPUT (strxfrm).org1;
+      org2 = TST_INPUT (strxfrm).org2;
+      n1 = TST_INPUT (strxfrm).n1;
+      n2 = TST_INPUT (strxfrm).n2;
+
+      if (n1 < 0 || sizeof (frm1) < n1 || sizeof (frm2) < n2)
+	{
+	  warn_count++;
+	  Result (C_IGNORED, S_STRXFRM, CASE_9,
+		  "input data n1 or n2 is invalid");
+	  continue;
+	}
+
+      /* An errno and a return value are checked
+	 only for 2nd strxfrm() call.
+	 A result of 1st call is used for comparing
+	 those 2 values by using strcmp().
+      */
+
+      /*-- First call --*/
+
+      TST_CLEAR_ERRNO;
+      ret = strxfrm (frm1, org1, n1);
+      TST_SAVE_ERRNO;
+
+      if (debug_flg)
+	{
+	  fprintf (stdout, "strxfrm() [ %s : %d ] ( 1st call )\n", locale,
+		   rec + 1);
+	  fprintf (stdout, "	  : err = %d | %s\n", errno_save,
+		   strerror (errno));
+	  fprintf (stdout, "	  : ret = %u\n", ret);
+	  fprintf (stdout, "	  : org = %s\n", org1);
+	}
+
+      if (ret >= n1 || errno != 0)
+	{
+	  warn_count++;
+	  Result (C_INVALID, S_STRXFRM, CASE_8,
+		  "got an error in fist strxfrm() call");
+	  continue;
+	}
+
+      /*-- Second call --*/
+
+      TST_CLEAR_ERRNO;
+      ret = strxfrm (((n2 == 0) ? NULL : frm2), org2, n2);
+      TST_SAVE_ERRNO;
+
+      if (debug_flg)
+	{
+	  fprintf (stderr, "	  ..............( 2nd call )\n");
+	  fprintf (stdout, "	  : err = %d | %s\n", errno,
+		   strerror (errno));
+	  fprintf (stdout, "	  : ret = %u\n", ret);
+	  fprintf (stdout, "	  : org = %s\n", org2);
+	}
+
+      TST_IF_RETURN (S_STRXFRM)
+      {
+      };
+
+      if (n2 == 0 || ret >= n2 || errno != 0)
+	{
+#if 0
+	  warn_count++;
+	  Result (C_IGNORED, S_STRXFRM, CASE_7, "did not get a result");
+#endif
+	  continue;
+	}
+
+      /*-- strcoll & strcmp --*/
+
+      TST_CLEAR_ERRNO;
+      /* Depends on strcoll() ... not good though ... */
+      ret_coll = strcoll (org1, org2);
+
+      if (errno != 0)
+	{
+	  /* bug * bug may get correct results ...	  */
+	  warn_count++;
+	  Result (C_INVALID, S_STRXFRM, CASE_6,
+		  "got an error in strcoll() call");
+	  continue;
+	}
+
+      ret_cmp = strcmp (frm1, frm2);
+
+      if ((ret_coll == 0 && ret_cmp == 0)
+	  || (ret_coll < 0 && ret_cmp < 0) || (ret_coll > 0 && ret_cmp > 0))
+	{
+	  Result (C_SUCCESS, S_STRXFRM, CASE_3,
+		  MS_PASSED "(depends on strcoll & strcmp)");
+	}
+      else
+	{
+	  err_count++;
+	  Result (C_FAILURE, S_STRXFRM, CASE_3,
+		  "results from strcoll & strcmp() do not match");
+	}
+
+      if (debug_flg)
+	{
+	  fprintf (stdout, ".......... strcoll = %d <-> %d = strcmp\n",
+		   ret_coll, ret_cmp);
+	}
+    }
+  }
+
+  return err_count;
+}
diff --git a/localedata/tests-mbwc/tst_wctomb.c b/localedata/tests-mbwc/tst_wctomb.c
new file mode 100644
index 0000000000..aea89fed8b
--- /dev/null
+++ b/localedata/tests-mbwc/tst_wctomb.c
@@ -0,0 +1,99 @@
+/*
+  WCTOMB: int wctomb (char *s, wchar_t wc)
+*/
+
+#define TST_FUNCTION wctomb
+
+#include "tsp_common.c"
+#include "dat_wctomb.c"
+
+int
+tst_wctomb (FILE * fp, int debug_flg)
+{
+  TST_DECL_VARS (int);
+  wchar_t wc;
+  char s[MBSSIZE], *s_in, *s_ex;
+  int err, i;
+
+  TST_DO_TEST (wctomb)
+  {
+    TST_HEAD_LOCALE (wctomb, S_WCTOMB);
+    TST_DO_REC (wctomb)
+    {
+      TST_GET_ERRET (wctomb);
+      wc = TST_INPUT (wctomb).wc;
+      s_in = ((TST_INPUT (wctomb).s_flg) == 0) ? (char *) NULL : s;
+      ret = wctomb (s_in, wc);
+
+      if (debug_flg)
+	{
+	  fprintf (stdout, "wctomb() [ %s : %d ] ret  = %d\n", locale,
+		   rec + 1, ret);
+	}
+
+      TST_IF_RETURN (S_WCTOMB)
+      {
+	if (s_in == NULL)	/* state dependency */
+	  {
+	    if (ret_exp == +1)	/* state-dependent  */
+	      {
+		if (ret != 0)
+		  {
+		    /* Non-zero means state-dependent encoding.	 */
+		    Result (C_SUCCESS, S_WCTOMB, CASE_3, MS_PASSED);
+		  }
+		else
+		  {
+		    err_count++;
+		    Result (C_FAILURE, S_WCTOMB, CASE_3,
+			    "should be state-dependent encoding, "
+			    "but a return value shows it is "
+			    "state-independent");
+		  }
+	      }
+
+	    if (ret_exp == 0)	/* state-independent */
+	      {
+		if (ret == 0)
+		  {
+		    /* Non-zero means state-dependent encoding.	 */
+		    Result (C_SUCCESS, S_WCTOMB, CASE_3, MS_PASSED);
+		  }
+		else
+		  {
+		    err_count++;
+		    Result (C_FAILURE, S_WCTOMB, CASE_3,
+			    "should be state-independent encoding, "
+			    "but a return value shows it is state-dependent");
+		  }
+	      }
+	  }
+      }
+
+      s_ex = TST_EXPECT (wctomb).s;
+
+      if (s_in)
+	{
+	  for (i = 0, err = 0; *(s_ex + i) != 0 && i < MBSSIZE; i++)
+	    {
+	      if (s_in[i] != s_ex[i])
+		{
+		  err++;
+		  err_count++;
+		  Result (C_FAILURE, S_WCTOMB, CASE_4,
+			  "copied string is different from an"
+			  " expected string");
+		  break;
+		}
+	    }
+
+	  if (!err)
+	    {
+	      Result (C_SUCCESS, S_WCTOMB, CASE_4, MS_PASSED);
+	    }
+	}
+    }
+  }
+
+  return err_count;
+}