-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlib_test.go
64 lines (57 loc) · 1.62 KB
/
lib_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
64
package main
import (
"testing"
)
func TestParseDeviceOptionConstraints(t *testing.T) {
tests := []struct {
input []string
// Expected results value map
expectedr map[string][]string
// Expected default value map
expectedd map[string]string
}{
{
input: []string{
"mode 24bit Color[Fast]|Black & White|True Gray|Gray[Error Diffusion] [24bit Color[Fast]]",
"resolution 100|150|200|300|400|600|1200dpi [100]",
"source Automatic Document Feeder(left aligned) [Automatic Document Feeder(left aligned)]",
},
expectedr: map[string][]string{
"mode": {"24bit Color[Fast]", "Black & White", "True Gray", "Gray[Error Diffusion]"},
"resolution": {"100", "150", "200", "300", "400", "600", "1200dpi"},
"source": {"Automatic Document Feeder(left aligned)"},
},
expectedd: map[string]string{
"mode": "24bit Color[Fast]",
"resolution": "100",
"source": "Automatic Document Feeder(left aligned)",
},
},
}
for _, test := range tests {
gotr, gotd := parseDeviceOptionConstraints(test.input)
if gotr == nil {
t.Error("nil pointer for map")
}
for k, v := range gotr {
for kk, vv := range test.expectedr {
if k != kk {
continue
}
if len(v) != len(vv) {
t.Errorf("string slice len mismatch: got %v, wanted %v", len(v), len(vv))
}
for i := range v {
if v[i] != vv[i] {
t.Errorf("string slice value mismatch: got %v, wanted %v", v[i], vv[i])
}
}
}
}
for k, v := range gotd {
if v != test.expectedd[k] {
t.Errorf("expected default values had a mismatch: got %v, wanted %v", v, test.expectedd[k])
}
}
}
}