-
Notifications
You must be signed in to change notification settings - Fork 42
/
fmt_test.go
36 lines (34 loc) · 1000 Bytes
/
fmt_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
package exp
import "testing"
func TestString(t *testing.T) {
for _, test := range []struct {
exp Exp
str string
}{
{True, "T"},
{False, "F"},
{Not(True), "¬T"},
{And(True), "(T)"},
{And(True, False), "(T∧F)"},
{Or(False), "(F)"},
{Or(True, False), "(T∨F)"},
{Eq("foo", 10), "[foo==10.00]"},
{Neq("foo", 5), "¬[foo==5.00]"},
{Gt("bar", 10), "[bar>10.00]"},
{Gte("bar", 10), "([bar>10.00]∨[bar==10.00])"},
{Lt("bar", 5), "[bar<5.00]"},
{Lte("bar", 5), "([bar<5.00]∨[bar==5.00])"},
{Match("baz", "abc"), "[baz==abc]"},
{MatchAny("baz", "abc", "bcd"), "([baz==abc]∨[baz==bcd])"},
{Contains("foo", "bc"), "[foo∋bc]"},
{ContainsAny("foo", "bc"), "[foo∋bc]"},
{ContainsRune("foo", 'a'), "[foo∋a]"},
{Len("bar", 3), "[len(bar)==3]"},
{Count("bar", "a", 2), "[count(bar,a)==2]"},
{EqualFold("bar", "AbC"), "[bar≈AbC]"},
} {
if sprintf("%s", test.exp) != test.str {
t.Errorf("unexpected string %q != %q", test.exp, test.str)
}
}
}