-
Notifications
You must be signed in to change notification settings - Fork 34
/
tagindex_test.go
51 lines (46 loc) · 1.15 KB
/
tagindex_test.go
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
51
package main
import (
"testing"
)
func TestParseTagHelper(t *testing.T) {
tests := []struct {
offered, expected string
}{
{"''", "''"},
{"This is a busted tag Del Snarf | Look", "This"},
{"'This is a newfangled tag' Del Snarf | Look", "'This is a newfangled tag'"},
}
for _, v := range tests {
returned := parsetaghelper(v.offered)
if returned != v.expected {
t.Errorf("Tag [%s]: expected [%s], got [%s]", v.offered, v.expected, returned)
}
}
}
func TestQuoteFilename(t *testing.T) {
for _, tc := range []struct {
in, out string
}{
{"quote me", "'quote me'"},
{"dontquoteme\\", "dontquoteme\\"},
{" quote me", "' quote me'"},
{"quote me ", "'quote me '"},
{"'dontrequoteme'", "'dontrequoteme'"},
} {
if qt := QuoteFilename(tc.in); qt != tc.out {
t.Errorf("QuoteFilename failed: Expected [%v] got [%v]", tc.out, qt)
}
}
}
func TestUnquoteFilename(t *testing.T) {
for _, tc := range []struct {
out, in string
}{
{"unquote me", "'unquote me'"},
{"dontunquoteme\\", "dontunquoteme\\"},
} {
if qt := UnquoteFilename(tc.in); qt != tc.out {
t.Errorf("UnquoteFilename failed: Expected [%v] got [%v]", tc.out, qt)
}
}
}