-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdetail_test.go
More file actions
32 lines (25 loc) · 864 Bytes
/
detail_test.go
File metadata and controls
32 lines (25 loc) · 864 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package sqlread
import "testing"
func TestStringValue(t *testing.T) {
tests := []struct {
input string
output string
err error
}{
{`no delimiters`, "", errorInvalidString},
{`'mismatched delimiters"`, "", errorInvalidString},
{`'I am made of sauce'`, "I am made of sauce", nil},
{`"I have lived a happy life free of sauce"`, "I have lived a happy life free of sauce", nil},
{`"foo""bar"`, `foo"bar`, nil},
{`"mismatched at end""`, ``, errorInvalidString},
{`"foo\"bar"`, `foo"bar`, nil},
{`"foo\\tbar"`, `foo\tbar`, nil},
{`"foo\xbar"`, ``, errorInvalidString},
}
for _, test := range tests {
actual, err := stringValue(LexItem{Val: test.input})
if actual != test.output || err != test.err {
t.Errorf(`stringValue(LexItem{Val: %#v}) = %#v, %#v; want %#v, %#v`, test.input, actual, err, test.output, test.err)
}
}
}