diff --git a/tst/assertions.go b/tst/assertions.go index 91d66d1..0dde113 100644 --- a/tst/assertions.go +++ b/tst/assertions.go @@ -28,6 +28,24 @@ func AssertDeepEqual[T any](t *testing.T, actual T, expected T) { } } +func AssertSetDeepEqual[T any](t *testing.T, actual []T, expected []T) { + t.Helper() + if len(actual) != len(expected) { + t.Errorf("values differ in length: Actual (n=%d): '%v', Expected (n=%d): '%v'", len(actual), actual, len(expected), expected) + } + + for _, a := range expected { + found := false + for _, b := range actual { + found = found || reflect.DeepEqual(a, b) + } + if !found { + t.Errorf("values differ: Element '%v' not found. Actual: '%v', Expected: '%v'", a, actual, expected) + return + } + } +} + func AssertNotDeepEqual[T any](t *testing.T, actual T, expected T) { t.Helper() if !reflect.DeepEqual(actual, expected) {