lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 542c0473 10/11: Augment unit test


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 542c0473 10/11: Augment unit test
Date: Fri, 29 Apr 2022 11:59:34 -0400 (EDT)

branch: master
commit 542c0473f7e0b205ed4378210980ae4d81485944
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Augment unit test
    
    And the gristles of his youth
    Hardened in his comely pow,
    And he came to fighting growth,
    Beat his bull and won his cow,
    And flew his tail and trampled off
    Past the tallest, vain enough,
    And curved about in splendour full
    And curved again and snuffed the airs
    As who should say Come out who dares !
    And all beheld a bull, a Bull,
    And knew that here was surely one
    That backed for no bull, fearing none.
      --Hodgson
---
 duff_fmt_test.cpp | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/duff_fmt_test.cpp b/duff_fmt_test.cpp
index f53dd379..cae0e024 100644
--- a/duff_fmt_test.cpp
+++ b/duff_fmt_test.cpp
@@ -198,6 +198,36 @@ int test_main(int, char*[])
         ||              "2,000.00" == duff_fmt(      1999.995     , 2)
         );
 
+    // Small and large values.
+
+    LMI_TEST_EQUAL(                "0.00", duff_fmt( 0.0000000000001  , 2));
+    LMI_TEST_EQUAL("-888,888,877,777,777", duff_fmt(-888888877777777.0, 0));
+
+    LMI_TEST_EQUAL("0.000000000000000001", duff_fmt( 0.000000000000000001, 
18));
+
+    double x0 = 0x1.fffffffffffffp+1023;
+    double x1 = 0x1p-1022;
+    double x2 = 0x1p-1074;
+    std::string f0 = "179,769,313,486,231,";
+    std::string f1 =
+        "0.0000000000000000000000000000000000000000000000000000000000"
+        "000000000000000000000000000000000000000000000000000000000000"
+        "000000000000000000000000000000000000000000000000000000000000"
+        "000000000000000000000000000000000000000000000000000000000000"
+        "000000000000000000000000000000000000000000000000000000000000"
+        "000000000222507385850720";
+    std::string f2 =
+        "0.0000000000000000000000000000000000000000000000000000000000"
+        "000000000000000000000000000000000000000000000000000000000000"
+        "000000000000000000000000000000000000000000000000000000000000"
+        "000000000000000000000000000000000000000000000000000000000000"
+        "000000000000000000000000000000000000000000000000000000000000"
+        "0000000000000000000000000494065645841246";
+    LMI_TEST(begins_with(duff_fmt(x0, 0  ), f0));
+    LMI_TEST(begins_with(duff_fmt(x0, 400), f0));
+    LMI_TEST(begins_with(duff_fmt(x1, 400), f1));
+    LMI_TEST(begins_with(duff_fmt(x2, 400), f2));
+
     // Infinities and NaNs.
 
     double volatile d = 0.0;



reply via email to

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