-
Notifications
You must be signed in to change notification settings - Fork 0
/
with_full_address_test.go
47 lines (37 loc) · 1.11 KB
/
with_full_address_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
package macpot_test
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/yitsushi/macpot"
)
func TestNew_WithFullAddress(t *testing.T) {
mac, err := macpot.New(
macpot.WithFullAddress("11:22:33:44:55:66"),
)
assert.NoError(t, err)
assert.Equal(t, "11:22:33:44:55:66", mac.ToString())
}
func TestNew_WithFullAddress_short(t *testing.T) {
_, err := macpot.New(
macpot.WithFullAddress("11:22"),
)
assert.Error(t, err)
assert.ErrorAs(t, err, &macpot.AddressError{})
assert.Equal(t, "invalid MAC address length: 11:22", err.Error())
}
func TestNew_WithFullAddress_long(t *testing.T) {
_, err := macpot.New(
macpot.WithFullAddress("11:22:33:44:55:66:77"),
)
assert.Error(t, err)
assert.ErrorAs(t, err, &macpot.AddressError{})
assert.Equal(t, "invalid MAC address length: 11:22:33:44:55:66:77", err.Error())
}
func TestNew_WithFullAddress_invalidCharacter(t *testing.T) {
_, err := macpot.New(
macpot.WithFullAddress("11:2l:33:44:55:66"),
)
assert.Error(t, err)
assert.ErrorAs(t, err, &macpot.AddressError{})
assert.Equal(t, "strconv.ParseInt: parsing \"2l\": invalid syntax", err.Error())
}