From 9e59ca9bfef2d9d471b1c934698efabae87195bb Mon Sep 17 00:00:00 2001 From: Kent Gruber Date: Mon, 30 Apr 2018 22:42:02 -0400 Subject: [PATCH] start adding tests for network net * IsZeroMac * IsBroadcastMac * NormalizeMac --- network/net_test.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 network/net_test.go diff --git a/network/net_test.go b/network/net_test.go new file mode 100644 index 00000000..0f995950 --- /dev/null +++ b/network/net_test.go @@ -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) + } +}