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

Function TestSpec_PublicAPI_Exclude

pkg/sliceutil/spec_test.go:211–237  ·  view source on GitHub ↗

TestSpec_PublicAPI_Exclude validates the documented behavior of Exclude as described in the sliceutil README.md specification. Specification: "Returns a new slice with all exclude values removed while preserving order" README example: filtered := sliceutil.Exclude([]string{"a", "b", "c"}, "b")

(t *testing.T)

Source from the content-addressed store, hash-verified

209// filtered := sliceutil.Exclude([]string{"a", "b", "c"}, "b")
210// // filtered = ["a", "c"]
211func TestSpec_PublicAPI_Exclude(t *testing.T) {
212 t.Run("removes excluded values preserving order", func(t *testing.T) {
213 filtered := Exclude([]string{"a", "b", "c"}, "b")
214 assert.Equal(t, []string{"a", "c"}, filtered,
215 "Exclude should remove matching values and keep original order")
216 })
217
218 t.Run("removes multiple excluded values", func(t *testing.T) {
219 filtered := Exclude([]string{"a", "b", "c", "d"}, "b", "d")
220 assert.Equal(t, []string{"a", "c"}, filtered,
221 "Exclude should remove every matching exclude value")
222 })
223
224 t.Run("returns base unchanged when no exclude values match", func(t *testing.T) {
225 filtered := Exclude([]string{"a", "b", "c"}, "z")
226 assert.Equal(t, []string{"a", "b", "c"}, filtered,
227 "Exclude with no matching excludes should yield the base elements in order")
228 })
229
230 t.Run("does not modify input base slice", func(t *testing.T) {
231 original := []string{"a", "b", "c"}
232 input := make([]string, len(original))
233 copy(input, original)
234 _ = Exclude(input, "b")
235 assert.Equal(t, original, input, "Exclude must not modify the input base slice")
236 })
237}

Callers

nothing calls this directly

Calls 2

ExcludeFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected