coord/ops: use the coord type for literal equality comparisons

This commit is contained in:
Danny Robson 2018-02-26 13:37:08 +11:00
parent 79d19b4f4f
commit 3b3f9cd3d3
3 changed files with 5 additions and 2 deletions

View File

@ -738,7 +738,7 @@ namespace util {
bool
is_normalised (const K &k)
{
return almost_equal (norm2 (k), 1);
return almost_equal (norm2 (k), typename K::value_type{1});
}

View File

@ -27,7 +27,7 @@ main (void)
tap.expect_eq ( p, p, "unary point addition");
auto vec = util::vector4f (0.5f);
tap.expect_eq (vec, util::normalised (vec), "normalisation of normalised vector");
tap.expect (util::almost_equal (vec, util::normalised (vec)), "normalisation of normalised vector");
tap.expect_eq (sum (util::vector4f::ones ()), 4.f, "elementwise summation");

View File

@ -89,5 +89,8 @@ main (int, char **) {
test_single (tap);
test_double (tap);
tap.expect (util::almost_equal (1.f, 1), "trivial float/int almost-equality");
tap.expect (util::almost_equal (1, 1.f), "trivial int/float almost-equality");
return tap.status ();
}