forked from lix-project/lix
Fix tests
This commit is contained in:
parent
25ecfffdc3
commit
88d5c9ec58
|
@ -33,7 +33,7 @@ namespace nix {
|
||||||
const auto iter = settings.find("name-of-the-setting");
|
const auto iter = settings.find("name-of-the-setting");
|
||||||
ASSERT_NE(iter, settings.end());
|
ASSERT_NE(iter, settings.end());
|
||||||
ASSERT_EQ(iter->second.value, "");
|
ASSERT_EQ(iter->second.value, "");
|
||||||
ASSERT_EQ(iter->second.description, "description");
|
ASSERT_EQ(iter->second.description, "description\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(Config, getDefinedOverridenSettingNotSet) {
|
TEST(Config, getDefinedOverridenSettingNotSet) {
|
||||||
|
@ -59,7 +59,7 @@ namespace nix {
|
||||||
const auto iter = settings.find("name-of-the-setting");
|
const auto iter = settings.find("name-of-the-setting");
|
||||||
ASSERT_NE(iter, settings.end());
|
ASSERT_NE(iter, settings.end());
|
||||||
ASSERT_EQ(iter->second.value, "value");
|
ASSERT_EQ(iter->second.value, "value");
|
||||||
ASSERT_EQ(iter->second.description, "description");
|
ASSERT_EQ(iter->second.description, "description\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(Config, getDefinedSettingSet2) {
|
TEST(Config, getDefinedSettingSet2) {
|
||||||
|
@ -73,7 +73,7 @@ namespace nix {
|
||||||
const auto e = settings.find("name-of-the-setting");
|
const auto e = settings.find("name-of-the-setting");
|
||||||
ASSERT_NE(e, settings.end());
|
ASSERT_NE(e, settings.end());
|
||||||
ASSERT_EQ(e->second.value, "value");
|
ASSERT_EQ(e->second.value, "value");
|
||||||
ASSERT_EQ(e->second.description, "description");
|
ASSERT_EQ(e->second.description, "description\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(Config, addSetting) {
|
TEST(Config, addSetting) {
|
||||||
|
@ -152,29 +152,16 @@ namespace nix {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(Config, toJSONOnEmptyConfig) {
|
TEST(Config, toJSONOnEmptyConfig) {
|
||||||
std::stringstream out;
|
ASSERT_EQ(Config().toJSON().dump(), "{}");
|
||||||
{ // Scoped to force the destructor of JSONObject to write the final `}`
|
|
||||||
JSONObject obj(out);
|
|
||||||
Config config;
|
|
||||||
config.toJSON(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
ASSERT_EQ(out.str(), "{}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(Config, toJSONOnNonEmptyConfig) {
|
TEST(Config, toJSONOnNonEmptyConfig) {
|
||||||
std::stringstream out;
|
|
||||||
{ // Scoped to force the destructor of JSONObject to write the final `}`
|
|
||||||
JSONObject obj(out);
|
|
||||||
|
|
||||||
Config config;
|
Config config;
|
||||||
std::map<std::string, Config::SettingInfo> settings;
|
std::map<std::string, Config::SettingInfo> settings;
|
||||||
Setting<std::string> setting{&config, "", "name-of-the-setting", "description"};
|
Setting<std::string> setting{&config, "", "name-of-the-setting", "description"};
|
||||||
setting.assign("value");
|
setting.assign("value");
|
||||||
|
|
||||||
config.toJSON(obj);
|
ASSERT_EQ(config.toJSON().dump(), R"#({"name-of-the-setting":{"aliases":[],"description":"description\n","value":"value"}})#");
|
||||||
}
|
|
||||||
ASSERT_EQ(out.str(), R"#({"name-of-the-setting":{"description":"description","value":"value"}})#");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(Config, setSettingAlias) {
|
TEST(Config, setSettingAlias) {
|
||||||
|
|
Loading…
Reference in a new issue