Mercurial > hg > nsaunier > traffic-intelligence
comparison trajectorymanagement/test/ChebyshevMetricTest.cpp @ 1159:e1e7acef8eab
moved trajectory management library into Traffic Intelligence
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Mon, 22 Feb 2021 22:09:35 -0500 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1158:7eb972942f22 | 1159:e1e7acef8eab |
|---|---|
| 1 #include "ChebyshevMetricTest.h" | |
| 2 | |
| 3 void ChebyshevMetricTest::setUp(void) | |
| 4 { | |
| 5 trajectoryA = new Trajectory<CvPoint> (); | |
| 6 trajectoryB = new Trajectory<CvPoint> (); | |
| 7 metric = new ChebyshevMetric<CvPoint, int> (); | |
| 8 } | |
| 9 | |
| 10 void ChebyshevMetricTest::tearDown(void) | |
| 11 { | |
| 12 delete trajectoryA; | |
| 13 delete trajectoryB; | |
| 14 delete metric; | |
| 15 | |
| 16 trajectoryA = NULL; | |
| 17 trajectoryB = NULL; | |
| 18 metric = NULL; | |
| 19 } | |
| 20 | |
| 21 void ChebyshevMetricTest::testMetric1(void) | |
| 22 { | |
| 23 int result = 0; | |
| 24 CPPUNIT_ASSERT_THROW(metric->distance(trajectoryA, trajectoryB, result), TrajectoryLengthErrorException); | |
| 25 } | |
| 26 | |
| 27 void ChebyshevMetricTest::testMetric2(void) | |
| 28 { | |
| 29 int result = 0; | |
| 30 trajectoryA->add(cvPoint(0, 0)); | |
| 31 trajectoryB->add(cvPoint(0, 0)); | |
| 32 metric->distance(trajectoryA, trajectoryB, result); | |
| 33 CPPUNIT_ASSERT_EQUAL(result, 0); | |
| 34 } | |
| 35 | |
| 36 void ChebyshevMetricTest::testMetric3(void) | |
| 37 { | |
| 38 int result = 0; | |
| 39 trajectoryA->add(cvPoint(0, 0)); | |
| 40 trajectoryB->add(cvPoint(1, 1)); | |
| 41 metric->distance(trajectoryA, trajectoryB, result); | |
| 42 CPPUNIT_ASSERT_EQUAL(result, 1); | |
| 43 } | |
| 44 | |
| 45 void ChebyshevMetricTest::testMetric4(void) | |
| 46 { | |
| 47 int result = 0; | |
| 48 trajectoryA->add(cvPoint(0, 0)); | |
| 49 trajectoryB->add(cvPoint(3, 4)); | |
| 50 metric->distance(trajectoryA, trajectoryB, result); | |
| 51 CPPUNIT_ASSERT_EQUAL(result, 4); | |
| 52 } | |
| 53 | |
| 54 void ChebyshevMetricTest::testMetric5(void) | |
| 55 { | |
| 56 int result = 0; | |
| 57 trajectoryA->add(cvPoint(0, 0)); | |
| 58 trajectoryA->add(cvPoint(-4, -3)); | |
| 59 trajectoryB->add(cvPoint(3, 4)); | |
| 60 trajectoryB->add(cvPoint(0, 0)); | |
| 61 metric->distance(trajectoryA, trajectoryB, result); | |
| 62 CPPUNIT_ASSERT_EQUAL(result, 4); | |
| 63 } | |
| 64 | |
| 65 void ChebyshevMetricTest::testMetric6(void) | |
| 66 { | |
| 67 int result = 0; | |
| 68 unsigned n = 100; | |
| 69 for (unsigned i = 0; i < n; ++i) | |
| 70 { | |
| 71 trajectoryA->add(cvPoint(i, i)); | |
| 72 trajectoryB ->add(cvPoint(i * 2, i * 3)); | |
| 73 } | |
| 74 metric->distance(trajectoryA, trajectoryB, result); | |
| 75 CPPUNIT_ASSERT_EQUAL(result, int((n - 1) * 2)); | |
| 76 } |
