Skip to content

Commit 1364024

Browse files
committed
Enable util_tests.cpp on Windows
1 parent 2e998d2 commit 1364024

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

modules/core/util/func_tests/util_tests.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,25 @@
66

77
#include "core/util/include/util.hpp"
88

9+
#ifdef _WIN32
10+
#include <Windows.h>
11+
inline int unsetenv(const char* name) { return SetEnvironmentVariableA(name, NULL) ? 0 : -1; }
12+
inline int setenv(const char* name, const char* value, int overwrite) {
13+
return SetEnvironmentVariableA(name, value) ? 0 : -1;
14+
}
15+
#endif
16+
917
TEST(util_tests, check_unset_env) {
10-
#ifndef _WIN32
1118
int save_var = ppc::util::GetPPCNumThreads();
1219

1320
unsetenv("OMP_NUM_THREADS"); // NOLINT(misc-include-cleaner)
1421

1522
EXPECT_EQ(ppc::util::GetPPCNumThreads(), 1);
1623

1724
setenv("OMP_NUM_THREADS", std::to_string(save_var).c_str(), 1); // NOLINT(misc-include-cleaner)
18-
#else
19-
GTEST_SKIP();
20-
#endif
2125
}
2226

2327
TEST(util_tests, check_set_env) {
24-
#ifndef _WIN32
2528
int save_var = ppc::util::GetPPCNumThreads();
2629

2730
const int num_threads = static_cast<int>(std::thread::hardware_concurrency());
@@ -30,7 +33,4 @@ TEST(util_tests, check_set_env) {
3033
EXPECT_EQ(ppc::util::GetPPCNumThreads(), num_threads);
3134

3235
setenv("OMP_NUM_THREADS", std::to_string(save_var).c_str(), 1); // NOLINT(misc-include-cleaner)
33-
#else
34-
GTEST_SKIP();
35-
#endif
3636
}

0 commit comments

Comments
 (0)