#include "Config.h"
#include "Define.h"
#include "gtest/gtest.h"
#include <boost/filesystem.hpp>
#include <cstdlib>
#include <fstream>
#include <string>
Go to the source code of this file.
|
std::string | CreateConfigWithMap (std::map< std::string, std::string > const &map) |
|
| TEST_F (ConfigEnvTest, NestedInt) |
|
| TEST_F (ConfigEnvTest, SimpleLowerString) |
|
| TEST_F (ConfigEnvTest, SimpleUpperString) |
|
| TEST_F (ConfigEnvTest, LongNestedNameWithNumber) |
|
| TEST_F (ConfigEnvTest, ValueWithSeveralUpperlLaters) |
|
| TEST_F (ConfigEnvTest, StringThatNotExistInConfig) |
|
| TEST_F (ConfigEnvTest, IntThatNotExistInConfig) |
|
| TEST_F (ConfigEnvTest, NotExistingString) |
|
| TEST_F (ConfigEnvTest, NotExistingInt) |
|
◆ CreateConfigWithMap()
std::string CreateConfigWithMap |
( |
std::map< std::string, std::string > const & |
map | ) |
|
28{
29 auto mTempFileRel = boost::filesystem::unique_path("deleteme.ini");
30 auto mTempFileAbs = boost::filesystem::temp_directory_path() / mTempFileRel;
31 std::ofstream iniStream;
32 iniStream.open(mTempFileAbs.c_str());
33
34 iniStream << "[test]\n";
35 for (auto const& itr : map)
36 iniStream << itr.first << " = " << itr.second << "\n";
37
38 iniStream.close();
39
40 return mTempFileAbs.native();
41}
Referenced by ConfigEnvTest::SetUp().
◆ TEST_F() [1/9]
113{
114 setenv("AC_UNIQUE_INT", "100", 1);
115 EXPECT_EQ(
sConfigMgr->GetOption<
int>(
"Unique.Int", 1), 100);
116}
#define sConfigMgr
Definition: Config.h:74
References sConfigMgr.
◆ TEST_F() [2/9]
91{
92 EXPECT_EQ(
sConfigMgr->GetOption<
float>(
"SomeLong.NestedNameWithNumber.Like1", 0), 1);
93 setenv("AC_SOME_LONG_NESTED_NAME_WITH_NUMBER_LIKE_1", "42", 1);
94 EXPECT_EQ(
sConfigMgr->OverrideWithEnvVariablesIfAny().empty(),
false);
95 EXPECT_EQ(
sConfigMgr->GetOption<
float>(
"SomeLong.NestedNameWithNumber.Like1", 0), 42);
96}
References sConfigMgr.
◆ TEST_F() [3/9]
67{
69 setenv("AC_INT_NESTED", "8080", 1);
70 EXPECT_EQ(
sConfigMgr->OverrideWithEnvVariablesIfAny().empty(),
false);
72}
std::int32_t int32
Definition: Define.h:103
References sConfigMgr.
◆ TEST_F() [4/9]
◆ TEST_F() [5/9]
119{
120 EXPECT_EQ(
sConfigMgr->GetOption<std::string>(
"NotFound.String",
"none"),
"none");
121}
References sConfigMgr.
◆ TEST_F() [6/9]
75{
76 EXPECT_EQ(
sConfigMgr->GetOption<std::string>(
"lower",
""),
"simpleString");
77 setenv("AC_LOWER", "envstring", 1);
78 EXPECT_EQ(
sConfigMgr->OverrideWithEnvVariablesIfAny().empty(),
false);
79 EXPECT_EQ(
sConfigMgr->GetOption<std::string>(
"lower",
""),
"envstring");
80}
References sConfigMgr.
◆ TEST_F() [7/9]
83{
84 EXPECT_EQ(
sConfigMgr->GetOption<std::string>(
"UPPER",
""),
"simpleString");
85 setenv("AC_UPPER", "envupperstring", 1);
86 EXPECT_EQ(
sConfigMgr->OverrideWithEnvVariablesIfAny().empty(),
false);
87 EXPECT_EQ(
sConfigMgr->GetOption<std::string>(
"UPPER",
""),
"envupperstring");
88}
References sConfigMgr.
◆ TEST_F() [8/9]
107{
108 setenv("AC_UNIQUE_STRING", "somevalue", 1);
109 EXPECT_EQ(
sConfigMgr->GetOption<std::string>(
"Unique.String",
""),
"somevalue");
110}
References sConfigMgr.
◆ TEST_F() [9/9]
99{
100 EXPECT_EQ(
sConfigMgr->GetOption<
int>(
"GM.InGMList.Level", 1), 50);
101 setenv("AC_GM_IN_GMLIST_LEVEL", "42", 1);
102 EXPECT_EQ(
sConfigMgr->OverrideWithEnvVariablesIfAny().empty(),
false);
103 EXPECT_EQ(
sConfigMgr->GetOption<
int>(
"GM.InGMList.Level", 0), 42);
104}
References sConfigMgr.