From fe514a2f7924817ecf915aab738dd138e3f05149 Mon Sep 17 00:00:00 2001 From: Vladimir Timofeev Date: Sat, 3 Jun 2017 13:59:13 +0300 Subject: [PATCH] Incorporate tests from #2 "escape quote only if odd number of escape chars" --- parser_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/parser_test.go b/parser_test.go index 35d3ffa..b24e5ff 100644 --- a/parser_test.go +++ b/parser_test.go @@ -106,6 +106,11 @@ var _ = Describe("parser", func() { // spaces {"skip various spaces", " \u000a\u000d\u0009true", BeTrue(), ExpectNoErr()}, {"don't skip low chars as spaces", " \u0008true", BeNil(), ExpectSyntaxErr(`unrecognized token`, 1)}, + //escapes + {"escape quote", `{"k1":"v1\"qwe"}`, Equal(map[string]interface{}{"k1": `v1"qwe`}), ExpectNoErr()}, + {"escape slash", `{"k1":"v1\\"}`, Equal(map[string]interface{}{"k1": `v1\`}), ExpectNoErr()}, + {"escape slash and quote", `{"k1":"v1\\\"qwe"}`, Equal(map[string]interface{}{"k1": `v1\"qwe`}), ExpectNoErr()}, + {"escape quote error", `{"k1":"v1\"qwe}`, Equal(map[string]interface{}{"k1": ""}), ExpectSyntaxErr("incorrect syntax - expected close quote", 15)}, } for n, t := range table { n, t := n, t