Discussion:
fix mbrtowc test failures on MSVC
(too old to reply)
Bruno Haible
2017-04-21 14:56:10 UTC
Permalink
Raw Message
On MSVC 14, the tests test-mbrtowc-w32-3.sh, test-mbrtowc-w32-4.sh,
test-mbrtowc-w32-5.sh fail, because the charset converter behaves a bit
differently than the GNU one.


2017-04-21 Bruno Haible <***@clisp.org>

mbrtowc tests: Fix test failures on MSVC 14.
* tests/test-mbrtowc-w32.c (test_one_locale): Accept MSVC's conversion
behaviour for invalid input.

diff --git a/tests/test-mbrtowc-w32.c b/tests/test-mbrtowc-w32.c
index 4dc30b0..70afc87 100644
--- a/tests/test-mbrtowc-w32.c
+++ b/tests/test-mbrtowc-w32.c
@@ -325,14 +325,12 @@ test_one_locale (const char *name, int codepage)
memset (&state, '\0', sizeof (mbstate_t));
wc = (wchar_t) 0xBADFACE;
ret = mbrtowc (&wc, "\377", 1, &state); /* 0xFF */
- ASSERT (ret == (size_t)-1);
- ASSERT (errno == EILSEQ);
+ ASSERT ((ret == (size_t)-1 && errno == EILSEQ) || ret == (size_t)-2);

memset (&state, '\0', sizeof (mbstate_t));
wc = (wchar_t) 0xBADFACE;
ret = mbrtowc (&wc, "\225\377", 2, &state); /* 0x95 0xFF */
- ASSERT (ret == (size_t)-1);
- ASSERT (errno == EILSEQ);
+ ASSERT ((ret == (size_t)-1 && errno == EILSEQ) || (ret == 2 && wc == 0x30FB));
}
return 0;

@@ -397,14 +395,12 @@ test_one_locale (const char *name, int codepage)
memset (&state, '\0', sizeof (mbstate_t));
wc = (wchar_t) 0xBADFACE;
ret = mbrtowc (&wc, "\377", 1, &state); /* 0xFF */
- ASSERT (ret == (size_t)-1);
- ASSERT (errno == EILSEQ);
+ ASSERT ((ret == (size_t)-1 && errno == EILSEQ) || ret == (size_t)-2);

memset (&state, '\0', sizeof (mbstate_t));
wc = (wchar_t) 0xBADFACE;
ret = mbrtowc (&wc, "\225\377", 2, &state); /* 0x95 0xFF */
- ASSERT (ret == (size_t)-1);
- ASSERT (errno == EILSEQ);
+ ASSERT ((ret == (size_t)-1 && errno == EILSEQ) || (ret == 2 && wc == '?'));
}
return 0;

@@ -469,14 +465,12 @@ test_one_locale (const char *name, int codepage)
memset (&state, '\0', sizeof (mbstate_t));
wc = (wchar_t) 0xBADFACE;
ret = mbrtowc (&wc, "\377", 1, &state); /* 0xFF */
- ASSERT (ret == (size_t)-1);
- ASSERT (errno == EILSEQ);
+ ASSERT ((ret == (size_t)-1 && errno == EILSEQ) || ret == (size_t)-2);

memset (&state, '\0', sizeof (mbstate_t));
wc = (wchar_t) 0xBADFACE;
ret = mbrtowc (&wc, "\225\377", 2, &state); /* 0x95 0xFF */
- ASSERT (ret == (size_t)-1);
- ASSERT (errno == EILSEQ);
+ ASSERT ((ret == (size_t)-1 && errno == EILSEQ) || (ret == 2 && wc == '?'));
}
return 0;

Loading...