aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2005-08-20 01:02:04 +0000
committerUlrich Drepper <drepper@redhat.com>2005-08-20 01:02:04 +0000
commit2a81f17880ff4d75cc6ef3fd4456cc23f28a6ed3 (patch)
tree7297314c08c3c5025f8f3b791f4e62fa37a551b3 /debug/tst-chk1.c
parent[BZ #1075, BZ #1112] (diff)
downloadglibc-2a81f17880ff4d75cc6ef3fd4456cc23f28a6ed3.tar.gz
glibc-2a81f17880ff4d75cc6ef3fd4456cc23f28a6ed3.tar.bz2
glibc-2a81f17880ff4d75cc6ef3fd4456cc23f28a6ed3.zip
Add tests for mbstowcs and wcstombs.
Diffstat (limited to 'debug/tst-chk1.c')
-rw-r--r--debug/tst-chk1.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/debug/tst-chk1.c b/debug/tst-chk1.c
index 755052c52b..e011d8602a 100644
--- a/debug/tst-chk1.c
+++ b/debug/tst-chk1.c
@@ -1104,6 +1104,24 @@ do_test (void)
CHK_FAIL_END
#endif
+ cp = "A";
+ if (mbstowcs (wenough, cp, 10) != 1)
+ {
+ puts ("first mbstowcs test failed");
+ ret = 1;
+ }
+
+#if __USE_FORTIFY_LEVEL >= 1
+ /* We know the wchar_t encoding is ISO 10646. So pick a
+ character which has a multibyte representation which does not
+ fit. */
+ CHK_FAIL_START
+ wchar_t wsmallbuf[2];
+ cp = "ABC";
+ mbstowcs (wsmallbuf, cp, 10);
+ CHK_FAIL_END
+#endif
+
memset (&s, '\0', sizeof (s));
cp = "A";
if (mbsnrtowcs (wenough, &cp, 1, 10, &s) != 1)
@@ -1142,6 +1160,24 @@ do_test (void)
CHK_FAIL_END
#endif
+ wcp = L"A";
+ if (wcstombs (enough, wcp, 10) != 1)
+ {
+ puts ("first wcstombs test failed");
+ ret = 1;
+ }
+
+#if __USE_FORTIFY_LEVEL >= 1
+ /* We know the wchar_t encoding is ISO 10646. So pick a
+ character which has a multibyte representation which does not
+ fit. */
+ CHK_FAIL_START
+ char smallbuf[2];
+ wcp = L"ABC";
+ wcstombs (smallbuf, wcp, 10);
+ CHK_FAIL_END
+#endif
+
memset (&s, '\0', sizeof (s));
wcp = L"A";
if (wcsnrtombs (enough, &wcp, 1, 10, &s) != 1)