@@ -3,6 +3,7 @@ library(RQuantLib)
33
44# # For QuantLib 1.31 or newer we need to adjust three test expectations
55is131 <- gsub(" -[a-z]+" , " " , RQuantLib :: getQuantLibVersion()) > = " 1.31"
6+ is138 <- gsub(" -[a-z]+" , " " , RQuantLib :: getQuantLibVersion()) > = " 1.38"
67
78# test.Schedule <- function() {
89# # these tests are taken from the QuantLib test-suite/schedule.cpp file
@@ -23,7 +24,7 @@ params <- list(effectiveDate= as.Date("2009-09-30"),
2324 dateGeneration = " Forward" ,
2425 endOfMonth = T )
2526expected <- as.Date(c(" 2009-09-30" , " 2010-03-31" , " 2010-09-30" , " 2011-03-31" , " 2011-09-30" ,
26- " 2012-03-30" ,
27+ if ( is138 ) " 2012-04-02 " else " 2012-03-30" ,
2728 if (is131 ) " 2012-06-15" else " 2012-06-29" ))
2829expect_equal(Schedule(params ), expected , info = " Testing end date for schedule with end-of-month adjustment..." )
2930
@@ -76,8 +77,13 @@ params <- list(effectiveDate = as.Date("1996-08-22"),
7677 terminationDateConvention = " Following" ,
7778 dateGeneration = " Backward" ,
7879 endOfMonth = T )
79- expected <- if (is131 ) { as.Date(c(" 1996-08-22" , " 1996-08-30" , " 1997-02-28" , " 1997-09-02" ))
80- } else { as.Date(c(" 1996-08-30" , " 1997-02-28" , " 1997-08-29" )) }
80+ expected <- if (is138 ) {
81+ as.Date(c(" 1996-08-22" , " 1996-09-03" , " 1997-02-28" , " 1997-09-02" ))
82+ } else if (is131 ) {
83+ as.Date(c(" 1996-08-22" , " 1996-08-30" , " 1997-02-28" , " 1997-09-02" ))
84+ } else {
85+ as.Date(c(" 1996-08-30" , " 1997-02-28" , " 1997-08-29" ))
86+ }
8187expect_equal(Schedule(params ), expected , info = paste(" Testing that the first date is not duplicated due to" ,
8288 " EOM convention when going backwards..." ))
8389
0 commit comments