go.charczuk.com@v0.0.0-20240327042549-bc490516bd1a/sdk/assert/its_any.go (about) 1 /* 2 3 Copyright (c) 2023 - Present. Will Charczuk. All rights reserved. 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file at the root of the repository. 5 6 */ 7 8 package assert 9 10 import "testing" 11 12 // ItsAny is an assertion helper. 13 // 14 // It will test that any value in the slice matches the filter. 15 func ItsAny[T any](t *testing.T, values []T, fn func(T) bool, message ...any) { 16 t.Helper() 17 for _, v := range values { 18 if fn(v) { 19 return 20 } 21 } 22 Fatalf(t, "expected any slice value to match the filter", nil, message) 23 }