File: test_dates.R

package info (click to toggle)
rquantlib 0.4.17-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,308 kB
  • sloc: cpp: 3,690; sh: 69; makefile: 6; ansic: 4
file content (24 lines) | stat: -rw-r--r-- 923 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

.onWindows <- .Platform$OS.type == "windows"

if (.onWindows) exit_file("Skipping dates test on Windows.")

Rcpp::sourceCpp("cpp/dates.cpp")

#test.date.conversion <- function() {
given <- as.Date("2000-01-01")
inc <- 2
expected <- given + inc

expect_equal(advanceDateRR(given, inc), expected, info="date conversion from R to R")
expect_equal(advanceDateQR(given, inc), expected, info="date conversion from QuantLib to R")
expect_equal(advanceDateQQ(given, inc), expected, info="date conversion from QuantLib to QuantLib")

#test.datevector.conversion <- function() {
given <- as.Date("2000-01-01") + 0:3
inc <- 2
expected <- given + inc

expect_equal(advanceDatesRR(given, inc), expected, info="date conversion from R to R")
expect_equal(advanceDatesQR(given, inc), expected, info="date conversion from QuantLib to QuantLib")
expect_equal(advanceDatesQQ(given, inc), expected, info="date conversion from QuantLib to R")