Skip to content

Commit 95936a1

Browse files
committed
Improve Vincenthz libjson's ParseDouble test
vincenthz/libjson#24
1 parent 274281a commit 95936a1

File tree

4 files changed

+21
-20
lines changed

4 files changed

+21
-20
lines changed

sample/conformance.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5743,7 +5743,7 @@ <h2>Source CSV</h2>
57435743
2. Parse Double,Vinenthz/libjson (C),double25,true
57445744
2. Parse Double,Vinenthz/libjson (C),double26,true
57455745
2. Parse Double,Vinenthz/libjson (C),double27,false
5746-
2. Parse Double,Vinenthz/libjson (C),double28,false
5746+
2. Parse Double,Vinenthz/libjson (C),double28,true
57475747
2. Parse Double,Vinenthz/libjson (C),double29,true
57485748
2. Parse Double,Vinenthz/libjson (C),double30,true
57495749
2. Parse Double,Vinenthz/libjson (C),double31,true

sample/conformance_Vinenthz_libjson (C).md

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,42 +9,38 @@ Summary: 34 of 34 are correct.
99

1010
* `[18446744073709551616]`
1111
* expect: `1.8446744073709552e+19 (0x01643F0000000000000)`
12-
* actual: `0 (0x0160)`
13-
14-
* `[-9223372036854775809]`
15-
* expect: `-9.2233720368547758e+18 (0x016C3E0000000000000)`
16-
* actual: `0 (0x0160)`
12+
* actual: `9.2233720368547758e+18 (0x01643E0000000000000)`
1713

1814
* `[10141204801825834086073718800384]`
1915
* expect: `1.0141204801825834e+31 (0x016465FFFFFFFFFFFFF)`
20-
* actual: `0 (0x0160)`
16+
* actual: `9.2233720368547758e+18 (0x01643E0000000000000)`
2117

2218
* `[10141204801825835211973625643008]`
2319
* expect: `1.0141204801825835e+31 (0x0164660000000000000)`
24-
* actual: `0 (0x0160)`
20+
* actual: `9.2233720368547758e+18 (0x01643E0000000000000)`
2521

2622
* `[10141204801825834649023672221696]`
2723
* expect: `1.0141204801825835e+31 (0x0164660000000000000)`
28-
* actual: `0 (0x0160)`
24+
* actual: `9.2233720368547758e+18 (0x01643E0000000000000)`
2925

3026
* `[5708990770823838890407843763683279797179383808]`
3127
* expect: `5.7089907708238389e+45 (0x016496FFFFFFFFFFFFF)`
32-
* actual: `0 (0x0160)`
28+
* actual: `9.2233720368547758e+18 (0x01643E0000000000000)`
3329

3430
* `[5708990770823839524233143877797980545530986496]`
3531
* expect: `5.7089907708238395e+45 (0x0164970000000000000)`
36-
* actual: `0 (0x0160)`
32+
* actual: `9.2233720368547758e+18 (0x01643E0000000000000)`
3733

3834
* `[5708990770823839207320493820740630171355185152]`
3935
* expect: `5.7089907708238395e+45 (0x0164970000000000000)`
40-
* actual: `0 (0x0160)`
36+
* actual: `9.2233720368547758e+18 (0x01643E0000000000000)`
4137

4238
* `[100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]`
4339
* expect: `1e+308 (0x0167FE1CCF385EBC8A0)`
44-
* actual: `0 (0x0160)`
40+
* actual: `9.2233720368547758e+18 (0x01643E0000000000000)`
4541

4642

47-
Summary: 57 of 66 are correct.
43+
Summary: 58 of 66 are correct.
4844

4945
## 3. Parse String
5046

src/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,7 +1200,7 @@ static void BenchAllConformance() {
12001200
#endif // TEST_CONFORMANCE
12011201

12021202
static void BenchAll(const TestJsonList& testJsons) {
1203-
BenchAllPerformance(testJsons);
1203+
// BenchAllPerformance(testJsons);
12041204

12051205
#if TEST_CONFORMANCE
12061206
BenchAllConformance();
@@ -1229,7 +1229,7 @@ int main(int, char* argv[]) {
12291229
TestList& tests = TestManager::Instance().GetTests();
12301230
std::sort(tests.begin(), tests.end());
12311231

1232-
VerifyAll(testJsons);
1232+
// VerifyAll(testJsons);
12331233
BenchAll(testJsons);
12341234

12351235
FreeFiles(testJsons);

src/tests/vincenthzlibjsontest.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -506,11 +506,16 @@ class VinenthzTest : public TestBase {
506506
bool ret = false;
507507
if (pr &&
508508
pr->root->type == JSON_ARRAY_BEGIN &&
509-
pr->root->length == 1 &&
510-
pr->root->u.array[0]->type == JSON_FLOAT)
509+
pr->root->length == 1)
511510
{
512-
*d = pr->root->u.array[0]->u.float_val;
513-
ret = true;
511+
if (pr->root->u.array[0]->type == JSON_FLOAT) {
512+
*d = pr->root->u.array[0]->u.float_val;
513+
ret = true;
514+
}
515+
else if (pr->root->u.array[0]->type == JSON_INT) {
516+
*d = (double)pr->root->u.array[0]->u.int_val;
517+
ret = true;
518+
}
514519
}
515520
delete pr;
516521
return ret;

0 commit comments

Comments
 (0)