MCPcopy Create free account
hub / github.com/comaps/comaps / generateRandomTest

Function generateRandomTest

libs/map/map_tests/mwm_url_tests.cpp:530–560  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

528}
529
530void generateRandomTest(uint32_t numberOfPoints, size_t stringLength)
531{
532 vector<url_scheme::MapPoint> vect(numberOfPoints);
533 for (uint32_t i = 0; i < numberOfPoints; ++i)
534 {
535 url_scheme::MapPoint point;
536 mt19937 rng(i);
537 point.m_lat = rng() % 90;
538 point.m_lat *= rng() % 2 == 0 ? 1 : -1;
539 point.m_lon = rng() % 180;
540 point.m_lon *= rng() % 2 == 0 ? 1 : -1;
541 point.m_name = randomString(stringLength, i);
542 point.m_id = randomString(stringLength, i);
543 vect[i] = point;
544 }
545 string result = "mapswithme://map?v=1";
546 for (size_t i = 0; i < vect.size(); ++i)
547 result += generatePartOfUrl(vect[i]);
548
549 ParsedMapApi api(result);
550 TEST_EQUAL(api.GetRequestType(), UrlType::Map, ());
551 TEST_EQUAL(api.GetMapPoints().size(), vect.size(), ());
552 for (size_t i = 0; i < vect.size(); ++i)
553 {
554 MapPoint const & p = api.GetMapPoints()[i];
555 TEST_EQUAL(p.m_name, vect[i].m_name, ());
556 TEST_EQUAL(p.m_id, vect[i].m_id, ());
557 TEST(AlmostEqualULPs(p.m_lat, vect[i].m_lat), ());
558 TEST(AlmostEqualULPs(p.m_lon, vect[i].m_lon), ());
559 }
560}
561
562} // namespace
563

Callers 2

mwm_url_tests.cppFile · 0.85
UNIT_TESTFunction · 0.85

Calls 6

randomStringFunction · 0.85
generatePartOfUrlFunction · 0.85
TESTFunction · 0.85
GetRequestTypeMethod · 0.80
AlmostEqualULPsFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected