- // Parsed IP without prefix receives a default one
- // so the input data must be adjusted
- if entry.result.Address.Af == ip_types.ADDRESS_IP4 && !strings.Contains(entry.input, "/") {
- entry.input = entry.input + "/32"
- }
- if entry.result.Address.Af == ip_types.ADDRESS_IP6 && !strings.Contains(entry.input, "/") {
- entry.input = entry.input + "/128"
- }
- originAddress := parsedAddress.ToString()
- Expect(originAddress).To(Equal(entry.input))
- })
- }
-}
-
-func TestGeneratedParsePrefixError(t *testing.T) {
- RegisterTestingT(t)
-
- _, err := ip_types.ParsePrefix("malformed_ip")
- Expect(err).Should(HaveOccurred())
-}
-
-func TestGeneratedParseMAC(t *testing.T) {
- RegisterTestingT(t)
-
- var data = []struct {
- input string
- result interfaces.MacAddress
- }{
- {"b7:b9:bb:a1:5c:af", interfaces.MacAddress{183, 185, 187, 161, 92, 175}},
- {"47:4b:c7:3e:06:c8", interfaces.MacAddress{71, 75, 199, 62, 6, 200}},
- {"a7:cc:9f:10:18:e3", interfaces.MacAddress{167, 204, 159, 16, 24, 227}},
- }
-
- for _, entry := range data {
- t.Run(entry.input, func(t *testing.T) {
- parsedMac, err := interfaces.ParseMAC(entry.input)
- Expect(err).ShouldNot(HaveOccurred())
- Expect(parsedMac).To(Equal(entry.result))
-
- originAddress := parsedMac.ToString()
- Expect(originAddress).To(Equal(entry.input))
- })
- }
-}
-
-func TestGeneratedParseMACError(t *testing.T) {
- RegisterTestingT(t)
-
- _, err := interfaces.ParseMAC("malformed_mac")
- Expect(err).Should(HaveOccurred())