region: commenting and style for test cases
This commit is contained in:
parent
3460d5edbe
commit
a27869d1c8
@ -10,35 +10,54 @@ main (int, char **)
|
|||||||
{
|
{
|
||||||
util::TAP::logger tap;
|
util::TAP::logger tap;
|
||||||
|
|
||||||
|
// check that two overlapping regions successfully test for intersection
|
||||||
{
|
{
|
||||||
util::point2d ap { 32.7, -6.09703 };
|
const util::point2d ap { 32.7, -6.09703 };
|
||||||
util::extent2d ae { 0.8, 2. };
|
const util::extent2d ae { 0.8, 2. };
|
||||||
|
const util::region2d a (ap, ae);
|
||||||
|
|
||||||
util::point2d bp {33.5, -4.5};
|
const util::point2d bp {33.5, -4.5};
|
||||||
util::extent2d be { 0.5, 0.5 };
|
const util::extent2d be { 0.5, 0.5 };
|
||||||
|
const util::region2d b (bp, be);
|
||||||
util::region2d a (ap, ae);
|
|
||||||
util::region2d b (bp, be);
|
|
||||||
|
|
||||||
tap.expect (!a.intersects (b), "simple 2d intersection");
|
tap.expect (!a.intersects (b), "simple 2d intersection");
|
||||||
}
|
}
|
||||||
|
|
||||||
tap.expect (util::region2d::max ().intersects (util::region2d::unit ()), "maximal region2d intersection");
|
// check various floating point maximums successfully test for
|
||||||
tap.expect (util::region2f::max ().intersects (util::region2f::unit ()), "maximal region2f intersection");
|
// intersection. the concern is that infinities are incorrectly handled
|
||||||
|
// in some comparisons.
|
||||||
|
tap.expect (
|
||||||
|
util::region2d::max ().intersects (
|
||||||
|
util::region2d::unit ()
|
||||||
|
),
|
||||||
|
"maximal region2d intersection"
|
||||||
|
);
|
||||||
|
|
||||||
|
tap.expect (
|
||||||
|
util::region2f::max ().intersects (
|
||||||
|
util::region2f::unit ()
|
||||||
|
),
|
||||||
|
"maximal region2f intersection"
|
||||||
|
);
|
||||||
|
|
||||||
|
// ensure unit regions are... unit sized...
|
||||||
tap.expect_eq (util::region2d::unit ().area (), 1.0, "unit region2d area");
|
tap.expect_eq (util::region2d::unit ().area (), 1.0, "unit region2d area");
|
||||||
tap.expect_eq (util::region2f::unit ().area (), 1.0f, "unit region2f area");
|
tap.expect_eq (util::region2f::unit ().area (), 1.0f, "unit region2f area");
|
||||||
|
|
||||||
util::point2u p0 { 0 };
|
// test boundary cases of includes and contains
|
||||||
util::extent2u e0 { 2 };
|
{
|
||||||
|
const util::point2u p0 { 0 };
|
||||||
|
const util::extent2u e0 { 2 };
|
||||||
|
const util::region2u r {p0, e0};
|
||||||
|
|
||||||
tap.expect (util::region2u (p0, e0).includes (util::point2u {1, 1}), "unsigned region centre inclusion");
|
tap.expect (r.includes (util::point2u {1, 1}), "unsigned region centre inclusion");
|
||||||
tap.expect (util::region2u (p0, e0).includes (util::point2u {0, 0}), "unsigned region base inclusion");
|
tap.expect (r.includes (util::point2u {0, 0}), "unsigned region base inclusion");
|
||||||
tap.expect (util::region2u (p0, e0).includes (util::point2u {2, 2}), "unsigned region corner inclusion");
|
tap.expect (r.includes (util::point2u {2, 2}), "unsigned region corner inclusion");
|
||||||
|
|
||||||
tap.expect ( util::region2u (p0, e0).contains (util::point2u {1, 1}), "unsigned region center contains");
|
tap.expect ( r.contains (util::point2u {1, 1}), "unsigned region center contains");
|
||||||
tap.expect (!util::region2u (p0, e0).contains (util::point2u {0, 0}), "unsigned region base contains");
|
tap.expect (!r.contains (util::point2u {0, 0}), "unsigned region base contains");
|
||||||
tap.expect (!util::region2u (p0, e0).contains (util::point2u {2, 2}), "unsigned region corner contains");
|
tap.expect (!r.contains (util::point2u {2, 2}), "unsigned region corner contains");
|
||||||
|
}
|
||||||
|
|
||||||
//CHECK (region<2,intmax_t> (0, 0, 10, 10).includes (point2d (0.4, 0.01)));
|
//CHECK (region<2,intmax_t> (0, 0, 10, 10).includes (point2d (0.4, 0.01)));
|
||||||
//CHECK (region<2,intmax_t> (0, 0, 10, 10).contains (point2d (0.4, 0.01)));
|
//CHECK (region<2,intmax_t> (0, 0, 10, 10).contains (point2d (0.4, 0.01)));
|
||||||
|
Loading…
Reference in New Issue
Block a user