MCPcopy Index your code
hub / github.com/donatj/sqlread / TestStringValue

Function TestStringValue

detail_test.go:5–32  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

3import "testing"
4
5func 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}

Callers

nothing calls this directly

Calls 1

stringValueFunction · 0.85

Tested by

no test coverage detected