eXparity / hamcrest-date

A Java library which provides a suite hamcrest matchers for matching dates, times, and moments in time
BSD 3-Clause "New" or "Revised" License
70 stars 11 forks source link

after, before with inclusive boolean #3

Closed Proximator closed 11 years ago

Proximator commented 11 years ago

Does assertThat(date1, before(date2)) fails if date1 = date2 ? Probably, it is better to have an other method with a boolean like : after(Date : date, boolean inclusive) to have a behaviour similar to less or equals Samething for before. Any thoughts ?

stewbis commented 11 years ago

Rather than a flag to pass in, I'd go with sameOrAfter(date) and sameOrBefore(date) - achieves the same aim but without the flag

Proximator commented 11 years ago

What about higherThan and lowerThan for strictly after and before ? higher and lower are used in NavigableMap in that sense.

stewbis commented 11 years ago

After and before are obvious in their meaning when it comes to date, higher and lower don't really fit with a date test suite.I'll go with sameOrBefore(date) and sameOrAfter(date) because it follows the same expression patterns as the other same* tests.

assertThat(dateUnderTest, sameOrBefore(referenceDate)); assertThat(dateUnderTest, sameOrAfter(referenceDate));

stewbis commented 11 years ago

Hi, this has been added in release 0.9.4. Regards, Stewbis