TestSpec_PublicAPI_Deduplicate validates the documented behavior of Deduplicate as described in the sliceutil README.md specification.
(t *testing.T)
| 139 | // TestSpec_PublicAPI_Deduplicate validates the documented behavior of |
| 140 | // Deduplicate as described in the sliceutil README.md specification. |
| 141 | func TestSpec_PublicAPI_Deduplicate(t *testing.T) { |
| 142 | t.Run("removes duplicates preserving first occurrence order", func(t *testing.T) { |
| 143 | items := []string{"a", "b", "a", "c", "b"} |
| 144 | unique := Deduplicate(items) |
| 145 | assert.Equal(t, []string{"a", "b", "c"}, unique, "Deduplicate should preserve order of first occurrence") |
| 146 | }) |
| 147 | |
| 148 | t.Run("does not modify input slice", func(t *testing.T) { |
| 149 | original := []string{"a", "b", "a", "c"} |
| 150 | input := make([]string, len(original)) |
| 151 | copy(input, original) |
| 152 | _ = Deduplicate(input) |
| 153 | assert.Equal(t, original, input, "Deduplicate must not modify the input slice") |
| 154 | }) |
| 155 | |
| 156 | t.Run("returns same elements for slice with no duplicates", func(t *testing.T) { |
| 157 | items := []string{"x", "y", "z"} |
| 158 | unique := Deduplicate(items) |
| 159 | assert.Equal(t, []string{"x", "y", "z"}, unique, "Deduplicate of slice with no duplicates should return same elements in same order") |
| 160 | }) |
| 161 | } |
| 162 | |
| 163 | // TestSpec_PublicAPI_MergeUnique validates the documented behavior of |
| 164 | // MergeUnique as described in the sliceutil README.md specification. |
nothing calls this directly
no test coverage detected