Skip to content

Commit 8c09f63

Browse files
test - add additional test cases
1 parent 61c3a12 commit 8c09f63

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

internal/eui64/tests/calculator_test.go

+14
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,14 @@ func TestCalculateEUI64(t *testing.T) {
192192
wantFullIP: "",
193193
wantErr: "parsing MAC address failed",
194194
},
195+
{
196+
name: "MAC exactly 6 bytes but invalid",
197+
mac: "00-14-22-01-23-ZZ", // 6 bytes, invalid hex
198+
prefix: "2001:0db8",
199+
wantInterfaceID: "",
200+
wantFullIP: "",
201+
wantErr: "parsing MAC address failed",
202+
},
195203
}
196204

197205
for _, tt := range tests {
@@ -312,6 +320,12 @@ func TestParsePrefix(t *testing.T) {
312320
wantParts: []string{"2001", "0db8"},
313321
wantErr: "", // Covers 88-94 if not already
314322
},
323+
{
324+
name: "Prefix with empty first hextet",
325+
prefix: ":2001:0db8",
326+
wantParts: []string{"", "2001", "0db8"},
327+
wantErr: "",
328+
},
315329
}
316330

317331
for _, testCase := range tests {

internal/eui64/tests/construct_full_ip_test.go

+6
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ func TestConstructFullIP(t *testing.T) {
6868
mac: []byte{0x00, 0x14, 0x22, 0x01, 0x23, 0x45},
6969
wantIP: "::214:22ff:fe01:2345",
7070
},
71+
{
72+
name: "Prefix with single empty hextet",
73+
prefixParts: []string{"2001", "", "0db8", "abcd"},
74+
mac: []byte{0x00, 0x14, 0x22, 0x01, 0x23, 0x45},
75+
wantIP: "2001:0:db8:abcd:214:22ff:fe01:2345",
76+
},
7177
}
7278

7379
for _, testCase := range tests {

0 commit comments

Comments
 (0)