ray: convert test to TAP format

This commit is contained in:
Danny Robson 2015-04-13 21:47:37 +10:00
parent 54f5f2d170
commit 7e2baf6751

View File

@ -5,48 +5,54 @@
#include "tap.hpp" #include "tap.hpp"
//-----------------------------------------------------------------------------
void void
test_intersect_plane (void) test_intersect_plane (util::TAP::logger &tap)
{ {
// trivial case: origin ray facing z, plane at unit z facing -z. // trivial case: origin ray facing z, plane at unit z facing -z.
util::ray3f l ({0,0,0}, {0,0, 1}); const util::ray3f l ({0,0,0}, {0,0, 1});
util::plane3f p ({0,0,1}, {0,0,-1}); const util::plane3f p ({0,0,1}, {0,0,-1});
CHECK_EQ (l.intersect (p), 1); tap.expect_eq (l.intersect (p), 1.f, "ray-plane intersect");
} }
//-----------------------------------------------------------------------------
void void
test_intersect_aabb (void) test_intersect_aabb (util::TAP::logger &tap)
{ {
// trivial case: unit aabb at origin, ray from (0.5,-0.5) upwards // trivial case: unit aabb at origin, ray from (0.5,-0.5) upwards
util::AABB2f b { const util::AABB2f b {
{ 0.f, 0.f }, { 0.f, 0.f },
{ 1.f, 1.f } { 1.f, 1.f }
}; };
util::ray2f l { const util::ray2f l {
{ 0.5f, -0.5f }, { 0.5f, -0.5f },
{ 0.f, 1.f } { 0.f, 1.f }
}; };
CHECK_EQ (l.intersect (b), 0.5f); tap.expect_eq (l.intersect (b), 0.5f, "ray-aabb intersect");
} }
//-----------------------------------------------------------------------------
void void
test_intersect_sphere (void) test_intersect_sphere (util::TAP::logger &tap)
{ {
; ;
} }
//-----------------------------------------------------------------------------
int int
main (void) main (void)
{ {
test_intersect_plane ();
test_intersect_aabb ();
util::TAP::logger tap; util::TAP::logger tap;
tap.todo ("convert to TAP");
test_intersect_plane (tap);
test_intersect_aabb (tap);
test_intersect_sphere (tap);
return tap.status ();
} }