From 3b3f9cd3d3a29eb88775408b8a44d06ff003e15f Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Mon, 26 Feb 2018 13:37:08 +1100 Subject: [PATCH] coord/ops: use the coord type for literal equality comparisons --- coord/ops.hpp | 2 +- test/coord.cpp | 2 +- test/float.cpp | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/coord/ops.hpp b/coord/ops.hpp index 6bd81393..7f39a8a0 100644 --- a/coord/ops.hpp +++ b/coord/ops.hpp @@ -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}); } diff --git a/test/coord.cpp b/test/coord.cpp index 5aaeb2fb..ed15e54c 100644 --- a/test/coord.cpp +++ b/test/coord.cpp @@ -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"); diff --git a/test/float.cpp b/test/float.cpp index 2be6c906..65de4ffb 100644 --- a/test/float.cpp +++ b/test/float.cpp @@ -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 (); }