libcruft-util/test/extent.cpp
Danny Robson 7b083df977 maths: tighten up type requirements for almost_equal
almost_equal only operates on two reals, or two integers (and even then
only on the same signedness).
2015-11-13 17:18:10 +11:00

34 lines
754 B
C++

#include "extent.hpp"
#include "tap.hpp"
#include "types.hpp"
int
main (void)
{
util::TAP::logger tap;
{
util::extent2u hi { 8, 4 };
util::extent2u lo { 6, 2 };
tap.expect_eq (lo, hi.contracted (2), "extent scalar contraction by value");
}
{
static const util::point2u EXPECTED[] = {
{ 0, 0 }, { 1, 0 }, { 2, 0 },
{ 0, 1 }, { 1, 1 }, { 2, 1 },
{ 0, 2 }, { 1, 2 }, { 2, 2 },
};
size_t offset = 0;
unsigned success = 0;
for (auto p: util::extent_range2u ({3, 3}))
success += EXPECTED[offset++] == p ? 1 : 0;
tap.expect_eq (success, elems (EXPECTED), "extent_range2u iteration");
}
return tap.status ();
}