(t *testing.T)
| 3 | import "testing" |
| 4 | |
| 5 | func TestStringValue(t *testing.T) { |
| 6 | tests := []struct { |
| 7 | input string |
| 8 | output string |
| 9 | err error |
| 10 | }{ |
| 11 | {`no delimiters`, "", errorInvalidString}, |
| 12 | {`'mismatched delimiters"`, "", errorInvalidString}, |
| 13 | |
| 14 | {`'I am made of sauce'`, "I am made of sauce", nil}, |
| 15 | {`"I have lived a happy life free of sauce"`, "I have lived a happy life free of sauce", nil}, |
| 16 | {`"foo""bar"`, `foo"bar`, nil}, |
| 17 | {`"mismatched at end""`, ``, errorInvalidString}, |
| 18 | |
| 19 | {`"foo\"bar"`, `foo"bar`, nil}, |
| 20 | |
| 21 | {`"foo\\tbar"`, `foo\tbar`, nil}, |
| 22 | {`"foo\xbar"`, ``, errorInvalidString}, |
| 23 | } |
| 24 | |
| 25 | for _, test := range tests { |
| 26 | actual, err := stringValue(LexItem{Val: test.input}) |
| 27 | |
| 28 | if actual != test.output || err != test.err { |
| 29 | t.Errorf(`stringValue(LexItem{Val: %#v}) = %#v, %#v; want %#v, %#v`, test.input, actual, err, test.output, test.err) |
| 30 | } |
| 31 | } |
| 32 | } |
nothing calls this directly
no test coverage detected