Skip to content

Commit

Permalink
netmap/policy: Add test checking CopyTo clones empty sub-filter slice
Browse files Browse the repository at this point in the history
Signed-off-by: Leonard Lyubich <[email protected]>
  • Loading branch information
cthulhu-rider committed Dec 26, 2024
1 parent 062f36b commit fade159
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions netmap/policy_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ func TestPlacementPolicy_CopyTo(t *testing.T) {
require.Equal(t, topFilter.Name(), dst.filters[0].Name())
require.NotEqual(t, topFilter.SubFilters()[0].Name(), dst.filters[0].SubFilters()[0].Name())
})
t.Run("empty", func(t *testing.T) {
var src, dst PlacementPolicy
src.filters = []Filter{{subs: make([]Filter, 0, 1)}}

src.CopyTo(&dst)
require.Len(t, dst.filters, 1)
require.Zero(t, cap(dst.filters[0].subs))
})
})

t.Run("empty filters", func(t *testing.T) {
Expand Down

0 comments on commit fade159

Please sign in to comment.