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-mbrtoc32.c | |
parent | 00893e79fc62966067af1a106567db96bd170338 (diff) |
New upstream version 1.3upstream/1.3upstream
Diffstat (limited to 'tests/test-mbrtoc32.c')
-rw-r--r-- | tests/test-mbrtoc32.c | 68 |
1 files changed, 63 insertions, 5 deletions
diff --git a/tests/test-mbrtoc32.c b/tests/test-mbrtoc32.c index 6fffb2a7..b26c7888 100644 --- a/tests/test-mbrtoc32.c +++ b/tests/test-mbrtoc32.c @@ -172,7 +172,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. */ @@ -225,7 +225,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. */ @@ -291,7 +291,34 @@ main (int argc, char *argv[]) ASSERT (wc == '!'); ASSERT (mbsinit (&state)); } - return 0; + { /* \360\237\220\203 = U+0001F403 */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, "\360", 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (wc == (char32_t) 0xBADFACE); + ASSERT (!mbsinit (&state)); + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, "\237", 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (wc == (char32_t) 0xBADFACE); + ASSERT (!mbsinit (&state)); + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, "\220", 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (wc == (char32_t) 0xBADFACE); + ASSERT (!mbsinit (&state)); + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, "\203", 1, &state); + ASSERT (ret == 1); + ASSERT (wc == 0x1F403); /* expect Unicode encoding */ + ASSERT (mbsinit (&state)); + } + return test_exit_status; case '4': /* Locale encoding is EUC-JP. */ @@ -356,11 +383,13 @@ main (int argc, char *argv[]) ASSERT (wc == '>'); ASSERT (mbsinit (&state)); } - return 0; + return test_exit_status; case '5': /* Locale encoding is GB18030. */ #if (defined __GLIBC__ && __GLIBC__ == 2 && __GLIBC_MINOR__ >= 13 && __GLIBC_MINOR__ <= 15) || (GL_CHAR32_T_IS_UNICODE && (defined __FreeBSD__ || defined __NetBSD__ || defined __sun)) + if (test_exit_status != EXIT_SUCCESS) + return test_exit_status; fputs ("Skipping test: The GB18030 converter in this system's iconv is broken.\n", stderr); return 77; #endif @@ -434,7 +463,36 @@ main (int argc, char *argv[]) ASSERT (wc == '!'); ASSERT (mbsinit (&state)); } - return 0; + { /* \224\071\311\067 = U+0001F403 */ + memset (&state, '\0', sizeof (mbstate_t)); + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, "\224", 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (wc == (char32_t) 0xBADFACE); + ASSERT (!mbsinit (&state)); + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, "\071", 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (wc == (char32_t) 0xBADFACE); + ASSERT (!mbsinit (&state)); + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, "\311", 1, &state); + ASSERT (ret == (size_t)(-2)); + ASSERT (wc == (char32_t) 0xBADFACE); + ASSERT (!mbsinit (&state)); + + wc = (char32_t) 0xBADFACE; + ret = mbrtoc32 (&wc, "\067", 1, &state); + ASSERT (ret == 1); + #if GL_CHAR32_T_IS_UNICODE + ASSERT (wc == 0x1F403); /* expect Unicode encoding */ + #endif + ASSERT (mbsinit (&state)); + } + return test_exit_status; } return 1; |