summaryrefslogtreecommitdiffhomepage
path: root/dhcpv4/bsdp/bsdp_test.go
diff options
context:
space:
mode:
authorSean Karlage <skarlage@fb.com>2018-03-21 22:22:21 -0700
committerinsomniac <insomniacslk@users.noreply.github.com>2018-03-22 10:52:25 -0700
commita5034c5a3be9a50b3b222b6234520d005ab41dbb (patch)
tree8625f387b886d1fedfc7628bff1d33928e0fa461 /dhcpv4/bsdp/bsdp_test.go
parente73a39c9e10a62f7e61949665b2afefc5b094f64 (diff)
Add specific BSDP options
Diffstat (limited to 'dhcpv4/bsdp/bsdp_test.go')
-rw-r--r--dhcpv4/bsdp/bsdp_test.go121
1 files changed, 0 insertions, 121 deletions
diff --git a/dhcpv4/bsdp/bsdp_test.go b/dhcpv4/bsdp/bsdp_test.go
index e323b52..ae9060d 100644
--- a/dhcpv4/bsdp/bsdp_test.go
+++ b/dhcpv4/bsdp/bsdp_test.go
@@ -9,127 +9,6 @@ import (
"github.com/stretchr/testify/require"
)
-/*
- * BootImageID
- */
-func TestBootImageIDToBytes(t *testing.T) {
- b := BootImageID{
- IsInstall: true,
- ImageType: BootImageTypeMacOSX,
- Index: 0x1000,
- }
- actual := b.ToBytes()
- expected := []byte{0x81, 0, 0x10, 0}
- require.Equal(t, expected, actual)
-
- b.IsInstall = false
- actual = b.ToBytes()
- expected = []byte{0x01, 0, 0x10, 0}
- require.Equal(t, expected, actual)
-}
-
-func TestBootImageIDFromBytes(t *testing.T) {
- b := BootImageID{
- IsInstall: false,
- ImageType: BootImageTypeMacOSX,
- Index: 0x1000,
- }
- newBootImage, err := BootImageIDFromBytes(b.ToBytes())
- require.NoError(t, err)
- require.Equal(t, b, *newBootImage)
-
- b = BootImageID{
- IsInstall: true,
- ImageType: BootImageTypeMacOSX,
- Index: 0x1011,
- }
- newBootImage, err = BootImageIDFromBytes(b.ToBytes())
- require.NoError(t, err)
- require.Equal(t, b, *newBootImage)
-}
-
-func TestBootImageIDFromBytesFail(t *testing.T) {
- serialized := []byte{0x81, 0, 0x10} // intentionally left short
- deserialized, err := BootImageIDFromBytes(serialized)
- require.Nil(t, deserialized)
- require.Error(t, err)
-}
-
-/*
- * BootImage
- */
-func TestBootImageToBytes(t *testing.T) {
- b := BootImage{
- ID: BootImageID{
- IsInstall: true,
- ImageType: BootImageTypeMacOSX,
- Index: 0x1000,
- },
- Name: "bsdp-1",
- }
- expected := []byte{
- 0x81, 0, 0x10, 0, // boot image ID
- 6, // len(Name)
- 98, 115, 100, 112, 45, 49, // byte-encoding of Name
- }
- actual := b.ToBytes()
- require.Equal(t, expected, actual)
-
- b = BootImage{
- ID: BootImageID{
- IsInstall: false,
- ImageType: BootImageTypeMacOSX,
- Index: 0x1010,
- },
- Name: "bsdp-21",
- }
- expected = []byte{
- 0x1, 0, 0x10, 0x10, // boot image ID
- 7, // len(Name)
- 98, 115, 100, 112, 45, 50, 49, // byte-encoding of Name
- }
- actual = b.ToBytes()
- require.Equal(t, expected, actual)
-}
-
-func TestBootImageFromBytes(t *testing.T) {
- input := []byte{
- 0x1, 0, 0x10, 0x10, // boot image ID
- 7, // len(Name)
- 98, 115, 100, 112, 45, 50, 49, // byte-encoding of Name
- }
- b, err := BootImageFromBytes(input)
- require.NoError(t, err)
- expectedBootImage := BootImage{
- ID: BootImageID{
- IsInstall: false,
- ImageType: BootImageTypeMacOSX,
- Index: 0x1010,
- },
- Name: "bsdp-21",
- }
- require.Equal(t, expectedBootImage, *b)
-}
-
-func TestBootImageFromBytesOnlyBootImageID(t *testing.T) {
- // Only a BootImageID, nothing else.
- input := []byte{0x1, 0, 0x10, 0x10}
- b, err := BootImageFromBytes(input)
- require.Nil(t, b)
- require.Error(t, err)
-}
-
-func TestBootImageFromBytesShortBootImage(t *testing.T) {
- input := []byte{
- 0x1, 0, 0x10, 0x10, // boot image ID
- 7, // len(Name)
- 98, 115, 100, 112, 45, 50, // Name bytes (intentionally off-by-one)
- }
- b, err := BootImageFromBytes(input)
- require.Nil(t, b)
- require.Error(t, err)
-}
-
func TestParseBootImageSingleBootImage(t *testing.T) {
input := []byte{
0x1, 0, 0x10, 0x10, // boot image ID