libcruft-util/test/geom/aabb.cpp

33 lines
584 B
C++
Raw Normal View History

#include "geom/aabb.hpp"
2015-04-09 14:05:01 +10:00
2015-04-13 16:45:56 +10:00
#include "tap.hpp"
#include <tuple>
using util::geom::AABB2f;
2015-04-13 16:45:56 +10:00
2015-04-09 14:05:01 +10:00
int
main (int, char**)
{
2015-04-13 16:45:56 +10:00
util::TAP::logger tap;
2015-04-09 14:05:01 +10:00
{
// Test contraction
2017-08-24 16:25:57 +10:00
const AABB2f val { { 2, 2 }, { 8, 8 } };
const AABB2f res { { 3, 3 }, { 7, 7 } };
2015-04-09 14:05:01 +10:00
2017-08-24 16:25:57 +10:00
tap.expect_eq (val.contracted (2.f), res, "over contraction");
2015-04-09 14:05:01 +10:00
}
{
// Test expansion
2017-08-24 16:25:57 +10:00
const AABB2f val { { 2, 2 }, { 8, 8 } };
const AABB2f res { { 1, 1 }, { 9, 9 } };
2015-04-09 14:05:01 +10:00
2017-08-24 16:25:57 +10:00
tap.expect_eq (val.expanded (2.f), res, "expansion");
2015-04-09 14:05:01 +10:00
}
return tap.status ();
2015-04-09 14:05:01 +10:00
}