From b154403b74a273716d619679847c83002aad92da Mon Sep 17 00:00:00 2001 From: Thomas Harning Jr Date: Tue, 13 Jan 2009 21:49:44 -0500 Subject: [PATCH] tests: adds \u and \x escape encoding/decoding test cases --- tests/lunit-strings.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/lunit-strings.lua b/tests/lunit-strings.lua index 14e3113..bc8da37 100644 --- a/tests/lunit-strings.lua +++ b/tests/lunit-strings.lua @@ -164,3 +164,21 @@ function test_whitespace_ignore() end end end + +function test_u_encoding() + local encoder = json.encode.getEncoder() + local decoder = json.decode.getDecoder() + for i = 0, 255 do + local char = string.char(i) + assert_equal(char, decoder(encoder(char))) + end +end + +function test_x_encoding() + local encoder = json.encode.getEncoder({ strings = { xEncode = true } }) + local decoder = json.decode.getDecoder() + for i = 0, 255 do + local char = string.char(i) + assert_equal(char, decoder(encoder(char))) + end +end -- 2.11.4.GIT