Skip to content

v0.2.49..v0.2.50 changeset NodesPerWayVisitorTest.cpp

Garret Voltz edited this page Nov 6, 2019 · 1 revision
diff --git a/hoot-core-test/src/test/cpp/hoot/core/visitors/NodesPerWayVisitorTest.cpp b/hoot-core-test/src/test/cpp/hoot/core/visitors/NodesPerWayVisitorTest.cpp
index 0a7412f..74747bc 100644
--- a/hoot-core-test/src/test/cpp/hoot/core/visitors/NodesPerWayVisitorTest.cpp
+++ b/hoot-core-test/src/test/cpp/hoot/core/visitors/NodesPerWayVisitorTest.cpp
@@ -30,16 +30,16 @@
 #include <hoot/core/TestUtils.h>
 #include <hoot/core/io/OsmMapReaderFactory.h>
 #include <hoot/core/visitors/NodesPerWayVisitor.h>
+#include <hoot/core/criterion/BuildingCriterion.h>
 
 namespace hoot
 {
 
-static const QString input = "test-files/ToyTestA.osm";
-
 class NodesPerWayVisitorTest : public HootTestFixture
 {
   CPPUNIT_TEST_SUITE(NodesPerWayVisitorTest);
   CPPUNIT_TEST(runBasicTest);
+  CPPUNIT_TEST(runCritTest);
   CPPUNIT_TEST_SUITE_END();
 
 public:
@@ -52,16 +52,34 @@ public:
   void runBasicTest()
   {
     OsmMapPtr map(new OsmMap());
-    OsmMapReaderFactory::read(map, input, false, Status::Unknown1);
+    OsmMapReaderFactory::read(map, "test-files/ToyTestA.osm", false, Status::Unknown1);
 
     NodesPerWayVisitor uut;
-    map->visitRo(uut);
+    // rw here b/c MultipleCriterionConsumerVisitor inherits from ElementVisitor and not
+    // ConstElementVisitor
+    map->visitRw(uut);
 
     CPPUNIT_ASSERT_EQUAL(40, (int)uut.getStat());
     CPPUNIT_ASSERT_EQUAL(3, (int)uut.getMin());
     CPPUNIT_ASSERT_EQUAL(30, (int)uut.getMax());
     CPPUNIT_ASSERT_EQUAL(10.0, uut.getAverage());
   }
+
+  void runCritTest()
+  {
+    OsmMapPtr map(new OsmMap());
+    OsmMapReaderFactory::read(
+      map, "test-files/conflate/unified/AllDataTypesA.osm", false, Status::Unknown1);
+
+    NodesPerWayVisitor uut;
+    uut.addCriterion(std::shared_ptr<BuildingCriterion>(new BuildingCriterion()));
+    map->visitRw(uut);
+
+    CPPUNIT_ASSERT_EQUAL(81, (int)uut.getStat());
+    CPPUNIT_ASSERT_EQUAL(5, (int)uut.getMin());
+    CPPUNIT_ASSERT_EQUAL(33, (int)uut.getMax());
+    CPPUNIT_ASSERT_EQUAL(8.0, uut.getAverage());
+  }
 };
 
 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(NodesPerWayVisitorTest, "quick");
Clone this wiki locally