From 032d93acf7fc59204f322aea55c516de4b768a71 Mon Sep 17 00:00:00 2001 From: gabime Date: Sat, 30 Nov 2024 15:52:22 +0200 Subject: [PATCH] Fix test compile --- tests/test_misc.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/test_misc.cpp b/tests/test_misc.cpp index 8743475b1..604f8f8f0 100644 --- a/tests/test_misc.cpp +++ b/tests/test_misc.cpp @@ -1,3 +1,7 @@ +#ifdef _WIN32 // to prevent fopen warning on windows +#define _CRT_SECURE_NO_WARNINGS +#endif + #include #include #include "includes.h" @@ -186,7 +190,7 @@ struct auto_closer { auto_closer(const auto_closer&) = delete; auto_closer& operator=(const auto_closer&) = delete; ~auto_closer() { - fp != nullptr && (std::fclose(fp) != 0); + if (fp != nullptr) (void)std::fclose(fp); } }; @@ -198,6 +202,7 @@ TEST_CASE("os::fwrite_bytes", "[os]") { { auto_closer closer(std::fopen(filename, "wb")); REQUIRE(closer.fp != nullptr); + std::ofstream ofstream(filename, std::ios::binary); REQUIRE(fwrite_bytes(msg, std::strlen(msg), closer.fp) == true); REQUIRE(fwrite_bytes(msg, 0, closer.fp) == true); std::fflush(closer.fp);