Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lehmann-4178656ch committed Nov 13, 2024
1 parent 6d0426c commit 2ffa180
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 123 deletions.
14 changes: 7 additions & 7 deletions tests/E2E.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ TEST(E2E, singleNode) {
ASSERT_THAT(printedState,
::testing::HasSubstr("areas seen:0 dumped: 0 geometry: 0\n"));
ASSERT_THAT(printedState,
::testing::HasSubstr("nodes seen:1 dumped: 0 geometry: 0\n"));
::testing::HasSubstr("nodes seen:1 dumped: 1 geometry: 1\n"));
ASSERT_THAT(printedState,
::testing::HasSubstr("relations seen:0 dumped: 0 geometry: 0\n"));
ASSERT_THAT(printedState,
Expand Down Expand Up @@ -415,7 +415,7 @@ TEST(E2E, osmWikiExample) {
ASSERT_THAT(printedState,
::testing::HasSubstr("areas seen:0 dumped: 0 geometry: 0\n"));
ASSERT_THAT(printedState,
::testing::HasSubstr("nodes seen:4 dumped: 1 geometry: 1\n"));
::testing::HasSubstr("nodes seen:4 dumped: 4 geometry: 4\n"));
ASSERT_THAT(printedState,
::testing::HasSubstr("relations seen:1 dumped: 1 geometry: 0\n"));
ASSERT_THAT(printedState,
Expand Down Expand Up @@ -503,7 +503,7 @@ TEST(E2E, building51NT) {
ASSERT_THAT(printedState,
::testing::HasSubstr("areas seen:1 dumped: 1 geometry: 1\n"));
ASSERT_THAT(printedState,
::testing::HasSubstr("nodes seen:19 dumped: 3 geometry: 3\n"));
::testing::HasSubstr("nodes seen:19 dumped: 19 geometry: 19\n"));
ASSERT_THAT(printedState,
::testing::HasSubstr("relations seen:0 dumped: 0 geometry: 0\n"));
ASSERT_THAT(printedState,
Expand Down Expand Up @@ -676,7 +676,7 @@ TEST(E2E, building51TTL) {
ASSERT_THAT(printedState,
::testing::HasSubstr("areas seen:1 dumped: 1 geometry: 1\n"));
ASSERT_THAT(printedState,
::testing::HasSubstr("nodes seen:19 dumped: 3 geometry: 3\n"));
::testing::HasSubstr("nodes seen:19 dumped: 19 geometry: 19\n"));
ASSERT_THAT(printedState,
::testing::HasSubstr("relations seen:0 dumped: 0 geometry: 0\n"));
ASSERT_THAT(printedState,
Expand Down Expand Up @@ -812,7 +812,7 @@ TEST(E2E, building51QLEVER) {
ASSERT_THAT(printedState,
::testing::HasSubstr("areas seen:1 dumped: 1 geometry: 1\n"));
ASSERT_THAT(printedState,
::testing::HasSubstr("nodes seen:19 dumped: 3 geometry: 3\n"));
::testing::HasSubstr("nodes seen:19 dumped: 19 geometry: 19\n"));
ASSERT_THAT(printedState,
::testing::HasSubstr("relations seen:0 dumped: 0 geometry: 0\n"));
ASSERT_THAT(printedState,
Expand Down Expand Up @@ -947,7 +947,7 @@ TEST(E2E, tf) {
ASSERT_THAT(printedState,
::testing::HasSubstr("areas seen:1 dumped: 1 geometry: 1\n"));
ASSERT_THAT(printedState,
::testing::HasSubstr("nodes seen:45 dumped: 0 geometry: 0\n"));
::testing::HasSubstr("nodes seen:45 dumped: 45 geometry: 45\n"));
ASSERT_THAT(printedState,
::testing::HasSubstr("relations seen:0 dumped: 0 geometry: 0\n"));
ASSERT_THAT(printedState,
Expand Down Expand Up @@ -1048,7 +1048,7 @@ TEST(E2E, building51inTF) {
ASSERT_THAT(printedState,
::testing::HasSubstr("areas seen:2 dumped: 2 geometry: 2\n"));
ASSERT_THAT(printedState,
::testing::HasSubstr("nodes seen:64 dumped: 3 geometry: 3\n"));
::testing::HasSubstr("nodes seen:64 dumped: 64 geometry: 64\n"));
ASSERT_THAT(printedState,
::testing::HasSubstr("relations seen:0 dumped: 0 geometry: 0\n"));
ASSERT_THAT(printedState,
Expand Down
28 changes: 0 additions & 28 deletions tests/config/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ void assertDefaultConfig(const osm2rdf::config::Config& config) {
ASSERT_FALSE(config.noWayGeometricRelations);

ASSERT_FALSE(config.addAreaWayLinestrings);
ASSERT_FALSE(config.addWayNodeGeometry);
ASSERT_FALSE(config.addWayNodeOrder);
ASSERT_FALSE(config.addWayNodeSpatialMetadata);
ASSERT_FALSE(config.addWayMetadata);
Expand Down Expand Up @@ -578,22 +577,6 @@ TEST(CONFIG_Config, fromArgsAddWayMetadataLong) {
ASSERT_TRUE(config.addWayMetadata);
}

// ____________________________________________________________________________
TEST(CONFIG_Config, fromArgsAddWayNodeGeomentryLong) {
osm2rdf::config::Config config;
assertDefaultConfig(config);

osm2rdf::util::CacheFile cf("/tmp/dummyInput");
const auto arg =
"--" + osm2rdf::config::constants::ADD_WAY_NODE_GEOMETRY_OPTION_LONG;
const int argc = 3;
char* argv[argc] = {const_cast<char*>(""), const_cast<char*>(arg.c_str()),
const_cast<char*>("/tmp/dummyInput")};
config.fromArgs(argc, argv);
ASSERT_EQ("", config.output.string());
ASSERT_TRUE(config.addWayNodeGeometry);
}

// ____________________________________________________________________________
TEST(CONFIG_Config, fromArgsAddWayNodeOrderLong) {
osm2rdf::config::Config config;
Expand Down Expand Up @@ -890,17 +873,6 @@ TEST(CONFIG_Config, getInfoAddWayMetadata) {
osm2rdf::config::constants::ADD_WAY_METADATA_INFO));
}

// ____________________________________________________________________________
TEST(CONFIG_Config, getInfoAddWayNodeGeometry) {
osm2rdf::config::Config config;
assertDefaultConfig(config);
config.addWayNodeGeometry = true;

const std::string res = config.getInfo("");
ASSERT_THAT(res, ::testing::HasSubstr(
osm2rdf::config::constants::ADD_WAY_NODE_GEOMETRY_INFO));
}

// ____________________________________________________________________________
TEST(CONFIG_Config, getInfoAddWayNodeOrder) {
osm2rdf::config::Config config;
Expand Down
8 changes: 4 additions & 4 deletions tests/issues/Issue15.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ TEST(Issue15, Relation_8291361_expected) {
ASSERT_THAT(printedState,
::testing::HasSubstr("areas seen:2 dumped: 2 geometry: 0\n"));
ASSERT_THAT(printedState,
::testing::HasSubstr("nodes seen:207 dumped: 0 geometry: 0\n"));
::testing::HasSubstr("nodes seen:207 dumped: 207 geometry: 0\n"));
ASSERT_THAT(printedState,
::testing::HasSubstr("relations seen:1 dumped: 1 geometry: 0\n"));
ASSERT_THAT(printedState,
Expand Down Expand Up @@ -117,7 +117,7 @@ TEST(Issue15, Relation_8291361_failed) {
ASSERT_THAT(printedState,
::testing::HasSubstr("areas seen:2 dumped: 2 geometry: 0\n"));
ASSERT_THAT(printedState,
::testing::HasSubstr("nodes seen:207 dumped: 0 geometry: 0\n"));
::testing::HasSubstr("nodes seen:207 dumped: 207 geometry: 0\n"));
ASSERT_THAT(printedState,
::testing::HasSubstr("relations seen:1 dumped: 1 geometry: 0\n"));
ASSERT_THAT(printedState,
Expand Down Expand Up @@ -171,7 +171,7 @@ TEST(Issue15, Way_201387026_expected) {
ASSERT_THAT(printedState,
::testing::HasSubstr("areas seen:1 dumped: 1 geometry: 0\n"));
ASSERT_THAT(printedState,
::testing::HasSubstr("nodes seen:1498 dumped: 2 geometry: 0\n"));
::testing::HasSubstr("nodes seen:1498 dumped: 1498 geometry: 0\n"));
ASSERT_THAT(printedState,
::testing::HasSubstr("relations seen:0 dumped: 0 geometry: 0\n"));
ASSERT_THAT(printedState,
Expand Down Expand Up @@ -224,7 +224,7 @@ TEST(Issue15, Way_201387026_failed) {
ASSERT_THAT(printedState,
::testing::HasSubstr("areas seen:1 dumped: 1 geometry: 0\n"));
ASSERT_THAT(printedState,
::testing::HasSubstr("nodes seen:1498 dumped: 2 geometry: 0\n"));
::testing::HasSubstr("nodes seen:1498 dumped: 1498 geometry: 0\n"));
ASSERT_THAT(printedState,
::testing::HasSubstr("relations seen:0 dumped: 0 geometry: 0\n"));
ASSERT_THAT(printedState,
Expand Down
68 changes: 0 additions & 68 deletions tests/osm/FactHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,74 +518,6 @@ TEST(OSM_FactHandler, way) {
std::cout.rdbuf(sbuf);
}

// ____________________________________________________________________________
TEST(OSM_FactHandler, wayAddWayNodeGeoemtry) {
// Capture std::cout
std::stringstream buffer;
std::streambuf* sbuf = std::cout.rdbuf();
std::cout.rdbuf(buffer.rdbuf());

osm2rdf::config::Config config;
config.output = "";
config.numThreads = 1; // set to one to avoid concurrency issues with the
// stringstream read buffer
config.outputCompress = osm2rdf::config::NONE;
config.addCentroids = false;
config.mergeOutput = osm2rdf::util::OutputMergeMode::NONE;
config.wktPrecision = 1;
config.addWayNodeGeometry = true;
config.addWayNodeOrder = true;

osm2rdf::util::Output output{config, config.output};
output.open();
osm2rdf::ttl::Writer<osm2rdf::ttl::format::TTL> writer{config, &output};
osm2rdf::osm::FactHandler dh{config, &writer};

// Create osmium object
const size_t initial_buffer_size = 10000;
osmium::memory::Buffer osmiumBuffer{initial_buffer_size,
osmium::memory::Buffer::auto_grow::yes};
osmium::builder::add_way(osmiumBuffer, osmium::builder::attr::_id(42),
osmium::builder::attr::_nodes({
{1, {48.0, 7.51}},
{2, {48.1, 7.61}},
}),
osmium::builder::attr::_tag("city", "Freiburg"));

// Create osm2rdf object from osmium object
osm2rdf::osm::Way w{osmiumBuffer.get<osmium::Way>(0)};
w.finalize();

dh.way(w);
output.flush();
output.close();

ASSERT_EQ(
"osmway:42 rdf:type osm:way .\nosmway:42 osmmeta:timestamp "
"\"1970-01-01T00:00:00\"^^xsd:dateTime .\nosmway:42 osmkey:city "
"\"Freiburg\" .\nosmway:42 osm2rdf:facts \"1\"^^xsd:integer .\nosmway:42 "
"osmway:node _:0_0 .\n_:0_0 osmway:node osmnode:1 .\n_:0_0 "
"osm2rdfmember:pos \"0\"^^xsd:integer .\nosmnode:1 rdf:type osm:node "
".\nosmnode:1 geo:hasGeometry osm2rdfgeom:osm_node_1 "
".\nosm2rdfgeom:osm_node_1 geo:asWKT \"POINT(48 7.5)\"^^geo:wktLiteral "
".\nosmway:42 osmway:node _:0_1 .\n_:0_1 osmway:node osmnode:2 .\n_:0_1 "
"osm2rdfmember:pos \"1\"^^xsd:integer .\nosmnode:2 rdf:type osm:node "
".\nosmnode:2 geo:hasGeometry osm2rdfgeom:osm_node_2 "
".\nosm2rdfgeom:osm_node_2 geo:asWKT \"POINT(48.1 7.6)\"^^geo:wktLiteral "
".\nosmway:42 geo:hasGeometry osm2rdf:way_42 .\nosm2rdf:way_42 geo:asWKT "
"\"LINESTRING(48 7.5,48.1 7.6)\"^^geo:wktLiteral .\nosmway:42 "
"osm2rdfgeom:convex_hull \"POLYGON((48 7.5,48.1 7.6,48 "
"7.5))\"^^geo:wktLiteral .\nosmway:42 osm2rdfgeom:envelope \"POLYGON((48 "
"7.5,48.1 7.5,48.1 7.6,48 7.6,48 7.5))\"^^geo:wktLiteral .\nosmway:42 "
"osm2rdfgeom:obb \"POLYGON((48.1 7.6,48.1 7.6,48 7.5,48 7.5,48.1 "
"7.6))\"^^geo:wktLiteral .\nosmway:42 osm2rdf:length "
"\"0.141421\"^^xsd:double .\n",
buffer.str());

// Cleanup
std::cout.rdbuf(sbuf);
}

// ____________________________________________________________________________
TEST(OSM_FactHandler, wayAddWayNodeOrder) {
// Capture std::cout
Expand Down
32 changes: 16 additions & 16 deletions tests/osm/OsmiumHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ TEST(OSM_OsmiumHandler, noFacts) {
ASSERT_EQ(2, osmiumHandler.areaGeometriesHandled());
ASSERT_EQ(2, osmiumHandler.nodesSeen());
ASSERT_EQ(0, osmiumHandler.nodesDumped());
ASSERT_EQ(1, osmiumHandler.nodeGeometriesHandled());
ASSERT_EQ(2, osmiumHandler.nodeGeometriesHandled());
ASSERT_EQ(3, osmiumHandler.relationsSeen());
ASSERT_EQ(0, osmiumHandler.relationsDumped());
ASSERT_EQ(0, osmiumHandler.relationGeometriesHandled());
Expand Down Expand Up @@ -224,7 +224,7 @@ TEST(OSM_OsmiumHandler, noGeometricRelations) {
ASSERT_EQ(2, osmiumHandler.areasDumped());
ASSERT_EQ(0, osmiumHandler.areaGeometriesHandled());
ASSERT_EQ(2, osmiumHandler.nodesSeen());
ASSERT_EQ(1, osmiumHandler.nodesDumped());
ASSERT_EQ(2, osmiumHandler.nodesDumped());
ASSERT_EQ(0, osmiumHandler.nodeGeometriesHandled());
ASSERT_EQ(3, osmiumHandler.relationsSeen());
ASSERT_EQ(3, osmiumHandler.relationsDumped());
Expand Down Expand Up @@ -266,8 +266,8 @@ TEST(OSM_OsmiumHandler, noAreaFacts) {
ASSERT_EQ(0, osmiumHandler.areasDumped());
ASSERT_EQ(2, osmiumHandler.areaGeometriesHandled());
ASSERT_EQ(2, osmiumHandler.nodesSeen());
ASSERT_EQ(1, osmiumHandler.nodesDumped());
ASSERT_EQ(1, osmiumHandler.nodeGeometriesHandled());
ASSERT_EQ(2, osmiumHandler.nodesDumped());
ASSERT_EQ(2, osmiumHandler.nodeGeometriesHandled());
ASSERT_EQ(3, osmiumHandler.relationsSeen());
ASSERT_EQ(3, osmiumHandler.relationsDumped());
ASSERT_EQ(0, osmiumHandler.relationGeometriesHandled());
Expand Down Expand Up @@ -309,7 +309,7 @@ TEST(OSM_OsmiumHandler, noNodeFacts) {
ASSERT_EQ(2, osmiumHandler.areaGeometriesHandled());
ASSERT_EQ(2, osmiumHandler.nodesSeen());
ASSERT_EQ(0, osmiumHandler.nodesDumped());
ASSERT_EQ(1, osmiumHandler.nodeGeometriesHandled());
ASSERT_EQ(2, osmiumHandler.nodeGeometriesHandled());
ASSERT_EQ(3, osmiumHandler.relationsSeen());
ASSERT_EQ(3, osmiumHandler.relationsDumped());
ASSERT_EQ(0, osmiumHandler.relationGeometriesHandled());
Expand Down Expand Up @@ -350,8 +350,8 @@ TEST(OSM_OsmiumHandler, noRelationFacts) {
ASSERT_EQ(2, osmiumHandler.areasDumped());
ASSERT_EQ(2, osmiumHandler.areaGeometriesHandled());
ASSERT_EQ(2, osmiumHandler.nodesSeen());
ASSERT_EQ(1, osmiumHandler.nodesDumped());
ASSERT_EQ(1, osmiumHandler.nodeGeometriesHandled());
ASSERT_EQ(2, osmiumHandler.nodesDumped());
ASSERT_EQ(2, osmiumHandler.nodeGeometriesHandled());
ASSERT_EQ(3, osmiumHandler.relationsSeen());
ASSERT_EQ(0, osmiumHandler.relationsDumped());
ASSERT_EQ(0, osmiumHandler.relationGeometriesHandled());
Expand Down Expand Up @@ -392,8 +392,8 @@ TEST(OSM_OsmiumHandler, noWayFacts) {
ASSERT_EQ(2, osmiumHandler.areasDumped());
ASSERT_EQ(2, osmiumHandler.areaGeometriesHandled());
ASSERT_EQ(2, osmiumHandler.nodesSeen());
ASSERT_EQ(1, osmiumHandler.nodesDumped());
ASSERT_EQ(1, osmiumHandler.nodeGeometriesHandled());
ASSERT_EQ(2, osmiumHandler.nodesDumped());
ASSERT_EQ(2, osmiumHandler.nodeGeometriesHandled());
ASSERT_EQ(3, osmiumHandler.relationsSeen());
ASSERT_EQ(3, osmiumHandler.relationsDumped());
ASSERT_EQ(0, osmiumHandler.relationGeometriesHandled());
Expand Down Expand Up @@ -434,8 +434,8 @@ TEST(OSM_OsmiumHandler, noAreaGeometricRelations) {
ASSERT_EQ(2, osmiumHandler.areasDumped());
ASSERT_EQ(0, osmiumHandler.areaGeometriesHandled());
ASSERT_EQ(2, osmiumHandler.nodesSeen());
ASSERT_EQ(1, osmiumHandler.nodesDumped());
ASSERT_EQ(1, osmiumHandler.nodeGeometriesHandled());
ASSERT_EQ(2, osmiumHandler.nodesDumped());
ASSERT_EQ(2, osmiumHandler.nodeGeometriesHandled());
ASSERT_EQ(3, osmiumHandler.relationsSeen());
ASSERT_EQ(3, osmiumHandler.relationsDumped());
ASSERT_EQ(0, osmiumHandler.relationGeometriesHandled());
Expand Down Expand Up @@ -476,7 +476,7 @@ TEST(OSM_OsmiumHandler, noNodeGeometricRelations) {
ASSERT_EQ(2, osmiumHandler.areasDumped());
ASSERT_EQ(2, osmiumHandler.areaGeometriesHandled());
ASSERT_EQ(2, osmiumHandler.nodesSeen());
ASSERT_EQ(1, osmiumHandler.nodesDumped());
ASSERT_EQ(2, osmiumHandler.nodesDumped());
ASSERT_EQ(0, osmiumHandler.nodeGeometriesHandled());
ASSERT_EQ(3, osmiumHandler.relationsSeen());
ASSERT_EQ(3, osmiumHandler.relationsDumped());
Expand Down Expand Up @@ -518,8 +518,8 @@ TEST(OSM_OsmiumHandler, noWayGeometricRelations) {
ASSERT_EQ(2, osmiumHandler.areasDumped());
ASSERT_EQ(2, osmiumHandler.areaGeometriesHandled());
ASSERT_EQ(2, osmiumHandler.nodesSeen());
ASSERT_EQ(1, osmiumHandler.nodesDumped());
ASSERT_EQ(1, osmiumHandler.nodeGeometriesHandled());
ASSERT_EQ(2, osmiumHandler.nodesDumped());
ASSERT_EQ(2, osmiumHandler.nodeGeometriesHandled());
ASSERT_EQ(3, osmiumHandler.relationsSeen());
ASSERT_EQ(3, osmiumHandler.relationsDumped());
ASSERT_EQ(0, osmiumHandler.relationGeometriesHandled());
Expand Down Expand Up @@ -830,7 +830,7 @@ TEST(OSM_OsmiumHandler, handleSingleNode) {
ASSERT_THAT(printedState,
::testing::HasSubstr("areas seen:0 dumped: 0 geometry: 0\n"));
ASSERT_THAT(printedState,
::testing::HasSubstr("nodes seen:1 dumped: 0 geometry: 0\n"));
::testing::HasSubstr("nodes seen:1 dumped: 1 geometry: 1\n"));
ASSERT_THAT(printedState,
::testing::HasSubstr("relations seen:0 dumped: 0 geometry: 0\n"));
ASSERT_THAT(printedState,
Expand Down Expand Up @@ -915,7 +915,7 @@ TEST(OSM_OsmiumHandler, handleOSMWikiExample) {
ASSERT_THAT(printedState,
::testing::HasSubstr("areas seen:0 dumped: 0 geometry: 0\n"));
ASSERT_THAT(printedState,
::testing::HasSubstr("nodes seen:4 dumped: 1 geometry: 1\n"));
::testing::HasSubstr("nodes seen:4 dumped: 4 geometry: 4\n"));
ASSERT_THAT(printedState,
::testing::HasSubstr("relations seen:1 dumped: 1 geometry: 0\n"));
ASSERT_THAT(printedState,
Expand Down

0 comments on commit 2ffa180

Please sign in to comment.