Skip to content

Commit

Permalink
Incorporate tests from #2 "escape quote only if odd number of escape …
Browse files Browse the repository at this point in the history
…chars"
  • Loading branch information
vovkasm committed Jun 3, 2017
1 parent 627c4d7 commit fe514a2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fe514a2

Please sign in to comment.