feat: Validate unexpected config values (#2457)

This commit is contained in:
Ayaz Salikhov
2025-08-20 12:38:51 +01:00
committed by GitHub
parent e9ab081ab7
commit a172d0b7ea
12 changed files with 101 additions and 59 deletions

View File

@@ -31,6 +31,7 @@
#include <algorithm>
#include <cstdint>
#include <ranges>
#include <string>
#include <unordered_map>
#include <variant>
@@ -488,6 +489,31 @@ TEST_F(ConfigFileJsonTest, containsKey)
EXPECT_FALSE(jsonFileObj.containsKey("array_of_objects.[].object"));
}
TEST_F(ConfigFileJsonTest, getAllKeys)
{
auto const jsonStr = R"JSON({
"int": 42,
"object": { "string": "some string", "array": [1, 2, 3] },
"array2": [1, 2, 3],
"array_of_objects": [ {"int": 42}, {"string": "some string"} ]
})JSON";
auto const jsonFileObj = ConfigFileJson{boost::json::parse(jsonStr).as_object()};
auto allKeys = jsonFileObj.getAllKeys();
std::ranges::sort(allKeys);
EXPECT_EQ(allKeys.size(), 6);
std::vector<std::string> const expectedKeys{
{"array2.[]",
"array_of_objects.[].int",
"array_of_objects.[].string",
"int",
"object.array.[]",
"object.string"}
};
EXPECT_EQ(allKeys, expectedKeys);
}
struct ConfigFileJsonMakeTest : ConfigFileJsonTest {};
TEST_F(ConfigFileJsonMakeTest, invalidFile)