add fuzzed fixtures and fix FixtureLogBackend to capture log output
This commit is contained in:
9
test/fixtures/style_parser/fuzz-colors.info.json
vendored
Normal file
9
test/fixtures/style_parser/fuzz-colors.info.json
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"default": {
|
||||
"log": [
|
||||
[84, "WARNING", "ParseStyle", "value of 'line-width' must be a number, or a number function"],
|
||||
[6, "WARNING", "ParseStyle", "value of 'line-opacity' must be a number, or a number function"],
|
||||
[12, "WARNING", "ParseStyle", "value of 'text-size' must be a number, or a number function"]
|
||||
]
|
||||
}
|
||||
}
|
||||
1
test/fixtures/style_parser/fuzz-colors.style.json
vendored
Normal file
1
test/fixtures/style_parser/fuzz-colors.style.json
vendored
Normal file
File diff suppressed because one or more lines are too long
8
test/fixtures/style_parser/fuzz-functions.info.json
vendored
Normal file
8
test/fixtures/style_parser/fuzz-functions.info.json
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"default": {
|
||||
"log": [
|
||||
[28, "WARNING", "ParseStyle", "stop must have zoom level and value specification"],
|
||||
[12, "WARNING", "ParseStyle", "function must specify a function type"]
|
||||
]
|
||||
}
|
||||
}
|
||||
1
test/fixtures/style_parser/fuzz-functions.style.json
vendored
Normal file
1
test/fixtures/style_parser/fuzz-functions.style.json
vendored
Normal file
File diff suppressed because one or more lines are too long
11
test/fixtures/style_parser/fuzz-layers.info.json
vendored
Normal file
11
test/fixtures/style_parser/fuzz-layers.info.json
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"default": {
|
||||
"log": [
|
||||
[20, "WARNING", "ParseStyle", "stop must have zoom level and value specification"],
|
||||
[6, "WARNING", "ParseStyle", "function must specify a function type"],
|
||||
[1, "WARNING", "ParseStyle", "value of 'line-width' must be a number, or a number function"],
|
||||
[1, "WARNING", "ParseStyle", "array value has unexpected number of elements"],
|
||||
[1, "WARNING", "ParseStyle", "value of 'line-opacity' must be a number, or a number function"]
|
||||
]
|
||||
}
|
||||
}
|
||||
1
test/fixtures/style_parser/fuzz-layers.style.json
vendored
Normal file
1
test/fixtures/style_parser/fuzz-layers.style.json
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -42,12 +42,12 @@ TEST_P(StyleParserTest, render) {
|
||||
std::stringstream stylejson;
|
||||
stylejson << stylefile.rdbuf();
|
||||
|
||||
const FixtureLogBackend &log = Log::Set<FixtureLogBackend>();
|
||||
|
||||
Style style;
|
||||
style.loadJSON((const uint8_t *)stylejson.str().c_str());
|
||||
|
||||
for (auto it = doc.MemberBegin(), end = doc.MemberEnd(); it != end; it++) {
|
||||
const FixtureLogBackend &log = Log::Set<FixtureLogBackend>();
|
||||
|
||||
const std::string name { it->name.GetString(), it->name.GetStringLength() };
|
||||
const rapidjson::Value &value = it->value;
|
||||
ASSERT_EQ(true, value.IsObject());
|
||||
@@ -58,26 +58,21 @@ TEST_P(StyleParserTest, render) {
|
||||
for (rapidjson::SizeType i = 0; i < js_log.Size(); i++) {
|
||||
const rapidjson::Value &js_entry = js_log[i];
|
||||
ASSERT_EQ(true, js_entry.IsArray());
|
||||
if (js_entry.Size() == 4) {
|
||||
const uint32_t count = js_entry[rapidjson::SizeType(0)].GetUint();
|
||||
if (js_entry[rapidjson::SizeType(3)].IsString()) {
|
||||
const FixtureLogBackend::LogMessage message {
|
||||
EventSeverityClass(js_entry[rapidjson::SizeType(1)].GetString()),
|
||||
EventClass(js_entry[rapidjson::SizeType(2)].GetString()),
|
||||
js_entry[rapidjson::SizeType(3)].GetString()
|
||||
};
|
||||
EXPECT_EQ(count, log.count(message)) << "Message: " << message << std::endl;
|
||||
}
|
||||
} else {
|
||||
FAIL();
|
||||
}
|
||||
|
||||
const uint32_t count = js_entry[rapidjson::SizeType(0)].GetUint();
|
||||
const FixtureLogBackend::LogMessage message {
|
||||
EventSeverityClass(js_entry[rapidjson::SizeType(1)].GetString()),
|
||||
EventClass(js_entry[rapidjson::SizeType(2)].GetString()),
|
||||
js_entry[rapidjson::SizeType(3)].GetString()
|
||||
};
|
||||
|
||||
EXPECT_EQ(count, log.count(message)) << "Message: " << message << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
const auto &unchecked = log.unchecked();
|
||||
if (unchecked.size()) {
|
||||
std::cerr << "Unchecked Log Messages (" << base << "): "
|
||||
<< std::endl << unchecked;
|
||||
std::cerr << "Unchecked Log Messages (" << base << "/" << name << "): " << std::endl << unchecked;
|
||||
}
|
||||
|
||||
ASSERT_EQ(0, unchecked.size());
|
||||
|
||||
Reference in New Issue
Block a user