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

Function UNIT_TEST

generator/generator_tests/node_mixer_test.cpp:9–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7#include <sstream>
8
9UNIT_TEST(NodeMixerTests)
10{
11 std::istringstream stream1("");
12 generator::MixFakeNodes(stream1,
13 [](OsmElement & p) { TEST(false, ("Returned an object for an empty input stream.")); });
14
15 std::istringstream stream2("shop=gift\nname=Shop\n");
16 generator::MixFakeNodes(
17 stream2, [](OsmElement & p) { TEST(false, ("Returned an object for a source without coordinates.")); });
18
19 std::istringstream stream3("lat=4.0\nlon=-4.1\n");
20 generator::MixFakeNodes(stream3,
21 [](OsmElement & p) { TEST(false, ("Returned an object for a source without tags.")); });
22
23 std::istringstream stream4("lat=10.0\nlon=-4.8\nshop=gift\nname=Shop");
24 int count4 = 0;
25 generator::MixFakeNodes(stream4, [&](OsmElement & p)
26 {
27 count4++;
28 TEST_EQUAL(p.m_type, OsmElement::EntityType::Node, ());
29 TEST_EQUAL(p.m_lat, 10.0, ());
30 TEST_EQUAL(p.m_lon, -4.8, ());
31 TEST_EQUAL(p.Tags().size(), 2, ());
32 TEST_EQUAL(p.GetTag("name"), "Shop", ());
33 });
34 TEST_EQUAL(count4, 1, ());
35
36 std::istringstream stream5("lat=10.0\nlon=-4.8\nid=1\nname=First\n\nid=2\nlat=60\nlon=1\nname=Second\n\n\n");
37 int count5 = 0;
38 generator::MixFakeNodes(stream5, [&](OsmElement & p)
39 {
40 count5++;
41 TEST_EQUAL(p.m_type, OsmElement::EntityType::Node, ());
42 TEST_EQUAL(p.Tags().size(), 2, ());
43 std::string id = p.GetTag("id");
44 TEST(!id.empty(), ("No id tag when every object has it."));
45 TEST_EQUAL(p.GetTag("name"), id == "1" ? "First" : "Second", ());
46 });
47 TEST_EQUAL(count5, 2, ());
48
49 std::istringstream stream6("lat=0\nlon=-4.8\nshop=mall");
50 int count6 = 0;
51 generator::MixFakeNodes(stream6, [&](OsmElement & p)
52 {
53 count6++;
54 TEST_EQUAL(p.m_lat, 0.0, ());
55 TEST_EQUAL(p.m_lon, -4.8, ());
56 });
57 TEST_EQUAL(count6, 1, ());
58}

Callers

nothing calls this directly

Calls 6

TESTFunction · 0.85
TagsMethod · 0.80
GetTagMethod · 0.80
MixFakeNodesFunction · 0.50
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected