-
Notifications
You must be signed in to change notification settings - Fork 2
/
accm_test.go
63 lines (61 loc) · 1.23 KB
/
accm_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
52
53
54
55
56
57
58
59
60
61
62
63
package hdlc
import (
"testing"
)
func Test_asyncControlCharacterMap_contains(t *testing.T) {
tests := []struct {
name string
accm asyncControlCharacterMap
char byte
want bool
}{
{
name: "first control character",
accm: asyncControlCharacterMap(CharNUL),
char: 0x00,
want: true,
},
{
name: "last control character",
accm: asyncControlCharacterMap(CharUS),
char: 0x1F,
want: true,
},
{
name: "non-control character",
accm: asyncControlCharacterMap(CharALL),
char: 0x20,
want: false,
},
{
name: "accm is uninitialized",
char: '\n',
want: false,
},
{
name: "accm contains only the one character being checked",
accm: asyncControlCharacterMap(CharLF),
char: '\n',
want: true,
},
{
name: "accm contains all chars including the one being checked",
accm: asyncControlCharacterMap(CharALL),
char: '\t',
want: true,
},
{
name: "accm contains all chars except the one being checked",
accm: asyncControlCharacterMap(CharALL &^ CharHT),
char: '\t',
want: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.accm.contains(tt.char); got != tt.want {
t.Errorf("got %v, want %v", got, tt.want)
}
})
}
}