From 4556f70aa8fd4826551399701144ec56f4733954 Mon Sep 17 00:00:00 2001 From: Thomas Harning Jr Date: Mon, 18 Apr 2016 23:08:49 -0400 Subject: [PATCH] tests: enhances coverage for strings.additionalEscapes decoding option --- tests/lunit-tests.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/lunit-tests.lua b/tests/lunit-tests.lua index d7adfe4..10f38cb 100644 --- a/tests/lunit-tests.lua +++ b/tests/lunit-tests.lua @@ -1,6 +1,7 @@ local json = require("json") local lunit = require("lunit") local testutil = require("testutil") +local lpeg = require("lpeg") -- DECODE NOT 'local' due to requirement for testutil to access it decode = json.decode.getDecoder(false) @@ -42,6 +43,11 @@ function test_preprocess() assert_equal('-Infinity', json.encode(1/0, {preProcess = function(x) return -x end})) end +function test_additionalEscapes_only() + -- Need to do escape while skipping escape character san-check + assert_equal("Hello", json.decode([["\S"]], { strings = { additionalEscapes = lpeg.C(lpeg.P("S")) / "Hello", escapeCheck= false } })) +end + local strictDecoder = json.decode.getDecoder(true) local function buildStrictDecoder(f) @@ -52,7 +58,7 @@ local function buildFailedStrictDecoder(f) end -- SETUP CHECKS FOR SEQUENCE OF DECODERS for k, v in pairs(TEST_ENV) do - if k:match("^test_") and not k:match("_gen$") then + if k:match("^test_") and not k:match("_gen$") and not k:match("_only$") then if k:match("_nostrict") then TEST_ENV[k .. "_strict_gen"] = buildFailedStrictDecoder(v) else -- 2.11.4.GIT