add fuzzed fixtures and fix FixtureLogBackend to capture log output

This commit is contained in:
Mike Morris
2014-07-18 15:44:48 -04:00
parent d0f6a87c1c
commit 37056a43de
7 changed files with 43 additions and 17 deletions

View 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"]
]
}
}

File diff suppressed because one or more lines are too long

View 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"]
]
}
}

File diff suppressed because one or more lines are too long

View 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"]
]
}
}

File diff suppressed because one or more lines are too long

View File

@@ -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());