Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpx/lua-cjson.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMark Pulford <mark@kyne.com.au>2012-01-19 15:08:48 +0400
committerMark Pulford <mark@kyne.com.au>2012-03-04 12:24:35 +0400
commitb67ebc41bbc60bd643784d89bd46f36180ea451b (patch)
tree4763991f384f7d253a9a94f09f3d66b2d9c963de /tests
parentbb296abe813f7ded82e74909fdb0f7e4f1f42416 (diff)
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 = {
{ "Decode string",
json.decode, { '"test string"' }, true, { "test string" } },
{ "Decode numbers",
- json.decode, { '[ 0.0, -5e3, -1, 0.3e-3, 1023.2, 00123, 05.2, 0e10 ]' },
- true, { { 0.0, -5000, -1, 0.0003, 1023.2, 123, 5.2, 0 } } },
+ json.decode, { '[ 0.0, -5e3, -1, 0.3e-3, 1023.2, 0e10 ]' },
+ true, { { 0.0, -5000, -1, 0.0003, 1023.2, 0 } } },
{ "Decode null",
json.decode, { 'null' }, true, { json.null } },
{ "Decode true",
@@ -219,7 +219,9 @@ local cjson_tests = {
{ "Set decode_invalid_numbers(true)",
json.decode_invalid_numbers, { true }, true, { true } },
{ "Decode hexadecimal",
- json.decode, { '0x6' }, true, { 6 } },
+ json.decode, { '0x6.ffp1' }, true, { 13.9921875 } },
+ { "Decode numbers with leading zero",
+ json.decode, { '[ 0123, 00.33 ]' }, true, { { 123, 0.33 } } },
{ "Decode +-Inf",
json.decode, { '[ +Inf, Inf, -Inf ]' }, true, { { Inf, Inf, -Inf } } },
{ "Decode +-Infinity",
@@ -238,6 +240,9 @@ local cjson_tests = {
{ "Decode hexadecimal [throw error]",
json.decode, { '0x6' },
false, { "Expected value but found invalid number at character 1" } },
+ { "Decode numbers with leading zero [throw error]",
+ json.decode, { '[ 0123, 00.33 ]' },
+ false, { "Expected value but found invalid number at character 3" } },
{ "Decode +-Inf [throw error]",
json.decode, { '[ +Inf, Inf, -Inf ]' },
false, { "Expected value but found invalid token at character 3" } },