Skip to content

sameInstant matcher doesn't handle null #19

@jacobg

Description

@jacobg

Current behavior when calling sameInstant with a null date is NullPointerException:

java.lang.NullPointerException
    at org.exparity.hamcrest.date.core.wrapper.DateWrapper.<init>(DateWrapper.java:30)
    at org.exparity.hamcrest.date.DateMatchers.sameInstant(DateMatchers.java:557)

It'd be nice if the matcher constructor did not have that exception, and would just return false on the matchesSafely call. That would allow a composite match like this:

assertThat(date, either(sameInstant(otherDate)).or(allOf(nullValue(), is(otherDate))));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions