MCPcopy Create free account
hub / github.com/github/gh-aw / TestExclude

Function TestExclude

pkg/sliceutil/sliceutil_test.go:330–360  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

328}
329
330func TestExclude(t *testing.T) {
331 tests := []struct {
332 name string
333 base []string
334 exclude []string
335 expected []string
336 }{
337 {
338 name: "excludes matching values while preserving order",
339 base: []string{"a", "b", "c", "b"},
340 exclude: []string{"b"},
341 expected: []string{"a", "c"},
342 },
343 {
344 name: "no excludes returns cloned slice",
345 base: []string{"a", "b"},
346 exclude: nil,
347 expected: []string{"a", "b"},
348 },
349 }
350
351 for _, tt := range tests {
352 t.Run(tt.name, func(t *testing.T) {
353 result := Exclude(tt.base, tt.exclude...)
354 assert.Equal(t, tt.expected, result, "Exclude should remove excluded elements")
355 if len(tt.exclude) == 0 && len(tt.base) > 0 {
356 assert.NotSame(t, &tt.base[0], &result[0], "Exclude should always return a fresh slice copy")
357 }
358 })
359 }
360}

Callers

nothing calls this directly

Calls 2

ExcludeFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected