Skip to content

Commit

Permalink
Fix vol surface test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
imanuelcostigan committed Sep 7, 2019
1 parent 02b4c98 commit fc404f1
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions tests/testthat/test-volsurface.R
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
context("VolSurface")

testthat::test_that(desc = "vol surface creation works", {
testthat::test_that("Vol surface creation works", {
testthat::expect_is(build_vol_surface(), "VolSurface")
})

testthat::test_that("time variance interpolation works", {
testthat::expect_true(is.LinearCubicTimeVarInterpolation(LinearCubicTimeVarInterpolation()))
testthat::test_that("Time variance interpolation creation works", {
testthat::expect_true(
is.LinearCubicTimeVarInterpolation(LinearCubicTimeVarInterpolation())
)
})

testthat::test_that("the interpolation is working as expected", {
testthat::test_that("Time variance interpolation works", {
term <- c(
as.Date("2023-08-15"), as.Date("2023-10-10"), as.Date("2020-02-29"),
as.Date("2021-04-15"), as.Date("2022-06-10"), as.Date("2025-06-10")
)
smile <- c(3, 96, 150, 80, 90, 300)

vs <- build_vol_surface()
testthat::expect_equal(
round(interpolate(vs, list(term = term, smile = smile)), 12)
, round(c(
0.6076543447950257, 0.26853916752886564, 0.19909034016558932,
0.25769535624031686, 0.25855784359768552, 0.26647898600000003
), 12)
res <- interpolate(vs, tibble::tibble(term = term, smile = smile))
exp <- c(
0.6076543447950257, 0.26853916752886564, 0.19909034016558932,
0.25769535624031686, 0.25855784359768552, 0.26647898600000003
)
testthat::expect_equal(round(res, 12), round(exp, 12))
})

0 comments on commit fc404f1

Please sign in to comment.