fix(UnitTest): fixes unit tests not compiling under windows (#21299)

This commit is contained in:
Patrick Müssig 2025-02-17 06:17:51 +01:00 committed by GitHub
parent e28384b059
commit f89a8e0b81
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 2 deletions

View File

@ -17,7 +17,8 @@
#ifndef Random_h__
#define Random_h__
#undef max
#undef min
#include "Define.h"
#include "Duration.h"
#include <limits>

View File

@ -24,6 +24,13 @@
#include <fstream>
#include <string>
#if WIN32
void inline setenv(const char* name, const char* value, int overwrite)
{
_putenv_s(name, value);
}
#endif
std::string CreateConfigWithMap(std::map<std::string, std::string> const& map)
{
auto mTempFileRel = boost::filesystem::unique_path("deleteme.ini");
@ -36,8 +43,12 @@ std::string CreateConfigWithMap(std::map<std::string, std::string> const& map)
iniStream << itr.first << " = " << itr.second << "\n";
iniStream.close();
#if WIN32
auto tmp = mTempFileAbs.native();
return std::string(tmp.begin(), tmp.end());
#else
return mTempFileAbs.native();
#endif
}
class ConfigEnvTest : public testing::Test {