From 1ca2f5423266f4c2cd451d9281c113fb881c9ebd Mon Sep 17 00:00:00 2001 From: Matt Dale <9760375+matthewdale@users.noreply.github.com> Date: Wed, 14 Jun 2023 11:47:13 -0700 Subject: [PATCH 1/3] DRIVERS-2651 Add decimal128 clamped zeros tests with very large exponents. --- source/bson-corpus/bson-corpus.rst | 2 ++ source/bson-corpus/tests/decimal128-1.json | 24 ++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/source/bson-corpus/bson-corpus.rst b/source/bson-corpus/bson-corpus.rst index 8205720cb9..68240b02a2 100644 --- a/source/bson-corpus/bson-corpus.rst +++ b/source/bson-corpus/bson-corpus.rst @@ -491,6 +491,8 @@ assertions. This makes for easier and safer test case development. Changelog ========= +:2023-06-14: Add decimal128 Extended JSON parse tests for clamped zeros with + very large exponents. :2022-10-05: Remove spec front matter and reformat changelog. :2021-09-09: Clarify error expectation rules for ``parseErrors``. :2021-09-02: Add spec and prose tests for prohibiting null bytes in diff --git a/source/bson-corpus/tests/decimal128-1.json b/source/bson-corpus/tests/decimal128-1.json index 7eefec6bf7..dc09934a25 100644 --- a/source/bson-corpus/tests/decimal128-1.json +++ b/source/bson-corpus/tests/decimal128-1.json @@ -312,6 +312,30 @@ "canonical_bson": "18000000136400000000000a5bc138938d44c64d31cc3700", "degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\"}}", "canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.000000000000000000000000000000000E+999\"}}" + }, + { + "description": "Clamped zeros with a large positive exponent", + "canonical_bson": "180000001364000000000000000000000000000000FE5F00", + "degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"0E+9999999999\"}}", + "canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"0E+6111\"}}" + }, + { + "description": "Clamped zeros with a large negative exponent", + "canonical_bson": "180000001364000000000000000000000000000000000000", + "degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"0E-9999999999\"}}", + "canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"0E-6176\"}}" + }, + { + "description": "Clamped negative zeros with a large positive exponent", + "canonical_bson": "180000001364000000000000000000000000000000FEDF00", + "degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0E+9999999999\"}}", + "canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0E+6111\"}}" + }, + { + "description": "Clamped negative zeros with a large negative exponent", + "canonical_bson": "180000001364000000000000000000000000000000008000", + "degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0E-9999999999\"}}", + "canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0E-6176\"}}" } ] } From 186bc07cb85d445c69abcf7bb4cd1224447ec6ee Mon Sep 17 00:00:00 2001 From: Matt Dale <9760375+matthewdale@users.noreply.github.com> Date: Thu, 15 Jun 2023 19:42:49 -0700 Subject: [PATCH 2/3] Use max/min int32 in zeros with large exponent tests. --- source/bson-corpus/tests/decimal128-1.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/bson-corpus/tests/decimal128-1.json b/source/bson-corpus/tests/decimal128-1.json index dc09934a25..fa20a997f1 100644 --- a/source/bson-corpus/tests/decimal128-1.json +++ b/source/bson-corpus/tests/decimal128-1.json @@ -316,25 +316,25 @@ { "description": "Clamped zeros with a large positive exponent", "canonical_bson": "180000001364000000000000000000000000000000FE5F00", - "degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"0E+9999999999\"}}", + "degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"0E+2147483647\"}}", "canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"0E+6111\"}}" }, { "description": "Clamped zeros with a large negative exponent", "canonical_bson": "180000001364000000000000000000000000000000000000", - "degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"0E-9999999999\"}}", + "degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"0E-2147483648\"}}", "canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"0E-6176\"}}" }, { "description": "Clamped negative zeros with a large positive exponent", "canonical_bson": "180000001364000000000000000000000000000000FEDF00", - "degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0E+9999999999\"}}", + "degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0E+2147483647\"}}", "canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0E+6111\"}}" }, { "description": "Clamped negative zeros with a large negative exponent", "canonical_bson": "180000001364000000000000000000000000000000008000", - "degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0E-9999999999\"}}", + "degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0E-2147483648\"}}", "canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0E-6176\"}}" } ] From 67a2a8da6919344b9eb289be28e0dc07eaf3aece Mon Sep 17 00:00:00 2001 From: Matt Dale <9760375+matthewdale@users.noreply.github.com> Date: Fri, 16 Jun 2023 09:03:10 -0700 Subject: [PATCH 3/3] Adjust the negative exponent by +1 in zeros with large exponent tests. --- source/bson-corpus/tests/decimal128-1.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/bson-corpus/tests/decimal128-1.json b/source/bson-corpus/tests/decimal128-1.json index fa20a997f1..8e7fbc93c6 100644 --- a/source/bson-corpus/tests/decimal128-1.json +++ b/source/bson-corpus/tests/decimal128-1.json @@ -322,7 +322,7 @@ { "description": "Clamped zeros with a large negative exponent", "canonical_bson": "180000001364000000000000000000000000000000000000", - "degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"0E-2147483648\"}}", + "degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"0E-2147483647\"}}", "canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"0E-6176\"}}" }, { @@ -334,7 +334,7 @@ { "description": "Clamped negative zeros with a large negative exponent", "canonical_bson": "180000001364000000000000000000000000000000008000", - "degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0E-2147483648\"}}", + "degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0E-2147483647\"}}", "canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0E-6176\"}}" } ]