Fix hard-coded hint strings in unit-tests

This commit is contained in:
Patrick Niklaus 2018-04-10 11:39:29 +00:00 committed by Patrick Niklaus
parent ea0881553e
commit a06171438e

View File

@ -90,11 +90,14 @@ BOOST_AUTO_TEST_CASE(invalid_table_urls)
BOOST_AUTO_TEST_CASE(valid_route_hint) BOOST_AUTO_TEST_CASE(valid_route_hint)
{ {
auto hint = engine::Hint::FromBase64("ZgYAgP___38EAAAAIAAAAD4AAAAdAAAABAAAACAAAAA-"
"AAAAHQAAABQAAABqaHEAt4KbAjtocQDLgpsCBQAPAJDIe3E="); engine::PhantomNode reference_node;
BOOST_CHECK_EQUAL( reference_node.input_location =
hint.phantom.input_location, util::Coordinate(util::FloatLongitude{7.432251}, util::FloatLatitude{43.745995});
util::Coordinate(util::FloatLongitude{7.432251}, util::FloatLatitude{43.745995})); engine::Hint reference_hint{reference_node, 0x1337};
auto encoded_hint = reference_hint.ToBase64();
auto hint = engine::Hint::FromBase64(encoded_hint);
BOOST_CHECK_EQUAL(hint.phantom.input_location, reference_hint.phantom.input_location);
} }
BOOST_AUTO_TEST_CASE(valid_route_urls) BOOST_AUTO_TEST_CASE(valid_route_urls)
@ -166,13 +169,12 @@ BOOST_AUTO_TEST_CASE(valid_route_urls)
CHECK_EQUAL_RANGE(reference_3.coordinates, result_3->coordinates); CHECK_EQUAL_RANGE(reference_3.coordinates, result_3->coordinates);
CHECK_EQUAL_RANGE(reference_3.hints, result_3->hints); CHECK_EQUAL_RANGE(reference_3.hints, result_3->hints);
std::vector<boost::optional<engine::Hint>> hints_4 = { engine::PhantomNode phantom_1;
engine::Hint::FromBase64("ZgYAgP___38EAAAAIAAAAD4AAAAdAAAABAAAACAAAAA-AAAAHQAAABQAAA" phantom_1.input_location = coords_1[0];
"BqaHEAt4KbAjtocQDLgpsCBQAPAJDIe3E="), engine::PhantomNode phantom_2;
engine::Hint::FromBase64("ngQAgP___38TAAAAGAAAAC8AAAA4AAAAEwAAABgAAAAvAAAAOAAAABQAAA" phantom_2.input_location = coords_1[1];
"CaYXEAvnObAtxhcQC7c5sCBAAPAJDIe3E="), std::vector<boost::optional<engine::Hint>> hints_4 = {engine::Hint{phantom_1, 0x1337},
engine::Hint::FromBase64("QAUAgM0FAIAYAAAABAAAAAAAAADxAAAAGAAAAAQAAAAAAAAA8QAAABQAAA" engine::Hint{phantom_2, 0x1337}};
"CDPnEAUFabAog-cQBQVpsCAAAPAJDIe3E=")};
RouteParameters reference_4{false, RouteParameters reference_4{false,
false, false,
false, false,
@ -184,13 +186,7 @@ BOOST_AUTO_TEST_CASE(valid_route_urls)
std::vector<boost::optional<double>>{}, std::vector<boost::optional<double>>{},
std::vector<boost::optional<engine::Bearing>>{}}; std::vector<boost::optional<engine::Bearing>>{}};
auto result_4 = parseParameters<RouteParameters>( auto result_4 = parseParameters<RouteParameters>(
"1,2;3,4?steps=false&hints=" "1,2;3,4?steps=false&hints=" + hints_4[0]->ToBase64() + ";" + hints_4[1]->ToBase64());
"ZgYAgP___38EAAAAIAAAAD4AAAAdAAAABAAAACAAAAA-"
"AAAAHQAAABQAAABqaHEAt4KbAjtocQDLgpsCBQAPAJDIe3E=;"
"ngQAgP___"
"38TAAAAGAAAAC8AAAA4AAAAEwAAABgAAAAvAAAAOAAAABQAAACaYXEAvnObAtxhcQC7c5sCBAAPAJDIe3E=;"
"QAUAgM0FAIAYAAAABAAAAAAAAADxAAAAGAAAAAQAAAAAAAAA8QAAABQAAACDPnEAUFabAog-"
"cQBQVpsCAAAPAJDIe3E=");
BOOST_CHECK(result_4); BOOST_CHECK(result_4);
BOOST_CHECK_EQUAL(reference_4.steps, result_4->steps); BOOST_CHECK_EQUAL(reference_4.steps, result_4->steps);
BOOST_CHECK_EQUAL(reference_4.alternatives, result_4->alternatives); BOOST_CHECK_EQUAL(reference_4.alternatives, result_4->alternatives);
@ -288,13 +284,13 @@ BOOST_AUTO_TEST_CASE(valid_route_urls)
{util::FloatLongitude{3}, util::FloatLatitude{4}}, {util::FloatLongitude{3}, util::FloatLatitude{4}},
{util::FloatLongitude{5}, util::FloatLatitude{6}}, {util::FloatLongitude{5}, util::FloatLatitude{6}},
{util::FloatLongitude{7}, util::FloatLatitude{8}}}; {util::FloatLongitude{7}, util::FloatLatitude{8}}};
engine::PhantomNode phantom_3;
phantom_3.input_location = coords_3[0];
engine::PhantomNode phantom_4;
phantom_4.input_location = coords_3[2];
std::vector<boost::optional<engine::Hint>> hints_10 = { std::vector<boost::optional<engine::Hint>> hints_10 = {
engine::Hint::FromBase64("ZgYAgP___38EAAAAIAAAAD4AAAAdAAAABAAAACAAAAA-" engine::Hint{phantom_3, 0x1337}, boost::none, engine::Hint{phantom_4, 0x1337}, boost::none};
"AAAAHQAAABQAAABqaHEAt4KbAjtocQDLgpsCBQAPAJDIe3E="),
boost::none,
engine::Hint::FromBase64("QAUAgM0FAIAYAAAABAAAAAAAAADxAAAAGAAAAAQAAAAAAAAA8QAAABQAAACDPnEAU"
"FabAog-cQBQVpsCAAAPAJDIe3E="),
boost::none};
RouteParameters reference_10{false, RouteParameters reference_10{false,
false, false,
false, false,
@ -305,12 +301,9 @@ BOOST_AUTO_TEST_CASE(valid_route_urls)
hints_10, hints_10,
std::vector<boost::optional<double>>{}, std::vector<boost::optional<double>>{},
std::vector<boost::optional<engine::Bearing>>{}}; std::vector<boost::optional<engine::Bearing>>{}};
auto result_10 = auto result_10 = parseParameters<RouteParameters>("1,2;3,4;5,6;7,8?steps=false&hints=" +
parseParameters<RouteParameters>("1,2;3,4;5,6;7,8?steps=false&hints=" hints_10[0]->ToBase64() + ";;" +
"ZgYAgP___38EAAAAIAAAAD4AAAAdAAAABAAAACAAAAA-" hints_10[2]->ToBase64() + ";");
"AAAAHQAAABQAAABqaHEAt4KbAjtocQDLgpsCBQAPAJDIe3E=;;"
"QAUAgM0FAIAYAAAABAAAAAAAAADxAAAAGAAAAAQAAAAAAAAA8QAAABQAA"
"ACDPnEAUFabAog-cQBQVpsCAAAPAJDIe3E=;");
BOOST_CHECK(result_10); BOOST_CHECK(result_10);
BOOST_CHECK_EQUAL(reference_10.steps, result_10->steps); BOOST_CHECK_EQUAL(reference_10.steps, result_10->steps);
BOOST_CHECK_EQUAL(reference_10.alternatives, result_10->alternatives); BOOST_CHECK_EQUAL(reference_10.alternatives, result_10->alternatives);