Merge pull request #251 from picatz/test-network-net

start adding tests for network net
This commit is contained in:
Simone Margaritelli 2018-05-01 12:00:18 +02:00 committed by GitHub
commit 0910c1ed0e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

34
network/net_test.go Normal file
View file

@ -0,0 +1,34 @@
package network
import (
"net"
"testing"
)
func TestIsZeroMac(t *testing.T) {
exampleMAC, _ := net.ParseMAC("00:00:00:00:00:00")
exp := true
got := IsZeroMac(exampleMAC)
if got != exp {
t.Fatalf("expected '%t', got '%t'", exp, got)
}
}
func TestIsBroadcastMac(t *testing.T) {
exampleMAC, _ := net.ParseMAC("ff:ff:ff:ff:ff:ff")
exp := true
got := IsBroadcastMac(exampleMAC)
if got != exp {
t.Fatalf("expected '%t', got '%t'", exp, got)
}
}
func TestNormalizeMac(t *testing.T) {
exp := "ff:ff:ff:ff:ff:ff"
got := NormalizeMac("fF-fF-fF-fF-fF-fF")
if got != exp {
t.Fatalf("expected '%s', got '%s'", exp, got)
}
}