Skip to content

Commit

Permalink
Fix test compile
Browse files Browse the repository at this point in the history
  • Loading branch information
gabime committed Nov 30, 2024
1 parent e26e369 commit 032d93a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tests/test_misc.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#ifdef _WIN32 // to prevent fopen warning on windows
#define _CRT_SECURE_NO_WARNINGS
#endif

#include <cstdio>
#include <cstring>
#include "includes.h"
Expand Down Expand Up @@ -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);
}
};

Expand All @@ -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);
Expand Down

0 comments on commit 032d93a

Please sign in to comment.