Go to the documentation of this file.00001 #include <boost/test/unit_test.hpp>
00002 #include "../elements/osmelements.h"
00003 #include <boost/property_tree/xml_parser.hpp>
00004
00005 BOOST_AUTO_TEST_SUITE(osmelements_test)
00006
00007 BOOST_AUTO_TEST_CASE(description)
00008 {
00009 osm::Node n(1, 2, 3);
00010 n.tags.insert(osm::Tag("nkey", "nval"));
00011 auto ndesc = n.get_description();
00012 BOOST_CHECK(ndesc.get<std::string>("node") == "1");
00013 BOOST_CHECK(ndesc.get<std::string>("node.tags.nkey") == "nval");
00014 osm::Way w(1);
00015 w.nodes.push_back(osm::Node(2));
00016 w.tags.insert(osm::Tag("wkey", "wval"));
00017 auto wdesc = w.get_description();
00018 BOOST_CHECK(wdesc.get<std::string>("way") == "1");
00019 BOOST_CHECK(wdesc.get<std::string>("way.nodes.node") == "2");
00020 BOOST_CHECK(wdesc.get<std::string>("way.tags.wkey") == "wval");
00021 osm::Relation r(1);
00022 r.tags.insert(osm::Tag("rkey", "rval"));
00023 r.add_node("role", osm::Node(2));
00024 auto rdesc = r.get_description();
00025 BOOST_CHECK(rdesc.get<std::string>("relation") == "1");
00026 BOOST_CHECK(rdesc.get<std::string>("relation.members.member.node") == "2");
00027 BOOST_CHECK(rdesc.get<std::string>("relation.members.member.role") == "role");
00028 BOOST_CHECK(rdesc.get<std::string>("relation.tags.rkey") == "rval");
00029 }
00030
00031 BOOST_AUTO_TEST_CASE(equals)
00032 {
00033 osm::Node n(1, 2, 3);
00034 n.tags.insert(osm::Tag("asdf", "bsdf"));
00035 n.tags.insert(osm::Tag("asdf", "csdf"));
00036 osm::Node n2(1, 2, 3);
00037 n2.tags.insert(osm::Tag("asdf", "csdf"));
00038 n2.tags.insert(osm::Tag("asdf", "bsdf"));
00039 BOOST_CHECK(n == n2);
00040 osm::Way w(1);
00041 w.nodes.push_back(osm::Node(2));
00042 w.nodes.push_back(osm::Node(3));
00043 w.tags.insert(osm::Tag("asdf", "bsdf"));
00044 w.tags.insert(osm::Tag("asdf", "csdf"));
00045 osm::Way w2(1);
00046 w2.nodes.push_back(osm::Node(2));
00047 w2.nodes.push_back(osm::Node(3));
00048 w2.tags.insert(osm::Tag("asdf", "csdf"));
00049 w2.tags.insert(osm::Tag("asdf", "bsdf"));
00050 BOOST_CHECK(w == w2);
00051 w2 = osm::Way(1);
00052 w2.nodes.push_back(osm::Node(3));
00053 w2.nodes.push_back(osm::Node(2));
00054 w2.tags.insert(osm::Tag("asdf", "csdf"));
00055 w2.tags.insert(osm::Tag("asdf", "bsdf"));
00056 BOOST_CHECK(w != w2);
00057 osm::Relation r(1);
00058 r.add_node("role", osm::Node(2));
00059 r.add_way("role", osm::Way(3));
00060 r.tags.insert(osm::Tag("asdf", "bsdf"));
00061 r.tags.insert(osm::Tag("asdf", "csdf"));
00062 osm::Relation r2(1);
00063 r2.add_way("role", osm::Way(3));
00064 r2.add_node("role", osm::Node(2));
00065 r2.tags.insert(osm::Tag("asdf", "csdf"));
00066 r2.tags.insert(osm::Tag("asdf", "bsdf"));
00067 BOOST_CHECK(r == r2);
00068
00069 osm::Node n3(1, 2, 3);
00070 n3.tags.insert(osm::Tag("asdf", "bsdf"));
00071 n3.tags.insert(osm::Tag("asdf", "csdf"));
00072 osm::Node n4(1, 2, 3);
00073 n4.tags.insert(osm::Tag("asdf", "csdf"));
00074 n4.tags.insert(osm::Tag("bsdf", "bsdf"));
00075 BOOST_CHECK(n3 != n4);
00076 }
00077
00078 BOOST_AUTO_TEST_SUITE_END()