lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 99c2c5e 7/8: Augment unit test and documentat


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 99c2c5e 7/8: Augment unit test and documentation
Date: Sat, 17 Mar 2018 19:12:57 -0400 (EDT)

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

    Augment unit test and documentation
---
 miscellany.cpp      | 14 ++++++++++++++
 miscellany_test.cpp |  9 ++++++++-
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/miscellany.cpp b/miscellany.cpp
index 6d6576c..5d886d4 100644
--- a/miscellany.cpp
+++ b/miscellany.cpp
@@ -99,6 +99,20 @@ bool files_are_identical(std::string const& file0, 
std::string const& file1)
 /// of concerns, and knowing them would not enable any significant
 /// refinement.
 ///
+/// Commas are disregarded as being incidental--in effect, treated as
+/// having zero width--but the minus sign is treated as having the
+/// same width as any digit. For PDF illustrations, "tabular figures"
+/// (monospace digits) and thousands separators are used, but commas
+/// and minus signs are narrow, so this is conservative: values of
+///   1,000,000,000
+///    -100,000,000
+/// are not equally wide. For flat-text output, however, values of
+///   1000000000
+///   -100000000
+/// have the same formatted width, with an all-monospace font and no
+/// thousands separators. In practice, this rarely matters, because
+/// typical negative values on illustrations are relatively small.
+///
 /// Asserted preconditions:
 ///   3 <= max_power
 ///   min_value <= max_value
diff --git a/miscellany_test.cpp b/miscellany_test.cpp
index bd2148c..5790463 100644
--- a/miscellany_test.cpp
+++ b/miscellany_test.cpp
@@ -314,7 +314,14 @@ void test_scale_power()
 
     // 999,999,999.0 rounds to 999,999,999
     BOOST_TEST_EQUAL( 0, scale_power( 9,     -99'999'999.0,     
999'999'999.0));
-    // 999,999.999.9 may round to 1,000,000,000
+
+    // 999,999.999.9 may round to 1,000,000,000; and
+    // -99,999,999.9 may round to  -100,000,000
+    //   which is equally wide if widths are reckoned as [,]:0 and [-0-9]:1
+    //   (as for a monospace font with comma-less formatting).
+    // Test with such a maximal value on LHS, RHS, and both sides.
+    BOOST_TEST_EQUAL( 3, scale_power( 9,     -99'999'999.9,         
999'999.9));
+    BOOST_TEST_EQUAL( 3, scale_power( 9,        -999'999.9,     
999'999'999.9));
     BOOST_TEST_EQUAL( 3, scale_power( 9,     -99'999'999.9,     
999'999'999.9));
 
     BOOST_TEST_EQUAL( 3, scale_power( 9,    -999'999'999.0,   
1'999'999'999.0));



reply via email to

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