From 4682deeb62247d34de87f8e777f99e2d337fd377 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sun, 20 Oct 2024 15:21:43 +0200 Subject: New upstream version 1.3 --- tests/test-mbrtoc32.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 63 insertions(+), 5 deletions(-) (limited to 'tests/test-mbrtoc32.c') 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; -- cgit v1.2.3