check log messages from style_parser

This commit is contained in:
Mike Morris
2014-07-15 16:16:52 -04:00
parent fb91537466
commit 9437d0d7cc

View File

@@ -8,6 +8,29 @@
using namespace llmr;
typedef std::vector<std::pair<uint32_t, std::string>> Messages;
void checkMessages(FixtureLogBackend log, Messages messages) {
for (auto &it : messages) {
const FixtureLogBackend::LogMessage message {
EventSeverityClass("WARNING"),
EventClass("ParseStyle"),
it.second
};
ASSERT_EQ(it.first, log.count(message)) << "Message: "
<< message << std::endl;
}
const auto &unchecked = log.unchecked();
if (unchecked.size()) {
std::cerr << "Unchecked Log Messages: " << std::endl
<< unchecked;
}
ASSERT_EQ(0, unchecked.size());
}
TEST(Style, Style) {
const FixtureLogBackend &log = Log::Set<FixtureLogBackend>();
@@ -18,6 +41,8 @@ TEST(Style, Style) {
Style style;
style.loadJSON((const uint8_t *)stylejson.str().c_str());
checkMessages(log, {});
}
TEST(Style, Colors) {
@@ -30,6 +55,12 @@ TEST(Style, Colors) {
Style style;
style.loadJSON((const uint8_t *)stylejson.str().c_str());
checkMessages(log, {
{84, "value of 'line-width' must be a number, or a number function"},
{6, "value of 'line-opacity' must be a number, or a number function"},
{12, "value of 'text-size' must be a number, or a number function"}
});
}
TEST(Style, Functions) {
@@ -43,21 +74,10 @@ TEST(Style, Functions) {
Style style;
style.loadJSON((const uint8_t *)stylejson.str().c_str());
const FixtureLogBackend::LogMessage number {
EventSeverityClass("WARNING"),
EventClass("ParseStyle"),
"value of 'line-width' must be a number, or a number function"
};
ASSERT_EQ(0, log.count(number));
const auto &unchecked = log.unchecked();
if (unchecked.size()) {
std::cerr << "Unchecked Log Messages: " << std::endl
<< unchecked;
}
ASSERT_EQ(0, unchecked.size());
checkMessages(log, {
{48, "stop must have zoom level and value specification"},
{10, "stops function must specify a stops array"}
});
}
TEST(Style, Layers) {
@@ -70,5 +90,18 @@ TEST(Style, Layers) {
Style style;
style.loadJSON((const uint8_t *)stylejson.str().c_str());
}
checkMessages(log, {
{14, "stop must have zoom level and value specification"},
{7, "function must specify a function name"},
{6, "value of 'line-width' must be a number, or a number function"},
{3, "stops function must specify a stops array"},
{2, "function type 'ss' is unknown"},
{1, "array value has unexpected number of elements"},
{1, "function type 'spots' is unknown"},
{1, "function type 'sItops' is unknown"},
{1, "function type 'st1tops' is unknown"},
{1, "function type 'sto' is unknown"},
{1, "function type 'sRlix4tops' is unknown"}
});
}