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

Function UNIT_TEST

libs/base/base_tests/geo_object_id_tests.cpp:9–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7using namespace base;
8
9UNIT_TEST(GeoObjectId_Smoke)
10{
11 GeoObjectId const invalid(GeoObjectId::kInvalid);
12 TEST_EQUAL(invalid.GetType(), GeoObjectId::Type::Invalid, ());
13 TEST_EQUAL(DebugPrint(invalid), "Invalid 0", ());
14
15 GeoObjectId const node(GeoObjectId::Type::ObsoleteOsmNode, 12345);
16 TEST_EQUAL(node.GetSerialId(), 12345ULL, ());
17 TEST_EQUAL(node.GetType(), GeoObjectId::Type::ObsoleteOsmNode, ());
18 TEST_EQUAL(DebugPrint(node), "Osm Node 12345", ());
19
20 GeoObjectId const way(GeoObjectId::Type::ObsoleteOsmWay, 93245123456332ULL);
21 TEST_EQUAL(way.GetSerialId(), 93245123456332ULL, ());
22 TEST_EQUAL(way.GetType(), GeoObjectId::Type::ObsoleteOsmWay, ());
23 TEST_EQUAL(DebugPrint(way), "Osm Way 93245123456332", ());
24
25 GeoObjectId const relation(GeoObjectId::Type::ObsoleteOsmRelation, 5);
26 TEST_EQUAL(relation.GetSerialId(), 5ULL, ());
27 TEST_EQUAL(relation.GetType(), GeoObjectId::Type::ObsoleteOsmRelation, ());
28 TEST_EQUAL(DebugPrint(relation), "Osm Relation 5", ());
29
30 // 2^48 - 1, maximal possible serial id.
31 GeoObjectId const surrogate(GeoObjectId::Type::OsmSurrogate, 281474976710655ULL);
32 TEST_EQUAL(surrogate.GetSerialId(), 281474976710655ULL, ());
33 TEST_EQUAL(surrogate.GetType(), GeoObjectId::Type::OsmSurrogate, ());
34 TEST_EQUAL(DebugPrint(surrogate), "Osm Surrogate 281474976710655", ());
35
36 // 0 is not prohibited by the encoding even though OSM ids start from 1.
37 GeoObjectId const booking(GeoObjectId::Type::BookingComNode, 0);
38 TEST_EQUAL(booking.GetSerialId(), 0, ());
39 TEST_EQUAL(booking.GetType(), GeoObjectId::Type::BookingComNode, ());
40 TEST_EQUAL(DebugPrint(booking), "Booking.com 0", ());
41
42 GeoObjectId const fias(GeoObjectId::Type::Fias, 0xf1a5);
43 TEST_EQUAL(fias.GetSerialId(), 0xf1a5, ());
44 TEST_EQUAL(fias.GetType(), GeoObjectId::Type::Fias, ());
45 TEST_EQUAL(DebugPrint(fias), "FIAS 61861", ());
46}
47
48UNIT_TEST(GeoObjectId_Print)
49{

Callers

nothing calls this directly

Calls 5

MakeOsmWayFunction · 0.85
GetSerialIdMethod · 0.80
GetEncodedIdMethod · 0.80
DebugPrintFunction · 0.70
GetTypeMethod · 0.45

Tested by

no test coverage detected