aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMark Pulford <mark@kyne.com.au>2012-01-19 21:38:48 +1030
committerMark Pulford <mark@kyne.com.au>2012-03-04 18:54:35 +1030
commitb67ebc41bbc60bd643784d89bd46f36180ea451b (patch)
tree4763991f384f7d253a9a94f09f3d66b2d9c963de /tests
parentbb296abe813f7ded82e74909fdb0f7e4f1f42416 (diff)
downloadlua-cjson-b67ebc41bbc60bd643784d89bd46f36180ea451b.tar.gz
lua-cjson-b67ebc41bbc60bd643784d89bd46f36180ea451b.tar.bz2
lua-cjson-b67ebc41bbc60bd643784d89bd46f36180ea451b.zip
Create separate tests for numbers w/leading zeros
Create separate tests for numbers with leading zeros. This allows the earlier "normal" number test to pass. Also update hexadecimal test to use the "p" exponent format.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/test.lua11
1 files changed, 8 insertions, 3 deletions
diff --git a/tests/test.lua b/tests/test.lua
index 1bf8d2b..e0f99f6 100755
--- a/tests/test.lua
+++ b/tests/test.lua
@@ -98,8 +98,8 @@ local cjson_tests = {
98 { "Decode string", 98 { "Decode string",
99 json.decode, { '"test string"' }, true, { "test string" } }, 99 json.decode, { '"test string"' }, true, { "test string" } },
100 { "Decode numbers", 100 { "Decode numbers",
101 json.decode, { '[ 0.0, -5e3, -1, 0.3e-3, 1023.2, 00123, 05.2, 0e10 ]' }, 101 json.decode, { '[ 0.0, -5e3, -1, 0.3e-3, 1023.2, 0e10 ]' },
102 true, { { 0.0, -5000, -1, 0.0003, 1023.2, 123, 5.2, 0 } } }, 102 true, { { 0.0, -5000, -1, 0.0003, 1023.2, 0 } } },
103 { "Decode null", 103 { "Decode null",
104 json.decode, { 'null' }, true, { json.null } }, 104 json.decode, { 'null' }, true, { json.null } },
105 { "Decode true", 105 { "Decode true",
@@ -219,7 +219,9 @@ local cjson_tests = {
219 { "Set decode_invalid_numbers(true)", 219 { "Set decode_invalid_numbers(true)",
220 json.decode_invalid_numbers, { true }, true, { true } }, 220 json.decode_invalid_numbers, { true }, true, { true } },
221 { "Decode hexadecimal", 221 { "Decode hexadecimal",
222 json.decode, { '0x6' }, true, { 6 } }, 222 json.decode, { '0x6.ffp1' }, true, { 13.9921875 } },
223 { "Decode numbers with leading zero",
224 json.decode, { '[ 0123, 00.33 ]' }, true, { { 123, 0.33 } } },
223 { "Decode +-Inf", 225 { "Decode +-Inf",
224 json.decode, { '[ +Inf, Inf, -Inf ]' }, true, { { Inf, Inf, -Inf } } }, 226 json.decode, { '[ +Inf, Inf, -Inf ]' }, true, { { Inf, Inf, -Inf } } },
225 { "Decode +-Infinity", 227 { "Decode +-Infinity",
@@ -238,6 +240,9 @@ local cjson_tests = {
238 { "Decode hexadecimal [throw error]", 240 { "Decode hexadecimal [throw error]",
239 json.decode, { '0x6' }, 241 json.decode, { '0x6' },
240 false, { "Expected value but found invalid number at character 1" } }, 242 false, { "Expected value but found invalid number at character 1" } },
243 { "Decode numbers with leading zero [throw error]",
244 json.decode, { '[ 0123, 00.33 ]' },
245 false, { "Expected value but found invalid number at character 3" } },
241 { "Decode +-Inf [throw error]", 246 { "Decode +-Inf [throw error]",
242 json.decode, { '[ +Inf, Inf, -Inf ]' }, 247 json.decode, { '[ +Inf, Inf, -Inf ]' },
243 false, { "Expected value but found invalid token at character 3" } }, 248 false, { "Expected value but found invalid token at character 3" } },