From 741abdf562e00bb093d1c5cb0a831276fea54159 Mon Sep 17 00:00:00 2001 From: Andrew Paseltiner Date: Tue, 4 Feb 2025 15:16:35 -0500 Subject: [PATCH] Add tests covering canonicalization of insignificant decimal digits Per Step 9 of https://httpwg.org/specs/rfc9651.html#ser-decimal only the significant digits of the decimal's fractional component should be included in the serialized form. --- number.json | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/number.json b/number.json index 1b43994..9a0bb5a 100644 --- a/number.json +++ b/number.json @@ -182,5 +182,26 @@ "raw": ["-1234567890123.0"], "header_type": "item", "must_fail": true + }, + { + "name": "decimal with 1 significant digit and 1 insignificant digit", + "raw": ["1.20"], + "header_type": "item", + "expected": [1.2, []], + "canonical": ["1.2"] + }, + { + "name": "decimal with 1 significant digit and 2 insignificant digits", + "raw": ["1.200"], + "header_type": "item", + "expected": [1.2, []], + "canonical": ["1.2"] + }, + { + "name": "decimal with 2 significant digits and 1 insignificant digit", + "raw": ["1.230"], + "header_type": "item", + "expected": [1.23, []], + "canonical": ["1.23"] } ]