@Test
public void testEndOfMonth() {
QL.info("Testing end-of-month calculation...");
final Calendar c = new Target(); // any calendar would be OK
Date eom;
final Date counter = Date.minDate();
final Date last = Date.maxDate().sub(new Period(2, TimeUnit.Months));
while (counter.le(last)) {
eom = c.endOfMonth(counter);
// check that eom is eom
if (!c.isEndOfMonth(eom)) {
Assert.fail(String.format("%s %s %s is not the last business day in %s according to %s",
eom.weekday(), eom.dayOfMonth(), eom.month(), eom.year(), c.name() ));
}
// check that eom is in the same month as counter
if (eom.month()!=counter.month()) {
Assert.fail(String.format("%s is not the same month as %s", eom, counter ));
}