lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master eb921be 3/6: Fix peccable unit tests


From: Greg Chicares
Subject: [lmi-commits] [lmi] master eb921be 3/6: Fix peccable unit tests
Date: Sun, 30 Apr 2017 11:49:36 -0400 (EDT)

branch: master
commit eb921be44e5249932d135cd47059ea58b4bf1e33
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Fix peccable unit tests
    
    This original distich
        // This test would fail for type bool.
        INVOKE_BOOST_TEST( is_strictly_between_extrema(   1), file, line);
    was confusing: its test succeeds whatever the containing function
    template's type T, even if T is bool (or std::string). The revised test
        is_strictly_between_extrema<T>(1)
    does fail for type bool: 'true' is not within the open interval (0,1)
    because it equals one of the extrema.
    
    Fixed several other tests that ought to have depended on type T but
    formerly did not.
---
 tn_range_test.cpp | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tn_range_test.cpp b/tn_range_test.cpp
index af4c04b..5ab39ab 100644
--- a/tn_range_test.cpp
+++ b/tn_range_test.cpp
@@ -136,7 +136,7 @@ void tn_range_test::test_auxiliary_functions(char const* 
file, int line)
     T const maxT = std::numeric_limits<T>::max();
     INVOKE_BOOST_TEST(!is_strictly_between_extrema(maxT), file, line);
     // This test would fail for type bool.
-    INVOKE_BOOST_TEST( is_strictly_between_extrema(   1), file, line);
+    INVOKE_BOOST_TEST( is_strictly_between_extrema<T>(1), file, line);
 
     INVOKE_BOOST_TEST_EQUAL(-1, signum(T(-1)), file, line);
     INVOKE_BOOST_TEST_EQUAL( 0, signum(T( 0)), file, line);
@@ -145,17 +145,17 @@ void tn_range_test::test_auxiliary_functions(char const* 
file, int line)
     INVOKE_BOOST_TEST_EQUAL(-1, signum(-maxT), file, line);
     INVOKE_BOOST_TEST_EQUAL( 1, signum( maxT), file, line);
 
-    INVOKE_BOOST_TEST_EQUAL(true , is_exact_integer(-1), file, line);
-    INVOKE_BOOST_TEST_EQUAL(true , is_exact_integer( 0), file, line);
-    INVOKE_BOOST_TEST_EQUAL(true , is_exact_integer( 1), file, line);
+    INVOKE_BOOST_TEST_EQUAL(true , is_exact_integer(T(-1)), file, line);
+    INVOKE_BOOST_TEST_EQUAL(true , is_exact_integer(T( 0)), file, line);
+    INVOKE_BOOST_TEST_EQUAL(true , is_exact_integer(T( 1)), file, line);
 
     // Integer types truncate the argument, always resulting in an
     // exact integer.
     bool volatile exact = std::numeric_limits<T>::is_exact;
     if(!exact)
         {
-        INVOKE_BOOST_TEST_EQUAL(false, is_exact_integer( 0.5), file, line);
-        INVOKE_BOOST_TEST_EQUAL(false, is_exact_integer(1.07), file, line);
+        INVOKE_BOOST_TEST_EQUAL(false, is_exact_integer(T( 0.5)), file, line);
+        INVOKE_BOOST_TEST_EQUAL(false, is_exact_integer(T(1.07)), file, line);
         }
 
     bool volatile is_iec559 = std::numeric_limits<T>::is_iec559;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]