28 lines
665 B
C++
28 lines
665 B
C++
|
#include "tap.hpp"
|
||
|
|
||
|
#include "geom/line.hpp"
|
||
|
|
||
|
int
|
||
|
main (int, char**)
|
||
|
{
|
||
|
util::TAP::logger tap;
|
||
|
|
||
|
static struct {
|
||
|
util::point3f origin;
|
||
|
util::vector3f direction;
|
||
|
util::point3f q;
|
||
|
float distance;
|
||
|
const char *message;
|
||
|
} TESTS[] = {
|
||
|
{ { 0, 0, 0 }, { 1, 0, 0}, { 0, 0, 0 }, 0, "origin line, origin point" } ,
|
||
|
{ { 0, 1, 0 }, { 1, 0, 0}, { 0, 0, 0 }, 1, "+x line, unit distance" },
|
||
|
};
|
||
|
|
||
|
for (auto const& t: TESTS) {
|
||
|
util::geom::line3f l { t.origin, t.direction };
|
||
|
auto d = distance2 (l, t.q);
|
||
|
tap.expect_eq (d, t.distance, "%!", t.message);
|
||
|
}
|
||
|
|
||
|
return tap.status ();
|
||
|
}
|