Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
philipdelff committed Aug 12, 2024
1 parent 1dda219 commit 1e806e1
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 45 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: NMdata
Type: Package
Title: Preparation, Checking and Post-Processing Data for PK/PD Modeling
Version: 0.1.6.913
Version: 0.1.6.914
Authors@R:
c(person(given="Philip", family="Delff",
email = "philip@delff.dk",
Expand All @@ -23,6 +23,7 @@ Suggests:
testthat,
knitr,
NMsim,
NMcalc,
formatR,
mime,
rmarkdown,
Expand Down
106 changes: 62 additions & 44 deletions tests/testthat/test_NMdataConf.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,24 @@ context("NMdataConf")

NMdataConf(reset=TRUE)

dropFuns <- function(x){
x$as.fun <- NULL
x$file.mod <- NULL
x$file.cov <- NULL
x$file.ext <- NULL
x$file.phi <- NULL
x$file.shk <- NULL
x$modelname <- NULL
x
}

test_that("defaults",{

fileRef <- "testReference/NMdataConf_01.rds"
## ref <- readRDS(fileRef)

defaults <- NMdataConf()
defaults$as.fun <- NULL
defaults$file.mod <- NULL
defaults$file.cov <- NULL
defaults$file.ext <- NULL
defaults$file.phi <- NULL
defaults$modelname <- NULL
defaults <- dropFuns(defaults)

expect_equal_to_reference(defaults,fileRef)

Expand All @@ -28,18 +34,22 @@ test_that("reset",{
NMdataConf(reset=TRUE)
defaults2 <- NMdataConf()

defaults$as.fun <- NULL
defaults$file.mod <- NULL
defaults$file.cov <- NULL
defaults$file.ext <- NULL
defaults$file.phi <- NULL
defaults$modelname <- NULL
defaults2$as.fun <- NULL
defaults2$file.mod <- NULL
defaults2$file.cov <- NULL
defaults2$file.ext <- NULL
defaults2$file.phi <- NULL
defaults2$modelname <- NULL
defaults <- dropFuns(defaults)
defaults2 <- dropFuns(defaults2)
## defaults$as.fun <- NULL
## defaults$file.mod <- NULL
## defaults$file.cov <- NULL
## defaults$file.ext <- NULL
## defaults$file.phi <- NULL
## defaults$file.shk <- NULL
## defaults$modelname <- NULL
## defaults2$as.fun <- NULL
## defaults2$file.mod <- NULL
## defaults2$file.cov <- NULL
## defaults2$file.ext <- NULL
## defaults2$file.phi <- NULL
## defaults2$file.shk <- NULL
## defaults2$modelname <- NULL


expect_equal(defaults,defaults2)
Expand Down Expand Up @@ -83,19 +93,23 @@ test_that("change fun in globalenv does not affect NMdataConf()",{
afun <- class
defaults2 <- NMdataConf()

defaults$as.fun <- NULL
defaults$file.mod <- NULL
defaults$file.cov <- NULL
defaults$file.ext <- NULL
defaults$file.phi <- NULL
defaults$modelname <- NULL
defaults2$as.fun <- NULL
defaults2$file.mod <- NULL
defaults2$file.cov <- NULL
defaults2$file.ext <- NULL
defaults2$file.phi <- NULL
defaults2$modelname <- NULL
defaults <- dropFuns(defaults)
defaults2 <- dropFuns(defaults2)

## defaults$as.fun <- NULL
## defaults$file.mod <- NULL
## defaults$file.cov <- NULL
## defaults$file.ext <- NULL
## defaults$file.phi <- NULL
## defaults$file.shk <- NULL
## defaults$modelname <- NULL
## defaults2$as.fun <- NULL
## defaults2$file.mod <- NULL
## defaults2$file.cov <- NULL
## defaults2$file.ext <- NULL
## defaults2$file.phi <- NULL
## defaults2$file.shk <- NULL
## defaults2$modelname <- NULL

expect_equal(defaults,defaults2)
})
Expand Down Expand Up @@ -126,19 +140,24 @@ test_that("change fun in globalenv does not affect NMdataConf()",{
afun <- class
defaults2 <- NMdataConf()

defaults$as.fun <- NULL
defaults$file.mod <- NULL
defaults$file.cov <- NULL
defaults$file.ext <- NULL
defaults$file.phi <- NULL
defaults$modelname <- NULL

defaults2$as.fun <- NULL
defaults2$file.mod <- NULL
defaults2$file.cov <- NULL
defaults2$file.ext <- NULL
defaults2$file.phi <- NULL
defaults2$modelname <- NULL
defaults <- dropFuns(defaults)
defaults2 <- dropFuns(defaults2)

## defaults$as.fun <- NULL
## defaults$file.mod <- NULL
## defaults$file.cov <- NULL
## defaults$file.ext <- NULL
## defaults$file.phi <- NULL
## defaults$file.shk <- NULL
## defaults$modelname <- NULL

## defaults2$as.fun <- NULL
## defaults2$file.mod <- NULL
## defaults2$file.cov <- NULL
## defaults2$file.ext <- NULL
## defaults2$file.phi <- NULL
## defaults2$file.shk <- NULL
## defaults2$modelname <- NULL

expect_equal(defaults,defaults2)
})
Expand All @@ -162,7 +181,6 @@ test_that("deprecated use.rds",{
new$file.phi <- NULL
new$file.shk <- NULL
new$modelname <- NULL


expect_equal_to_reference(new,fileRef)
compareCols(readRDS(fileRef),new)
Expand Down

0 comments on commit 1e806e1

Please sign in to comment.