add AssertSetDeepEqual

This commit is contained in:
Robin Willmann 2023-09-25 09:18:07 +02:00
parent c08a739158
commit 69d6290376

View File

@ -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) { func AssertNotDeepEqual[T any](t *testing.T, actual T, expected T) {
t.Helper() t.Helper()
if !reflect.DeepEqual(actual, expected) { if !reflect.DeepEqual(actual, expected) {