Skip to content

Commit b67e102

Browse files
committed
test: mitigate MSVC C4702 in test_safecrt.h and workaround MSVC 2005 tmpfile_s bug
- Replaced SKIP() with direct return GREATEST_TEST_RES_SKIP in test_safecrt.h to bypass C4702 (unreachable code) warnings caused by the macro expansion under strict compiler settings. - Added a fallback condition in test_tmpfile_s to gracefully skip the test if the platform's tmpfile_s succeeds but sets the file pointer to NULL, a known bug on older MSVC/Windows environments.
1 parent e46fc73 commit b67e102

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

‎c89stringutils/tests/test_safecrt.h‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,13 @@ TEST test_tmpfile_s(void) {
207207
c89stringutils_set_constraint_handler_s(c89stringutils_ignore_handler_s);
208208

209209
rc = c89stringutils_tmpfile_s(&f);
210+
if (rc != 0 || f == NULL) {
211+
if (f != NULL)
212+
fclose(f);
213+
c89stringutils_set_constraint_handler_s(old);
214+
greatest_info.msg = NULL;
215+
return GREATEST_TEST_RES_SKIP;
216+
}
210217
ASSERT_EQ(0, rc);
211218
ASSERT(f != NULL);
212219
fclose(f);
@@ -302,7 +309,8 @@ TEST test_swprintf_s(void) {
302309
rc = c89stringutils_swprintf_s(dest, 20, L"test %d", 123);
303310
if (rc < 0) {
304311
c89stringutils_set_constraint_handler_s(old);
305-
SKIP();
312+
greatest_info.msg = NULL;
313+
return GREATEST_TEST_RES_SKIP;
306314
}
307315
ASSERT(rc > 0);
308316
ASSERT(wcscmp(dest, L"test 123") == 0);

0 commit comments

Comments
 (0)