@Test
public void testReferenceChange() {
QL.info("Testing term structure against evaluation date change...");
final YieldTermStructure localTermStructure = new FlatForward(settlementDays, new NullCalendar(), 0.03, new Actual360());
final int days[] = { 10, 30, 60, 120, 360, 720 };
/*@DiscountFactor*/ final double[] expected = new /*@DiscountFactor*/ double[days.length];
final Date today = new Settings().evaluationDate();
for (int i=0; i<days.length; i++) {
final Date anotherDay = today.add(days[i]);
expected[i] = localTermStructure.discount(anotherDay);
}
final Date nextMonth = today.add(30);
new Settings().setEvaluationDate(nextMonth);
/*@DiscountFactor*/ final double[] calculated = new /*@DiscountFactor*/ double[days.length];
for (int i=0; i<days.length; i++) {
final Date anotherDay = nextMonth.add(days[i]);
calculated[i] = localTermStructure.discount(anotherDay);
}
for (int i=0; i<days.length; i++) {
if (!Closeness.isClose(expected[i],calculated[i])) {
fail("\n Discount at " + days[i] + " days:\n"