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

Function TestSpec_PublicAPI_Any

pkg/sliceutil/spec_test.go:114–137  ·  view source on GitHub ↗

TestSpec_PublicAPI_Any validates the documented behavior of Any as described in the sliceutil README.md specification.

(t *testing.T)

Source from the content-addressed store, hash-verified

112// TestSpec_PublicAPI_Any validates the documented behavior of Any as described
113// in the sliceutil README.md specification.
114func TestSpec_PublicAPI_Any(t *testing.T) {
115 t.Run("returns true when at least one element matches predicate", func(t *testing.T) {
116 words := []string{"hello", "world"}
117 result := Any(words, func(w string) bool { return w == "world" })
118 assert.True(t, result, "Any should return true when a matching element exists")
119 })
120
121 t.Run("returns false when no element matches predicate", func(t *testing.T) {
122 words := []string{"hello", "world"}
123 result := Any(words, func(w string) bool { return w == "missing" })
124 assert.False(t, result, "Any should return false when no matching element exists")
125 })
126
127 t.Run("returns false for nil slice", func(t *testing.T) {
128 var nilSlice []string
129 result := Any(nilSlice, func(w string) bool { return true })
130 assert.False(t, result, "Any should return false for nil slice")
131 })
132
133 t.Run("returns false for empty slice", func(t *testing.T) {
134 result := Any([]string{}, func(w string) bool { return true })
135 assert.False(t, result, "Any should return false for empty slice")
136 })
137}
138
139// TestSpec_PublicAPI_Deduplicate validates the documented behavior of
140// Deduplicate as described in the sliceutil README.md specification.

Callers

nothing calls this directly

Calls 2

AnyFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected