libcruft-util/test/point.cpp

41 lines
916 B
C++
Raw Normal View History

2014-02-18 15:28:28 +11:00
#include "point.hpp"
#include "debug.hpp"
#include "types.hpp"
using namespace util;
int
main (int, char**) {
2015-01-13 18:40:45 +11:00
// Redim to lower dimension
{
const point3f p(0.f, 1.f, 2.f);
const point2f q = p.redim<2> ();
2014-02-18 15:28:28 +11:00
2015-01-13 18:40:45 +11:00
CHECK_EQ (q.data[0], p.data[0]);
CHECK_EQ (q.data[1], p.data[1]);
}
// Redim to higher dimension without fill
{
const point2f p(0.f, 1.f);
const point3f q = p.redim<3> ();
CHECK_EQ (p.data[0], q.data[0]);
CHECK_EQ (p.data[1], q.data[1]);
}
// Redim to higher dimension with fill
{
static const point4f FILL (1.f, 2.f, 3.f, 4.f);
const point2f p (0.1f, 1.f);
2015-01-13 18:40:45 +11:00
const point4f q = p.template redim<4> (FILL);
CHECK_EQ (q.data[0], p.data[0]);
CHECK_EQ (q.data[1], p.data[1]);
CHECK_EQ (q.data[2], FILL.data[2]);
CHECK_EQ (q.data[3], FILL.data[3]);
}
2014-02-18 15:28:28 +11:00
}