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
|
package app
import "testing"
func TestLooksLikeMouseLeak(t *testing.T) {
leak := []string{
"<64;68;26M",
"<64;68;26M<64;68;26M<64;68;26M",
"64;68;26M", // leading '<' consumed by the parser
"<65;68;26m", // release form (lowercase m)
"<0;1;1M<0;2;2M",
}
for _, s := range leak {
if !looksLikeMouseLeak(s) {
t.Errorf("looksLikeMouseLeak(%q) = false, want true", s)
}
}
ok := []string{
"hello", "# glint", "<", "<3", "i <3 you", "a;b;c",
"64;68", "", ";;", "<64;68;26", "3 < 5 && 2 > 1",
}
for _, s := range ok {
if looksLikeMouseLeak(s) {
t.Errorf("looksLikeMouseLeak(%q) = true, want false (normal input)", s)
}
}
}
|