Skip to content

Commit 1cfffa5

Browse files
committed
Use exactly representable floating point numbers in tests
CDRIVER-1945 increased the precision when rendering floating point numbers in JavaScript. Using numbers that can be exactly represented in floating point will allow us to keep the expected output consistent with our input.
1 parent 31b8693 commit 1cfffa5

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

tests/bson/bson-decode-001.phpt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ $tests = array(
1010
array((object)array("hello" => "world")),
1111
array(null),
1212
array(123),
13-
14-
array(4.23),
13+
array(4.125),
1514
array(true),
1615
array(false),
1716
array("string"),
@@ -60,7 +59,7 @@ Test#2 { "0" : null }
6059
OK
6160
Test#3 { "0" : 123 }
6261
OK
63-
Test#4 { "0" : 4.23 }
62+
Test#4 { "0" : 4.125 }
6463
OK
6564
Test#5 { "0" : true }
6665
OK

tests/bson/bson-encode-001.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ $tests = array(
1515
array(array("0" => 1, "1" => 2, "2" => 3, "3" => 4, "4" => 5, "5" => 6, "6" => 7, "7" => 8, "8" => 9)),
1616
array(null),
1717
array(123),
18-
array(4.23),
18+
array(4.125),
1919
array(true),
2020
array(false),
2121
array("string"),
@@ -74,8 +74,8 @@ Test#7 { "0" : null }
7474
0 : 08 00 00 00 0a 30 00 00 [.....0..]
7575
Test#8 { "0" : 123 }
7676
0 : 0c 00 00 00 10 30 00 7b 00 00 00 00 [.....0.{....]
77-
Test#9 { "0" : 4.23 }
78-
0 : 10 00 00 00 01 30 00 ec 51 b8 1e 85 eb 10 40 00 [.....0..Q.....@.]
77+
Test#9 { "0" : 4.125 }
78+
0 : 10 00 00 00 01 30 00 00 00 00 00 00 80 10 40 00 [.....0........@.]
7979
Test#10 { "0" : true }
8080
0 : 09 00 00 00 08 30 00 01 00 [.....0...]
8181
Test#11 { "0" : false }

0 commit comments

Comments
 (0)