lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 2faa024 5/6: Test auxiliary functions with an


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 2faa024 5/6: Test auxiliary functions with an unsigned type too
Date: Sun, 30 Apr 2017 11:49:37 -0400 (EDT)

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

    Test auxiliary functions with an unsigned type too
    
    Conditionalized initializations involving negative values.
---
 tn_range_test.cpp | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/tn_range_test.cpp b/tn_range_test.cpp
index c4e85ea..0d099ec 100644
--- a/tn_range_test.cpp
+++ b/tn_range_test.cpp
@@ -134,21 +134,27 @@ template<typename T>
 void tn_range_test::test_auxiliary_functions(char const* file, int line)
 {
     T const maxT = std::numeric_limits<T>::max();
+    T const minT = std::numeric_limits<T>::lowest();
+
     INVOKE_BOOST_TEST(!is_strictly_between_extrema(maxT), file, line);
     // This test would fail for type bool.
     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);
     INVOKE_BOOST_TEST_EQUAL( 1, signum(T( 1)), file, line);
 
-    INVOKE_BOOST_TEST_EQUAL(-1, signum(-maxT), file, 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(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);
 
+    if(minT < 0)
+        {
+        INVOKE_BOOST_TEST_EQUAL(-1, signum(T(-1)), file, line);
+        INVOKE_BOOST_TEST_EQUAL(-1, signum(minT), 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;
@@ -285,11 +291,12 @@ void tn_range_test::test_percentages(char const* file, 
int line)
 
 void tn_range_test::test()
 {
-    test_auxiliary_functions<signed char>(__FILE__, __LINE__);
-    test_auxiliary_functions<int        >(__FILE__, __LINE__);
-    test_auxiliary_functions<float      >(__FILE__, __LINE__);
-    test_auxiliary_functions<double     >(__FILE__, __LINE__);
-    test_auxiliary_functions<long double>(__FILE__, __LINE__);
+    test_auxiliary_functions<signed char  >(__FILE__, __LINE__);
+    test_auxiliary_functions<unsigned char>(__FILE__, __LINE__);
+    test_auxiliary_functions<int          >(__FILE__, __LINE__);
+    test_auxiliary_functions<float        >(__FILE__, __LINE__);
+    test_auxiliary_functions<double       >(__FILE__, __LINE__);
+    test_auxiliary_functions<long double  >(__FILE__, __LINE__);
 
     test_floating_auxiliary_functions<float      >(__FILE__, __LINE__);
     test_floating_auxiliary_functions<double     >(__FILE__, __LINE__);



reply via email to

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