From a22cefc86285b6ba1d9879486fda11054d070b78 Mon Sep 17 00:00:00 2001 From: Sean Karlage Date: Sat, 3 Mar 2018 11:20:51 -0800 Subject: Add better formatting for vendor opts --- dhcpv4/options_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'dhcpv4/options_test.go') diff --git a/dhcpv4/options_test.go b/dhcpv4/options_test.go index 5a34ed5..47258aa 100644 --- a/dhcpv4/options_test.go +++ b/dhcpv4/options_test.go @@ -146,3 +146,21 @@ func TestOptionsToStringDHCPMessageType(t *testing.T) { t.Fatalf("Invalid string representation: %v", stropt) } } + +func TestBSDPOptionToString(t *testing.T) { + // Parse message type + option := Option{ + Code: BSDPOptionMessageType, + Data: []byte{BSDPMessageTypeList}, + } + stropt := option.BSDPString() + AssertEqual(t, stropt, "BSDP Message Type -> [1]", "BSDP string representation") + + // Parse failure + option = Option{ + Code: OptionCode(12), // invalid BSDP Opcode + Data: []byte{1, 2, 3}, + } + stropt = option.BSDPString() + AssertEqual(t, stropt, "Unknown -> [1 2 3]", "BSDP string representation") +} -- cgit v1.2.3