Skip to content

Commit 8f007df

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

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

modules/core/util/func_tests/util_tests.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,23 @@
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) { return SetEnvironmentVariableA(name, value) ? 0 : -1; }
13+
#endif
14+
915
TEST(util_tests, check_unset_env) {
10-
#ifndef _WIN32
1116
int save_var = ppc::util::GetPPCNumThreads();
1217

1318
unsetenv("OMP_NUM_THREADS"); // NOLINT(misc-include-cleaner)
1419

1520
EXPECT_EQ(ppc::util::GetPPCNumThreads(), 1);
1621

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

2325
TEST(util_tests, check_set_env) {
24-
#ifndef _WIN32
2526
int save_var = ppc::util::GetPPCNumThreads();
2627

2728
const int num_threads = static_cast<int>(std::thread::hardware_concurrency());
@@ -30,7 +31,4 @@ TEST(util_tests, check_set_env) {
3031
EXPECT_EQ(ppc::util::GetPPCNumThreads(), num_threads);
3132

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

0 commit comments

Comments
 (0)