-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelper_test.go
More file actions
50 lines (44 loc) · 880 Bytes
/
helper_test.go
File metadata and controls
50 lines (44 loc) · 880 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package sqlite_test
import (
"testing"
"ella.to/sqlite"
)
func TestPlaceholders(t *testing.T) {
testCases := []struct {
count int
want string
}{
{0, ""},
{1, "?"},
{2, "?, ?"},
{3, "?, ?, ?"},
{4, "?, ?, ?, ?"},
{5, "?, ?, ?, ?, ?"},
}
for _, tc := range testCases {
got := sqlite.Placeholders(tc.count)
if got != tc.want {
t.Errorf("Placeholders(%d) = %q; want %q", tc.count, got, tc.want)
}
}
}
func TestGroupPlaceholders(t *testing.T) {
testCases := []struct {
row int
col int
want string
}{
{0, 0, ""},
{1, 1, "(?)"},
{1, 2, "(?, ?)"},
{2, 1, "(?), (?)"},
{2, 2, "(?, ?), (?, ?)"},
{2, 3, "(?, ?, ?), (?, ?, ?)"},
}
for _, tc := range testCases {
got := sqlite.GroupPlaceholders(tc.row, tc.col)
if got != tc.want {
t.Errorf("GroupPlaceholders(%d, %d) = %q; want %q", tc.row, tc.col, got, tc.want)
}
}
}