diff options
Diffstat (limited to '')
| -rwxr-xr-x | tests/test.lua | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/test.lua b/tests/test.lua index 7a75243..d80dcf0 100755 --- a/tests/test.lua +++ b/tests/test.lua | |||
| @@ -210,6 +210,21 @@ local escape_tests = { | |||
| 210 | { json.decode, { utf16_escaped }, true, { utf8_raw } } | 210 | { json.decode, { utf16_escaped }, true, { utf8_raw } } |
| 211 | } | 211 | } |
| 212 | 212 | ||
| 213 | -- The standard Lua interpreter is ANSI C online doesn't support locales | ||
| 214 | -- by default. Force a known problematic locale to test strtod()/sprintf(). | ||
| 215 | local locale_tests = { | ||
| 216 | function () | ||
| 217 | os.setlocale("cs_CZ") | ||
| 218 | return "Setting locale to cs_CZ (comma separator)" | ||
| 219 | end, | ||
| 220 | { json.encode, { 1.5 }, true, { '1.5' } }, | ||
| 221 | { json.decode, { "[ 10, \"test\" ]" }, true, { { 10, "test" } } }, | ||
| 222 | function () | ||
| 223 | os.setlocale("C") | ||
| 224 | return "Reverting locale to POSIX" | ||
| 225 | end | ||
| 226 | } | ||
| 227 | |||
| 213 | print(string.format("Testing CJSON v%s\n", cjson.version)) | 228 | print(string.format("Testing CJSON v%s\n", cjson.version)) |
| 214 | 229 | ||
| 215 | run_test_group("decode simple value", decode_simple_tests) | 230 | run_test_group("decode simple value", decode_simple_tests) |
| @@ -225,6 +240,7 @@ run_test_group("encode table", encode_table_tests) | |||
| 225 | run_test_group("decode error", decode_error_tests) | 240 | run_test_group("decode error", decode_error_tests) |
| 226 | run_test_group("encode error", encode_error_tests) | 241 | run_test_group("encode error", encode_error_tests) |
| 227 | run_test_group("escape", escape_tests) | 242 | run_test_group("escape", escape_tests) |
| 243 | run_test_group("locale", locale_tests) | ||
| 228 | 244 | ||
| 229 | cjson.refuse_invalid_numbers(false) | 245 | cjson.refuse_invalid_numbers(false) |
| 230 | cjson.encode_max_depth(20) | 246 | cjson.encode_max_depth(20) |
