[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;
- [lmi-commits] [lmi] master 17f6042e 01/11: Test nonstandard "'" printf flag, (continued)
- [lmi-commits] [lmi] master 17f6042e 01/11: Test nonstandard "'" printf flag, Greg Chicares, 2022/04/29
- [lmi-commits] [lmi] master 5e493f40 02/11: Rename ncnnnpnn, Greg Chicares, 2022/04/29
- [lmi-commits] [lmi] master a87f01b0 03/11: Rename a function, Greg Chicares, 2022/04/29
- [lmi-commits] [lmi] master 51c6865b 04/11: Use non-long double for duff_fmt(), Greg Chicares, 2022/04/29
- [lmi-commits] [lmi] master e8d7f191 05/11: Use low-level functions for low-level work, Greg Chicares, 2022/04/29
- [lmi-commits] [lmi] master 2202d220 09/11: Reimplement ledger_format() in terms of duff_fmt(), Greg Chicares, 2022/04/29
- [lmi-commits] [lmi] master d46e3440 07/11: Modernize duff_fmt(), Greg Chicares, 2022/04/29
- [lmi-commits] [lmi] master d838ad1f 06/11: Make number of decimals a duff_fmt() argument, Greg Chicares, 2022/04/29
- [lmi-commits] [lmi] master e8d4b982 08/11: Measure ledger_format() speed, Greg Chicares, 2022/04/29
- [lmi-commits] [lmi] master 92d90368 11/11: Designate release candidate 20220429T1437Z, Greg Chicares, 2022/04/29
- [lmi-commits] [lmi] master 542c0473 10/11: Augment unit test,
Greg Chicares <=