-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpluggeddevice_test.go
More file actions
47 lines (43 loc) · 892 Bytes
/
pluggeddevice_test.go
File metadata and controls
47 lines (43 loc) · 892 Bytes
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
package map_usb_devices
import (
"fmt"
"testing"
)
var testCasesDevices = []struct {
description string
product uint16
vendor uint16
want interface{}
}{
{
description: "devices info",
product: 0x6001,
vendor: 0x0403,
want: 2,
},
}
var implementationsDevices = []struct {
descr string
f func(p, v uint16) ([]string, error)
}{
{
descr: "DevicesInfo",
f: GetDevicesInfo,
},
}
func TestGetDevicesInfo(t *testing.T) {
for _, impl := range implementationsDevices {
t.Run(impl.descr, func(t *testing.T) {
for _, tc := range testCasesDevices {
t.Run(tc.description, func(t *testing.T) {
got, _ := impl.f(tc.product, tc.vendor)
if len(got) != tc.want {
t.Fatalf("Test result %v \ngot: %d\nwant: %d", got, len(got), tc.want)
} else {
fmt.Printf("Test result %v", got)
}
})
}
})
}
}