-
-
Notifications
You must be signed in to change notification settings - Fork 296
Closed
Description
@bart0sh found the following odd behavior:
package foo
import (
"testing"
"github.com/onsi/gomega"
)
func TestHaveExactElements(t *testing.T) {
var expected []any = nil
actual := []string{"test"}
gomega.NewWithT(t).Expect(actual).To(gomega.HaveExactElements(expected...)) // Same as HaveExactElements().
if len(expected) != len(actual) {
t.Error("unexpected non-nil results", expected, actual)
}
}
Output:
--- FAIL: TestHaveExactElements (0.00s)
foo_test.go:15: HaveExactElements did not detect a length mismatch: the actual list has 1 elements, expected were 0
FAIL
FAIL k8s.io/kubernetes/foo 0.007s
FAIL
I think this is a bug. HaveExactElements
should report all extra elements in the actual slice. So if there is nothing to match against, any non-empty slice should cause a failure.
Metadata
Metadata
Assignees
Labels
No labels