MCPcopy Index your code
hub / github.com/lib/pq / TestArrayParseError

Function TestArrayParseError

array_test.go:67–96  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

65}
66
67func TestArrayParseError(t *testing.T) {
68 tests := []struct {
69 in, wantErr string
70 }{
71 {``, "expected '{' at offset 0"},
72 {`x`, "expected '{' at offset 0"},
73 {`}`, "expected '{' at offset 0"},
74 {`{`, "expected '}' at offset 1"},
75 {`{{}`, "expected '}' at offset 3"},
76 {`{}}`, "unexpected '}' at offset 2"},
77 {`{,}`, "unexpected ',' at offset 1"},
78 {`{,x}`, "unexpected ',' at offset 1"},
79 {`{x,}`, "unexpected '}' at offset 3"},
80 {`{x,{`, "unexpected '{' at offset 3"},
81 {`{x},`, "unexpected ',' at offset 3"},
82 {`{x}}`, "unexpected '}' at offset 3"},
83 {`{{x}`, "expected '}' at offset 4"},
84 {`{""x}`, "unexpected 'x' at offset 3"},
85 {`{{a},{b,c}}`, "multidimensional arrays must have elements with matching dimensions"},
86 }
87
88 for _, tt := range tests {
89 t.Run("", func(t *testing.T) {
90 _, _, err := parseArray([]byte(tt.in), []byte{','})
91 if !pqtest.ErrorContains(err, tt.wantErr) {
92 t.Errorf("wrong error:\nhave: %s\nwant: %s", err, tt.wantErr)
93 }
94 })
95 }
96}
97
98func TestArrayFunc(t *testing.T) {
99 tests := []struct {

Callers

nothing calls this directly

Calls 2

ErrorContainsFunction · 0.92
parseArrayFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…