-
Notifications
You must be signed in to change notification settings - Fork 74
v0.2.50..v0.2.51 changeset OsmJsonReaderTest.cpp
Garret Voltz edited this page Jan 15, 2020
·
1 revision
diff --git a/hoot-core-test/src/test/cpp/hoot/core/io/OsmJsonReaderTest.cpp b/hoot-core-test/src/test/cpp/hoot/core/io/OsmJsonReaderTest.cpp
index def1b61..84fb225 100644
--- a/hoot-core-test/src/test/cpp/hoot/core/io/OsmJsonReaderTest.cpp
+++ b/hoot-core-test/src/test/cpp/hoot/core/io/OsmJsonReaderTest.cpp
@@ -51,6 +51,9 @@ class OsmJsonReaderTest : public HootTestFixture
CPPUNIT_TEST(isSupportedTest);
CPPUNIT_TEST(runBoundsTest);
CPPUNIT_TEST(runBoundsLeaveConnectedOobWaysTest);
+ CPPUNIT_TEST(elementTypeUnorderedTest);
+ CPPUNIT_TEST(elementTypeUnorderedMissingTest);
+ // TODO: add duplicates test
CPPUNIT_TEST_SUITE_END();
public:
@@ -58,6 +61,7 @@ public:
OsmJsonReaderTest() :
HootTestFixture("test-files/io/OsmJsonReaderTest/", "test-output/io/OsmJsonReaderTest/")
{
+ setResetType(ResetBasic);
}
void nodeTest()
@@ -335,9 +339,10 @@ public:
CPPUNIT_ASSERT(TestUtils::compareMaps(pMap, pTestMap));
}
- // Try hitting the network to get some data...
void urlTest()
{
+ // Try hitting the network to get some data...
+
// needed to suppress map crop missing element warnings
DisableLog dl;
@@ -625,6 +630,77 @@ public:
HOOT_FILE_EQUALS(_inputPath + "/" + testFileName, _outputPath + "/" + testFileName);
}
+
+ void elementTypeUnorderedTest()
+ {
+ // This should load the elements even though child elements come after their parents.
+
+ // TODO: we need some relations in the test input
+
+ QString testFileName;
+ OsmJsonReader uut;
+ OsmMapPtr map;
+
+ TestUtils::resetBasic();
+ testFileName = "elementTypeUnorderedTest1.osm";
+ uut.setUseDataSourceIds(true);
+ map.reset(new OsmMap());
+ uut.open(_inputPath + "elementTypeUnorderedTest-in.json");
+ uut.read(map);
+ uut.close();
+ OsmMapWriterFactory::write(map, _outputPath + "/" + testFileName, false, true);
+ HOOT_FILE_EQUALS(_inputPath + "/" + testFileName, _outputPath + "/" + testFileName);
+
+ // same as above except we create our own element ids this time
+
+ TestUtils::resetBasic();
+ testFileName = "elementTypeUnorderedTest2.osm";
+ uut.setUseDataSourceIds(false);
+ map.reset(new OsmMap());
+ uut.open(_inputPath + "elementTypeUnorderedTest-in.json");
+ uut.read(map);
+ uut.close();
+ OsmMapWriterFactory::write(map, _outputPath + "/" + testFileName, false, true);
+ HOOT_FILE_EQUALS(_inputPath + "/" + testFileName, _outputPath + "/" + testFileName);
+ }
+
+ void elementTypeUnorderedMissingTest()
+ {
+ // There is one node referenced by a way that doesn't exist in the file (id=2442180398). That
+ // node should not be present in the output way.
+
+ // TODO: we need some relations and way refs in the test input
+
+ // The default behavior is to log missing elements as warnings, and we don't want to see that in
+ // this test;
+ DisableLog dl;
+
+ QString outputFile;
+ OsmJsonReader uut;
+ OsmMapPtr map;
+
+ TestUtils::resetBasic();
+ outputFile = "elementTypeUnorderedMissingTest1.osm";
+ uut.setUseDataSourceIds(true);
+ map.reset(new OsmMap());
+ uut.open(_inputPath + "elementTypeUnorderedMissingTest-in.json");
+ uut.read(map);
+ uut.close();
+ OsmMapWriterFactory::write(map, _outputPath + "/" + outputFile, false, true);
+ HOOT_FILE_EQUALS(_inputPath + "/" + outputFile, _outputPath + "/" + outputFile);
+
+ // same as above except we create our own element ids this time
+
+ TestUtils::resetBasic();
+ outputFile = "elementTypeUnorderedMissingTest2.osm";
+ uut.setUseDataSourceIds(false);
+ map.reset(new OsmMap());
+ uut.open(_inputPath + "elementTypeUnorderedMissingTest-in.json");
+ uut.read(map);
+ uut.close();
+ OsmMapWriterFactory::write(map, _outputPath + "/" + outputFile, false, true);
+ HOOT_FILE_EQUALS(_inputPath + "/" + outputFile, _outputPath + "/" + outputFile);
+ }
};
}