fix parse_double_optional_percent grammar and update tests

This commit is contained in:
artemp 2015-07-31 11:35:02 +02:00
parent 5b04764757
commit 42bf2303e0
2 changed files with 5 additions and 5 deletions

View file

@ -149,7 +149,7 @@ double parse_double_optional_percent(T & error_messages, const char* str, bool &
double val = 0.0; double val = 0.0;
if (!parse(str, str + std::strlen(str),double_[ref(val)=_1, ref(percent) = false] if (!parse(str, str + std::strlen(str),double_[ref(val)=_1, ref(percent) = false]
>> -char_('%')[ref(val)/100.0, ref(percent) = true])) >> -char_('%')[ref(val) /= 100.0, ref(percent) = true]))
{ {
error_messages.emplace_back("Failed to parse double (optional %) from " + std::string(str)); error_messages.emplace_back("Failed to parse double (optional %) from " + std::string(str));
} }

View file

@ -750,9 +750,9 @@ TEST_CASE("SVG parser") {
REQUIRE(attrs[0].fill_gradient.has_stop()); REQUIRE(attrs[0].fill_gradient.has_stop());
attrs[0].fill_gradient.get_control_points(x1, y1, x2, y2, r); attrs[0].fill_gradient.get_control_points(x1, y1, x2, y2, r);
REQUIRE(x1 == 0); REQUIRE(x1 == 0);
REQUIRE(y1 == 25); REQUIRE(y1 == 0.25);
REQUIRE(x2 == 10); REQUIRE(x2 == 0.10);
REQUIRE(y2 == 10); REQUIRE(y2 == 0.10);
REQUIRE(r == 75); REQUIRE(r == 0.75);
} }
} }