lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 50b6290 2/8: Add a failing unit test


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 50b6290 2/8: Add a failing unit test
Date: Sat, 17 Mar 2018 19:12:56 -0400 (EDT)

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

    Add a failing unit test
    
    This tricky statement:
        double widest = std::max
            (min_value * -10
            ,max_value
            );
    doesn't do the right thing for
        1'999'999'999.0 min_value
         -999'999'999.0 max_value
    because it violates the assumption that min_value <= max_value. That
    precondition must hold, because std::minmax_element() produces those
    values; but it should be asserted, because their connection to that
    standard-library function is indirect.
    
    Of course, no assertion can make the statement less tricky.
---
 miscellany_test.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/miscellany_test.cpp b/miscellany_test.cpp
index b8ecebd..91f10b1 100644
--- a/miscellany_test.cpp
+++ b/miscellany_test.cpp
@@ -299,6 +299,9 @@ void test_scale_power()
     BOOST_TEST_EQUAL( 0, scale_power( 9,               0.0,     
999'999'999.0));
     BOOST_TEST_EQUAL( 0, scale_power( 9,     -99'999'999.0,               
0.0));
     BOOST_TEST_EQUAL( 0, scale_power( 9,     999'999'999.0,     
999'999'999.0));
+
+    BOOST_TEST_EQUAL( 3, scale_power( 9,    -999'999'999.0,   
1'999'999'999.0));
+    BOOST_TEST_EQUAL( 3, scale_power( 9,   1'999'999'999.0,    
-999'999'999.0));
 }
 
 void test_trimming()



reply via email to

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