diff options
author | Jörg Frings-Fürst <debian@jff.email> | 2024-10-20 15:21:43 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff.email> | 2024-10-20 15:21:43 +0200 |
commit | 4682deeb62247d34de87f8e777f99e2d337fd377 (patch) | |
tree | 5bd5b5605b5f3a4b3c8ea7468c34c23094afdef4 /tests/test-mbrtowc.c | |
parent | 00893e79fc62966067af1a106567db96bd170338 (diff) |
New upstream version 1.3upstream/1.3upstream
Diffstat (limited to 'tests/test-mbrtowc.c')
-rw-r--r-- | tests/test-mbrtowc.c | 66 |
1 files changed, 61 insertions, 5 deletions
diff --git a/tests/test-mbrtowc.c b/tests/test-mbrtowc.c index f45f90e4..63600a11 100644 --- a/tests/test-mbrtowc.c +++ b/tests/test-mbrtowc.c @@ -169,7 +169,7 @@ main (int argc, char *argv[]) ASSERT (mbsinit (&state)); } } - return 0; + return test_exit_status; case '2': /* Locale encoding is ISO-8859-1 or ISO-8859-15. */ @@ -216,7 +216,7 @@ main (int argc, char *argv[]) ASSERT (wc == 'r'); ASSERT (mbsinit (&state)); } - return 0; + return test_exit_status; case '3': /* Locale encoding is UTF-8. */ @@ -271,7 +271,35 @@ main (int argc, char *argv[]) ASSERT (wc == 'r'); ASSERT (mbsinit (&state)); } - return 0; + if (sizeof (wchar_t) > 2) + { /* \360\237\220\203 = U+0001F403 */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\360", 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (wc == (wchar_t) 0xBADFACE); + ASSERT (!mbsinit (&state)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\237", 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (wc == (wchar_t) 0xBADFACE); + ASSERT (!mbsinit (&state)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\220", 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (wc == (wchar_t) 0xBADFACE); + ASSERT (!mbsinit (&state)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\203", 1, &state); + ASSERT (ret == 1); + ASSERT (wctob (wc) == EOF); + ASSERT (mbsinit (&state)); + } + return test_exit_status; case '4': /* Locale encoding is EUC-JP. */ @@ -327,7 +355,7 @@ main (int argc, char *argv[]) ASSERT (wc == '>'); ASSERT (mbsinit (&state)); } - return 0; + return test_exit_status; case '5': /* Locale encoding is GB18030. */ @@ -384,7 +412,35 @@ main (int argc, char *argv[]) ASSERT (wc == 'r'); ASSERT (mbsinit (&state)); } - return 0; + if (sizeof (wchar_t) > 2) + { /* \224\071\311\067 = U+0001F403 */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\224", 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (wc == (wchar_t) 0xBADFACE); + ASSERT (!mbsinit (&state)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\071", 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (wc == (wchar_t) 0xBADFACE); + ASSERT (!mbsinit (&state)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\311", 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (wc == (wchar_t) 0xBADFACE); + ASSERT (!mbsinit (&state)); + + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\067", 1, &state); + ASSERT (ret == 1); + ASSERT (wctob (wc) == EOF); + ASSERT (mbsinit (&state)); + } + return test_exit_status; } return 1; |