Skip to content
Snippets Groups Projects
Commit 0a870055 authored by Reinhold Kainhofer's avatar Reinhold Kainhofer
Browse files

unittesting: factor out calculations, improve testVmGlgExample, implement vmGlgExample.generateTest

parent de590363
No related branches found
No related tags found
No related merge requests found
...@@ -79,6 +79,7 @@ export(showVmGlgExamples) ...@@ -79,6 +79,7 @@ export(showVmGlgExamples)
export(sumProfits) export(sumProfits)
export(testVmGlgExample) export(testVmGlgExample)
export(valueOrFunction) export(valueOrFunction)
export(vmGlgExample.generateTest)
exportClasses(CalculationSingleEnum) exportClasses(CalculationSingleEnum)
exportClasses(PaymentTimeSingleEnum) exportClasses(PaymentTimeSingleEnum)
exportClasses(ProfitComponentsMultipleEnum) exportClasses(ProfitComponentsMultipleEnum)
......
This diff is collapsed.
...@@ -17,7 +17,7 @@ showVmGlgExamples(contract, prf = 10, t = 10, t_prf = 12, file = "", ...) ...@@ -17,7 +17,7 @@ showVmGlgExamples(contract, prf = 10, t = 10, t_prf = 12, file = "", ...)
\item{file}{If given, outputs all information to the file rather than the console} \item{file}{If given, outputs all information to the file rather than the console}
\item{...}{Further parameters (currently unused)} \item{...}{Further parameters for generating the contract for a tariff object}
} }
\description{ \description{
Display the values of the example calculation of the given insurance contract Display the values of the example calculation of the given insurance contract
......
...@@ -20,13 +20,14 @@ testVmGlgExample( ...@@ -20,13 +20,14 @@ testVmGlgExample(
VwKostenRes, VwKostenRes,
VwKostenRes.prf, VwKostenRes.prf,
Bilanzreserve, Bilanzreserve,
Prämienübertrag, Praemienuebertrag,
Rückkaufsreserve, Rueckkaufsreserve,
Rückkaufswert, Rueckkaufswert,
Abschlusskostenrücktrag, Abschlusskostenruecktrag,
Rückkaufswert.prf, Rueckkaufswert.prf,
VS.prf, VS.prf,
tolerance = 0.01 tolerance = 0.01,
...
) )
} }
\arguments{ \arguments{
...@@ -38,9 +39,11 @@ testVmGlgExample( ...@@ -38,9 +39,11 @@ testVmGlgExample(
\item{t_prf}{Time for which to check all values after the premium waiver} \item{t_prf}{Time for which to check all values after the premium waiver}
\item{net, }{Zillmer, gross, written, savings, risk, ZillmerRes, ZillmerRes.prf, VwKostenRes, VwKostenRes.prf, Bilanzreserve, Prämienübertrag, Rückkaufsreserve, Rückkaufswert, Abschlusskostenrücktrag, Rückkaufswert.prf, VS.prf Values as printed out by showVmGlgExamples} \item{net, }{Zillmer, gross, written, savings, risk, ZillmerRes, ZillmerRes.prf, VwKostenRes, VwKostenRes.prf, Bilanzreserve, Praemienuebertrag, Rueckkaufsreserve, Rueckkaufswert, Abschlusskostenruecktrag, Rueckkaufswert.prf, VS.prf Values as printed out by showVmGlgExamples}
\item{tolerance}{If non-NULL, will ignore small floating point differences. It uses same algorithm as all.equal()} \item{tolerance}{If non-NULL, will ignore small floating point differences. It uses same algorithm as all.equal()}
\item{...}{Further parameters for generating the contract for a tariff object}
} }
\description{ \description{
Check the values of the example calculation of the given insurance contract Check the values of the example calculation of the given insurance contract
...@@ -49,6 +52,9 @@ Versicherungsmathematische Grundlagen Verordnung"). ...@@ -49,6 +52,9 @@ Versicherungsmathematische Grundlagen Verordnung").
Missing params not passed to the function call will be silently ignored and Missing params not passed to the function call will be silently ignored and
not cause unit test failures. not cause unit test failures.
} }
\details{
The easiest way to write unit-tests is using the function \code{vmGlgExample.generateTest}
}
\examples{ \examples{
library(MortalityTables) library(MortalityTables)
mortalityTables.load("Austria_Annuities_AVOe2005R") mortalityTables.load("Austria_Annuities_AVOe2005R")
...@@ -77,11 +83,11 @@ test_that("Testtarif", { ...@@ -77,11 +83,11 @@ test_that("Testtarif", {
VwKostenRes = 0.00, VwKostenRes = 0.00,
VwKostenRes.prf = 0.00, VwKostenRes.prf = 0.00,
Bilanzreserve = 9250.35, Bilanzreserve = 9250.35,
Prämienübertrag = 212.52, Praemienuebertrag = 212.52,
Rückkaufsreserve = 9011.40, Rueckkaufsreserve = 9011.40,
Rückkaufswert = 9011.40, Rueckkaufswert = 9011.40,
Abschlusskostenrücktrag = 0.00, Abschlusskostenruecktrag = 0.00,
Rückkaufswert.prf = 9205.96, Rueckkaufswert.prf = 9205.96,
VS.prf = 685.12 VS.prf = 685.12
) )
}) })
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/showVmGlgExamples.R
\name{vmGlgExample.generateTest}
\alias{vmGlgExample.generateTest}
\title{Generate testthat output for unit-testing a tarif implementation}
\usage{
vmGlgExample.generateTest(contract, prf = 10, t = 10, t_prf = 12, ...)
}
\arguments{
\item{contract}{The insurance contract to calculate and generate unit-testing code.
If an InsuranceTarif object is given, a new contract with default
values is generated.}
\item{prf}{Time of premium waiver (premium-free)}
\item{t}{Time for which to calculate all values (except premium-free values)}
\item{t_prf}{Time for which to calculated all values after the premium waiver}
\item{...}{Further parameters for generating the contract for a tariff object}
}
\description{
This function calculates the required reference values for the given
insurance contract as required by the Austrian regulation (LV-VMGLV, "LV
Versicherungsmathematische Grundlagen Verordnung") and generates the
code for unit-testing the contract with these values. The code printed
can be directly copied into a unit test file.
}
\examples{
library(MortalityTables)
mortalityTables.load("Austria_Annuities_AVOe2005R")
# A trivial deferred annuity tariff with no costs:
tariff = InsuranceTarif$new(name="Test Annuity", type="annuity",
mortalityTable = AVOe2005R.unisex, i=0.01)
vmGlgExample.generateTest(tariff,
age = 35, YOB = 1981,
policyPeriod = 30, premiumPeriod = 15, deferralPeriod = 15,
sumInsured = 1000,
contractClosing = as.Date("2016-10-01")
)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment