diff c/test_graph.cpp @ 231:249d65ff6c35

merged modifications for windows
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Mon, 02 Jul 2012 23:49:39 -0400
parents bc4ea09b1743 f0f800b95765
children cc8e54997d4c
line wrap: on
line diff
--- a/c/test_graph.cpp	Fri Jun 29 16:15:13 2012 -0400
+++ b/c/test_graph.cpp	Mon Jul 02 23:49:39 2012 -0400
@@ -3,42 +3,39 @@
 
 #include "opencv2/core/core.hpp"
 
-#include <boost/test/unit_test.hpp>
-#include <boost/test/floating_point_comparison.hpp>
+#include "catch.hpp"
 
 #include <iostream>
 
 using namespace std;
 using namespace cv;
 
-BOOST_AUTO_TEST_SUITE(test_graph)
-
-BOOST_AUTO_TEST_CASE(graph_add_connected_components) {
+TEST_CASE("graph/connected_components", "test graph connected components") {
   FeatureGraph featureGraph(5, 1, 5 , 1.); // (float _connectionDistance, float _segmentationDistance, unsigned int _minFeatureTime, float _minNFeaturesPerGroup)
   unsigned int lastInstant = 20;
   FeatureTrajectoryPtr ft1 = createFeatureTrajectory(1, 10, lastInstant, Point2f(1,1), Point2f(0.5, 0.));
   FeatureTrajectoryPtr ft2 = createFeatureTrajectory(2, 10, lastInstant, Point2f(1.1,1), Point2f(0.5, 0.));
 
   featureGraph.addFeature(ft1);
-  BOOST_CHECK_EQUAL(featureGraph.getNVertices(), 1);
-  BOOST_CHECK_EQUAL(featureGraph.getNEdges(), 0);
+  REQUIRE(featureGraph.getNVertices() == 1);
+  REQUIRE(featureGraph.getNEdges() == 0);
 
   featureGraph.addFeature(ft2);
-  BOOST_CHECK_EQUAL(featureGraph.getNVertices(), 2);
-  BOOST_CHECK_EQUAL(featureGraph.getNEdges(), 1);
+  REQUIRE(featureGraph.getNVertices() == 2);
+  REQUIRE(featureGraph.getNEdges() == 1);
 
   featureGraph.connectedComponents(lastInstant);
-  std::vector<std::vector<unsigned int> > components = featureGraph.getFeatureGroups();
-  BOOST_CHECK_EQUAL(components.size(), 0);
-  BOOST_CHECK_EQUAL(featureGraph.getNVertices(), 2);
-  BOOST_CHECK_EQUAL(featureGraph.getNEdges(), 1);
+  vector<vector<unsigned int> > components = featureGraph.getFeatureGroups();
+  REQUIRE(components.size() == 0);
+  REQUIRE(featureGraph.getNVertices() == 2);
+  REQUIRE(featureGraph.getNEdges() == 1);
 
   featureGraph.connectedComponents(lastInstant+1);
   components = featureGraph.getFeatureGroups();
-  BOOST_CHECK_EQUAL(components.size(), 1);
-  BOOST_CHECK_EQUAL(components[0].size(), 2);
-  BOOST_CHECK_EQUAL(featureGraph.getNVertices(), 0);
-  BOOST_CHECK_EQUAL(featureGraph.getNEdges(), 0);
+  REQUIRE(components.size() == 1);
+  REQUIRE(components[0].size() == 2);
+  REQUIRE(featureGraph.getNVertices() == 0);
+  REQUIRE(featureGraph.getNEdges() == 0);
 
   // test connection distance
   featureGraph.addFeature(ft1);
@@ -48,16 +45,14 @@
   FeatureTrajectoryPtr ft4 = createFeatureTrajectory(4, 10, lastInstant, Point2f(11.1,1), Point2f(0.5, 0.)); // not connected
   featureGraph.addFeature(ft4);
 
-  BOOST_CHECK_EQUAL(featureGraph.getNVertices(), 4);
-  BOOST_CHECK_EQUAL(featureGraph.getNEdges(), 2);
+  REQUIRE(featureGraph.getNVertices() == 4);
+  REQUIRE(featureGraph.getNEdges() == 2);
 
   featureGraph.connectedComponents(lastInstant+1);
   components = featureGraph.getFeatureGroups();
-  BOOST_CHECK_EQUAL(components.size(), 2);
-  BOOST_CHECK_EQUAL(components[0].size(), 3);
-  BOOST_CHECK_EQUAL(components[1].size(), 1);
-  BOOST_CHECK_EQUAL(featureGraph.getNVertices(), 0);
-  BOOST_CHECK_EQUAL(featureGraph.getNEdges(), 0);
+  REQUIRE(components.size() == 2);
+  REQUIRE(components[0].size() == 3);
+  REQUIRE(components[1].size() == 1);
+  REQUIRE(featureGraph.getNVertices() == 0);
+  REQUIRE(featureGraph.getNEdges() == 0);
 }
-
-BOOST_AUTO_TEST_SUITE_END()