-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvendor_test.go
68 lines (54 loc) · 1.62 KB
/
vendor_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
65
66
67
68
package vendor
import (
"testing"
)
const MacBookMac = `6c:40:08:b2:1b:a4`
const OnePlusOneMac = `C0EEFB3368FA`
const RandomMac1 = `C2EEFB3368FA`
const RandomMac2 = `6e:40:08:b2:1b:a4`
func TestLookup(t *testing.T) {
Init()
MacBookVendorString := Lookup(MacBookMac)
if MacBookVendorString != "Apple, Inc." {
t.Errorf("Error looking up MacBook Mac. %v", MacBookVendorString)
}
OnePlusVendorString := Lookup(OnePlusOneMac)
if OnePlusVendorString != "OnePlus Tech (Shenzhen) Ltd" {
t.Errorf("Error looking up OnePlus Mac. %v", OnePlusVendorString)
}
if Lookup(RandomMac1) != "Random" {
t.Errorf("Error looking up Random Mac. 1")
}
if Lookup(RandomMac2) != "Random" {
t.Errorf("Error looking up Random Mac. 2")
}
if Lookup("") != "Malformed" {
t.Errorf("Error looking up empty string %v", Lookup(""))
}
if Lookup("dummy") != "Malformed" {
t.Errorf("Error looking up dummy string")
}
}
func TestLookupNoInit(t *testing.T) {
VendorMap = make(map[string]string)
MacBookVendorString := Lookup(MacBookMac)
if MacBookVendorString != "Unknown" {
t.Errorf("Error looking up MacBook Mac. %v", MacBookVendorString)
}
OnePlusVendorString := Lookup(OnePlusOneMac)
if OnePlusVendorString != "Unknown" {
t.Errorf("Error looking up OnePlus Mac. %v", OnePlusVendorString)
}
if Lookup(RandomMac1) != "Random" {
t.Errorf("Error looking up Random Mac. 1")
}
if Lookup(RandomMac2) != "Random" {
t.Errorf("Error looking up Random Mac. 2")
}
if Lookup("") != "Malformed" {
t.Errorf("Error looking up empty string %v", Lookup(""))
}
if Lookup("dummy") != "Malformed" {
t.Errorf("Error looking up dummy string")
}
}