Skip to content
This repository has been archived by the owner on May 25, 2023. It is now read-only.

Commit

Permalink
Add regression test for #125.
Browse files Browse the repository at this point in the history
Signed-off-by: David Anderson <[email protected]>
  • Loading branch information
danderson committed Jan 29, 2021
1 parent 54bff44 commit 8429105
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions ipset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,22 @@ func TestIPSet(t *testing.T) {
},
wantPrefixes: pxv("10.0.0.0/30", "10.0.0.255/32"),
},
{
// regression test for a bug where Ranges returned invalid IPRanges.
name: "single_ip_removal",
f: func(s *IPSet) {
s.Add(mustIP("10.0.0.0"))
s.Add(mustIP("10.0.0.1"))
s.Add(mustIP("10.0.0.2"))
s.Add(mustIP("10.0.0.3"))
s.Add(mustIP("10.0.0.4"))
s.Remove(mustIP("10.0.0.4"))
},
wantRanges: []IPRange{
{mustIP("10.0.0.0"), mustIP("10.0.0.3")},
},
wantPrefixes: pxv("10.0.0.0/30"),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand All @@ -220,6 +236,7 @@ func TestIPSet(t *testing.T) {
got := s.Ranges()
t.Run("ranges", func(t *testing.T) {
for _, v := range got {
debugf("%s -> %s", v.From, v.To)
if !v.Valid() {
t.Errorf("invalid IPRange in result: %s -> %s", v.From, v.To)
}
Expand Down

0 comments on commit 8429105

Please sign in to comment.