libcruft-util/test/region.cpp

37 lines
1.2 KiB
C++
Raw Normal View History

2012-05-11 12:21:47 +10:00
#include "../region.hpp"
2012-06-08 16:48:33 +10:00
#include "../point.hpp"
#include "../debug.hpp"
2012-05-11 12:21:47 +10:00
using util::region;
using util::point;
using util::point2d;
2012-05-11 12:21:47 +10:00
int
main (int, char **) {
{
region<double> a (32.7, -6.09703, 0.8, 2);
region<double> b (33.5, -4.5, 0.5, 0.5);
CHECK (!a.intersects (b));
2012-05-11 12:21:47 +10:00
}
CHECK (region<double>::MAX.intersects (region<double>::UNIT));
CHECK (region< float>::MAX.intersects (region< float>::UNIT));
2012-06-15 16:38:57 +10:00
CHECK_EQ (region<double>::UNIT.area (), 1.0);
CHECK_EQ (region< float>::UNIT.area (), 1.0f);
CHECK (region<unsigned> (0, 0, 2, 2).includes (point<2,unsigned>(1, 1)));
CHECK (region<unsigned> (0, 0, 2, 2).includes (point<2,unsigned>(0, 0)));
CHECK (region<unsigned> (0, 0, 2, 2).includes (point<2,unsigned>(2, 2)));
2012-06-08 16:48:33 +10:00
CHECK ( region<unsigned> (0, 0, 2, 2).contains (point<2,unsigned>(1, 1)));
CHECK (!region<unsigned> (0, 0, 2, 2).contains (point<2,unsigned>(0, 0)));
CHECK (!region<unsigned> (0, 0, 2, 2).contains (point<2,unsigned>(2, 2)));
2012-06-08 16:48:33 +10:00
//CHECK (region<intmax_t> (0, 0, 10, 10).includes (point2d (0.4, 0.01)));
//CHECK (region<intmax_t> (0, 0, 10, 10).contains (point2d (0.4, 0.01)));
2012-06-08 16:48:33 +10:00
2012-05-11 12:21:47 +10:00
return 0;
}