Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
pkg/matcher: isEmpty should fail for null or non-collections. #21562
This issue was originally filed by bl...@google.com
As there is no isNotEmpty matcher, you are forced to use isNot(isEmpty). However, expect(null, isNot(isEmpty)) passes because isEmpty returns false for non-collections or null. So, likewise, any other non-collection object would also wrongly pass such an expect call.
My suggested solution would be for isEmpty to throw an exception for "wrong" types.
Alternatively, an isNotEmpty matcher could be added.