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

Function TestSpec_PublicAPI_MergeUnique

pkg/sliceutil/spec_test.go:173–199  ·  view source on GitHub ↗

TestSpec_PublicAPI_MergeUnique validates the documented behavior of MergeUnique as described in the sliceutil README.md specification. Specification: "Returns a deduplicated slice starting with base and appending unseen values from extra" README example: merged := sliceutil.MergeUnique([]string{

(t *testing.T)

Source from the content-addressed store, hash-verified

171// merged := sliceutil.MergeUnique([]string{"a", "b"}, "b", "c")
172// // merged = ["a", "b", "c"]
173func TestSpec_PublicAPI_MergeUnique(t *testing.T) {
174 t.Run("appends unseen values from extra to base", func(t *testing.T) {
175 merged := MergeUnique([]string{"a", "b"}, "b", "c")
176 assert.Equal(t, []string{"a", "b", "c"}, merged,
177 "MergeUnique should append only unseen extras, in order")
178 })
179
180 t.Run("base is deduplicated when it contains duplicates", func(t *testing.T) {
181 merged := MergeUnique([]string{"a", "b", "a"}, "c")
182 assert.Equal(t, []string{"a", "b", "c"}, merged,
183 "MergeUnique should deduplicate the base slice")
184 })
185
186 t.Run("returns base when extra is empty", func(t *testing.T) {
187 merged := MergeUnique([]string{"x", "y"})
188 assert.Equal(t, []string{"x", "y"}, merged,
189 "MergeUnique with no extras should yield the deduplicated base")
190 })
191
192 t.Run("does not modify input base slice", func(t *testing.T) {
193 original := []string{"a", "b"}
194 input := make([]string, len(original))
195 copy(input, original)
196 _ = MergeUnique(input, "b", "c")
197 assert.Equal(t, original, input, "MergeUnique must not modify the input base slice")
198 })
199}
200
201// TestSpec_PublicAPI_Exclude validates the documented behavior of
202// Exclude as described in the sliceutil README.md specification.

Callers

nothing calls this directly

Calls 2

MergeUniqueFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected