Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
dtoatest.cpp File Reference
#include "unittest.h"
#include "rapidjson/internal/dtoa.h"
Include dependency graph for dtoatest.cpp:

Go to the source code of this file.

Macros

#define TEST_DTOA(d, a)
 
#define TEST_DTOA(m, d, a)
 

Functions

 TEST (dtoa, normal)
 
 TEST (dtoa, maxDecimalPlaces)
 

Macro Definition Documentation

◆ TEST_DTOA [1/2]

#define TEST_DTOA ( d,
a )
Value:
*dtoa(d, buffer) = '\0';\
EXPECT_STREQ(a, buffer)
#define dtoa
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1181

◆ TEST_DTOA [2/2]

#define TEST_DTOA ( m,
d,
a )
Value:
*dtoa(d, buffer, m) = '\0';\
EXPECT_STREQ(a, buffer)

Function Documentation

◆ TEST() [1/2]

TEST ( dtoa ,
maxDecimalPlaces  )

Definition at line 53 of file dtoatest.cpp.

53 {
54 char buffer[30];
55
56#define TEST_DTOA(m, d, a)\
57 *dtoa(d, buffer, m) = '\0';\
58 EXPECT_STREQ(a, buffer)
59
60 TEST_DTOA(3, 0.0, "0.0");
61 TEST_DTOA(1, 0.0, "0.0");
62 TEST_DTOA(3, -0.0, "-0.0");
63 TEST_DTOA(3, 1.0, "1.0");
64 TEST_DTOA(3, -1.0, "-1.0");
65 TEST_DTOA(3, 1.2345, "1.234");
66 TEST_DTOA(2, 1.2345, "1.23");
67 TEST_DTOA(1, 1.2345, "1.2");
68 TEST_DTOA(3, 1.2345678, "1.234");
69 TEST_DTOA(3, 1.0001, "1.0");
70 TEST_DTOA(2, 1.0001, "1.0");
71 TEST_DTOA(1, 1.0001, "1.0");
72 TEST_DTOA(3, 0.123456789012, "0.123");
73 TEST_DTOA(2, 0.123456789012, "0.12");
74 TEST_DTOA(1, 0.123456789012, "0.1");
75 TEST_DTOA(4, 0.0001, "0.0001");
76 TEST_DTOA(3, 0.0001, "0.0");
77 TEST_DTOA(2, 0.0001, "0.0");
78 TEST_DTOA(1, 0.0001, "0.0");
79 TEST_DTOA(3, 1234567.8, "1234567.8");
80 TEST_DTOA(3, 1e30, "1e30");
81 TEST_DTOA(3, 5e-324, "0.0"); // Min subnormal positive double
82 TEST_DTOA(3, 2.225073858507201e-308, "0.0"); // Max subnormal positive double
83 TEST_DTOA(3, 2.2250738585072014e-308, "0.0"); // Min normal positive double
84 TEST_DTOA(3, 1.7976931348623157e308, "1.7976931348623157e308"); // Max double
85 TEST_DTOA(5, -0.14000000000000001, "-0.14");
86 TEST_DTOA(4, -0.14000000000000001, "-0.14");
87 TEST_DTOA(3, -0.14000000000000001, "-0.14");
88 TEST_DTOA(3, -0.10000000000000001, "-0.1");
89 TEST_DTOA(2, -0.10000000000000001, "-0.1");
90 TEST_DTOA(1, -0.10000000000000001, "-0.1");
91
92#undef TEST_DTOA
93}
#define TEST_DTOA(d, a)

◆ TEST() [2/2]

TEST ( dtoa ,
normal  )

Definition at line 25 of file dtoatest.cpp.

25 {
26 char buffer[30];
27
28#define TEST_DTOA(d, a)\
29 *dtoa(d, buffer) = '\0';\
30 EXPECT_STREQ(a, buffer)
31
32 TEST_DTOA(0.0, "0.0");
33 TEST_DTOA(-0.0, "-0.0");
34 TEST_DTOA(1.0, "1.0");
35 TEST_DTOA(-1.0, "-1.0");
36 TEST_DTOA(1.2345, "1.2345");
37 TEST_DTOA(1.2345678, "1.2345678");
38 TEST_DTOA(0.123456789012, "0.123456789012");
39 TEST_DTOA(1234567.8, "1234567.8");
40 TEST_DTOA(-79.39773355813419, "-79.39773355813419");
41 TEST_DTOA(0.000001, "0.000001");
42 TEST_DTOA(0.0000001, "1e-7");
43 TEST_DTOA(1e30, "1e30");
44 TEST_DTOA(1.234567890123456e30, "1.234567890123456e30");
45 TEST_DTOA(5e-324, "5e-324"); // Min subnormal positive double
46 TEST_DTOA(2.225073858507201e-308, "2.225073858507201e-308"); // Max subnormal positive double
47 TEST_DTOA(2.2250738585072014e-308, "2.2250738585072014e-308"); // Min normal positive double
48 TEST_DTOA(1.7976931348623157e308, "1.7976931348623157e308"); // Max double
49
50#undef TEST_DTOA
51}