(t *testing.T)
| 56 | } |
| 57 | |
| 58 | func TestParseStringUnquote(t *testing.T) { |
| 59 | tests := []struct { |
| 60 | in string |
| 61 | out string |
| 62 | ext string |
| 63 | }{ |
| 64 | {`""`, ``, ``}, |
| 65 | {`"1234567890"`, `1234567890`, ``}, |
| 66 | {`"Hello World!"`, `Hello World!`, ``}, |
| 67 | {`"Hello\"World!"`, `Hello"World!`, ``}, |
| 68 | {`"\\"`, `\`, ``}, |
| 69 | {`"\u0061\u0062\u0063"`, `abc`, ``}, |
| 70 | } |
| 71 | |
| 72 | d := decoder{} |
| 73 | for _, test := range tests { |
| 74 | t.Run(test.in, func(t *testing.T) { |
| 75 | out, ext, _, err := d.parseStringUnquote([]byte(test.in), nil) |
| 76 | if err != nil { |
| 77 | t.Errorf("%s => %s", test.in, err) |
| 78 | return |
| 79 | } |
| 80 | |
| 81 | if s := string(out); s != test.out { |
| 82 | t.Error("invalid output") |
| 83 | t.Logf("expected: %s", test.out) |
| 84 | t.Logf("found: %s", s) |
| 85 | } |
| 86 | |
| 87 | if s := string(ext); s != test.ext { |
| 88 | t.Error("invalid extra bytes") |
| 89 | t.Logf("expected: %s", test.ext) |
| 90 | t.Logf("found: %s", s) |
| 91 | } |
| 92 | }) |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | func TestAppendToLower(t *testing.T) { |
| 97 | tests := []string{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…