DGtal  1.5.beta
testPointHashFunctions.cpp
Go to the documentation of this file.
1 
31 #include <iostream>
32 #include "DGtal/base/Common.h"
33 #include "ConfigTest.h"
34 #include "DGtal/helpers/StdDefs.h"
35 
36 #include "DGtalCatch.h"
37 
38 #include "DGtal/kernel/PointVector.h"
39 #include "DGtal/helpers/StdDefs.h"
40 #include "DGtal/kernel/PointHashFunctions.h"
42 
43 using namespace std;
44 using namespace DGtal;
45 
46 
47 
48 TEST_CASE("Hash functions on DGtal::Point")
49 {
50  Z3i::Point p(0,0,0);
51  Z3i::Point q(10,0,0);
52  Z3i::Point p_copy(0,0,0);
53  std::hash<Z3i::Point> myhashcpp11;
54 
55  SECTION("Identity test")
56  {
57  REQUIRE( myhashcpp11(p) == myhashcpp11(p_copy) );
58  }
59 
60 
61  SECTION("Difference test")
62  {
63  REQUIRE( myhashcpp11(p) != myhashcpp11(q) );
64  }
65 
66  SECTION("Higher dimension identity test")
67  {
68  typedef PointVector<26,int> Point26;
69  Point26 pp=Point26::diagonal(12),
70  qq=(Point26::diagonal(11) + Point26::diagonal(1)),
71  rr=Point26::diagonal(13);
72 
73  std::hash<Point26> myhash26cpp11;
74 
75  REQUIRE( myhash26cpp11(pp) == myhash26cpp11(qq) );
76  REQUIRE( myhash26cpp11(pp) != myhash26cpp11(rr) );
77  }
78 }
DGtal is the top-level namespace which contains all DGtal functions and types.
TEST_CASE("Hash functions on DGtal::Point")
SECTION("Testing constant forward iterators")
REQUIRE(domain.isInside(aPoint))