File: json_test.go

package info (click to toggle)
elvish 0.12%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,532 kB
  • sloc: python: 108; makefile: 94; sh: 72; xml: 9
file content (21 lines) | stat: -rw-r--r-- 377 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package program

import "testing"

var quoteJSONTests = []struct {
	in   string
	want string
}{
	{`a`, `"a"`},
	{`"ab\c`, `"\"ab\\c"`},
	{"a\x19\x00", `"a\u0019\u0000"`},
}

func TestQuoteJSON(t *testing.T) {
	for _, test := range quoteJSONTests {
		out := quoteJSON(test.in)
		if out != test.want {
			t.Errorf("quoteJSON(%q) = %q, want %q", test.in, out, test.want)
		}
	}
}