summaryrefslogtreecommitdiffhomepage
path: root/dhcpv4
diff options
context:
space:
mode:
authorAnatole Denis <natolumin@unverle.fr>2019-10-08 10:20:37 +0200
committerChris K <c@chrisko.ch>2020-06-20 21:42:12 -0700
commit65668712da12ab11520b64097496616d39a50368 (patch)
tree73aabe68a64210e5f77be7b1492d9ae4c2d9e68b /dhcpv4
parent9a7fb219220c42cea49aec41ad5fdb1fed06b75b (diff)
dhcpv4: Consolidate identical tests into 1
Those 2 tests did the exact same thing: check that an invalid packet raises an error when parsed. Merge them into the same test, so that we can easily add more test cases to the list Signed-off-by: Anatole Denis <natolumin@unverle.fr>
Diffstat (limited to 'dhcpv4')
-rw-r--r--dhcpv4/dhcpv4_test.go23
1 files changed, 13 insertions, 10 deletions
diff --git a/dhcpv4/dhcpv4_test.go b/dhcpv4/dhcpv4_test.go
index ea3776c..3198a66 100644
--- a/dhcpv4/dhcpv4_test.go
+++ b/dhcpv4/dhcpv4_test.go
@@ -3,6 +3,7 @@ package dhcpv4
import (
"bytes"
"net"
+ "strconv"
"testing"
"github.com/insomniacslk/dhcp/iana"
@@ -80,16 +81,18 @@ func TestFromBytes(t *testing.T) {
// above
}
-func TestFromBytesZeroLength(t *testing.T) {
- data := []byte{}
- _, err := FromBytes(data)
- require.Error(t, err)
-}
-
-func TestFromBytesShortLength(t *testing.T) {
- data := []byte{1, 1, 6, 0}
- _, err := FromBytes(data)
- require.Error(t, err)
+func TestFromBytesGenericInvalid(t *testing.T) {
+ data := [][]byte{
+ {},
+ {1, 1, 6, 0},
+ }
+ t.Parallel()
+ for i, packet := range data {
+ t.Run(strconv.Itoa(i), func(t *testing.T) {
+ _, err := FromBytes(packet)
+ require.Error(t, err)
+ })
+ }
}
func TestFromBytesInvalidOptions(t *testing.T) {