libcruft-util/test/extent.cpp

34 lines
758 B
C++
Raw Normal View History

#include "extent.hpp"
2015-04-13 16:45:56 +10:00
#include "tap.hpp"
#include "types.hpp"
int
main (void)
{
2015-04-13 16:45:56 +10:00
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, std::size (EXPECTED), "extent_range2u iteration");
}
return tap.status ();
}