add AssertSetDeepEqual
This commit is contained in:
parent
c08a739158
commit
69d6290376
@ -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) {
|
||||||
|
Loading…
Reference in New Issue
Block a user