github.com/mem/u-root@v2.0.1-0.20181004165302-9b18b4636a33+incompatible/cmds/elvish/program/json_test.go (about) 1 package program 2 3 import "testing" 4 5 var quoteJSONTests = []struct { 6 in string 7 want string 8 }{ 9 {`a`, `"a"`}, 10 {`"ab\c`, `"\"ab\\c"`}, 11 {"a\x19\x00", `"a\u0019\u0000"`}, 12 } 13 14 func TestQuoteJSON(t *testing.T) { 15 for _, test := range quoteJSONTests { 16 out := quoteJSON(test.in) 17 if out != test.want { 18 t.Errorf("quoteJSON(%q) = %q, want %q", test.in, out, test.want) 19 } 20 } 21 }