Skip to content

v0.2.52..v0.2.53 changeset OsmXmlReaderTest.cpp

Garret Voltz edited this page Feb 12, 2020 · 1 revision
diff --git a/hoot-core-test/src/test/cpp/hoot/core/io/OsmXmlReaderTest.cpp b/hoot-core-test/src/test/cpp/hoot/core/io/OsmXmlReaderTest.cpp
index 14c3b04..ea3df4f 100644
--- a/hoot-core-test/src/test/cpp/hoot/core/io/OsmXmlReaderTest.cpp
+++ b/hoot-core-test/src/test/cpp/hoot/core/io/OsmXmlReaderTest.cpp
@@ -22,7 +22,7 @@
  * This will properly maintain the copyright information. DigitalGlobe
  * copyrights will be updated automatically.
  *
- * @copyright Copyright (C) 2012, 2013, 2014, 2017, 2018, 2019 DigitalGlobe (http://www.digitalglobe.com/)
+ * @copyright Copyright (C) 2012, 2013, 2014, 2017, 2018, 2019, 2020 DigitalGlobe (http://www.digitalglobe.com/)
  */
 
 // Hoot
@@ -45,6 +45,7 @@ class OsmXmlReaderTest : public HootTestFixture
   CPPUNIT_TEST(runDecodeCharsTest);
   CPPUNIT_TEST(runBoundsTest);
   CPPUNIT_TEST(runBoundsLeaveConnectedOobWaysTest);
+  CPPUNIT_TEST(runIgnoreDuplicateMergeTest);
   CPPUNIT_TEST_SUITE_END();
 
 public:
@@ -226,9 +227,36 @@ public:
     OsmMapPtr map(new OsmMap());
     uut.read("test-files/ops/ImmediatelyConnectedOutOfBoundsWayTagger/in.osm", map);
     uut.close();
-    OsmMapWriterFactory::write(map, _outputPath + "/" + testFileName, false, true);
+    OsmMapWriterFactory::write(map, _outputPath + testFileName, false, true);
 
-    HOOT_FILE_EQUALS(_inputPath + "/" + testFileName, _outputPath + "/" + testFileName);
+    HOOT_FILE_EQUALS(_inputPath + testFileName, _outputPath + testFileName);
+  }
+
+  void runIgnoreDuplicateMergeTest()
+  {
+    //  This test opens two versions of ToyTestA (with positive IDs) that contain duplicate nodes
+    //  and ways that should result in merging them both into ToyTestA
+    const QString testFileName = "IgnoreDuplicateMergeTest.osm";
+
+    //  Set the merge ignore duplicate IDs flag
+    conf().set(ConfigOptions::getMapMergeIgnoreDuplicateIdsKey(), true);
+
+    OsmXmlReader uut;
+    uut.setIgnoreDuplicates(true);
+    uut.setUseDataSourceIds(true);
+    OsmMapPtr map(new OsmMap());
+    uut.read(_inputPath + "IgnoreDuplicateMergeTest-1.osm", map);
+    uut.read(_inputPath + "IgnoreDuplicateMergeTest-2.osm", map);
+    uut.close();
+
+    conf().set(ConfigOptions::getWriterIncludeCircularErrorTagsKey(), false);
+
+    OsmMapWriterFactory::write(map, _outputPath + testFileName, false, false);
+
+    //  Since HOOT_FILE_EQUALS uses a reader factory, turn off the flag because it breaks it
+    conf().set(ConfigOptions::getMapMergeIgnoreDuplicateIdsKey(), false);
+
+    HOOT_FILE_EQUALS(_inputPath + testFileName, _outputPath + testFileName);
   }
 };
 
Clone this wiki locally