From 1e09eeff2bb05f22be1881f07bc1124c5b65d9f9 Mon Sep 17 00:00:00 2001 From: Lisec Date: Tue, 25 Jul 2023 10:30:18 +0200 Subject: [PATCH] recMID test modified to avoid external code outside `testthat` calls. --- tests/testthat/test-recMID.R | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/tests/testthat/test-recMID.R b/tests/testthat/test-recMID.R index b1fa22e..eaea07d 100644 --- a/tests/testthat/test-recMID.R +++ b/tests/testthat/test-recMID.R @@ -1,14 +1,8 @@ -# simple calculations -fml <- "C9H20O3Si2" -mid <- c(0.9,0,0,0.1) -r <- list("M+H"=0.8, "M-H"=0.1, "M+H2O-CH4"=0.1) -rMID <- CorMID::recMID(mid=mid, r=r, fml=fml) -# avoid creating a Rplots.pdf in testthat folder -pdf(NULL) - testthat::test_that( desc = "recMID returns expected result", code = { + # simple calculations + rMID <- CorMID::recMID(mid=c(0.9,0,0,0.1), r=list("M+H"=0.8, "M-H"=0.1, "M+H2O-CH4"=0.1), fml="C9H20O3Si2") testthat::expect_true(inherits(rMID, "recMID")) testthat::expect_true(is.numeric(rMID)) testthat::expect_false(is.null(names(rMID))) @@ -19,6 +13,9 @@ testthat::test_that( testthat::test_that( desc = "recMID plot returns expected result", code = { + # avoid creating a Rplots.pdf in testthat folder + pdf(NULL) + rMID <- CorMID::recMID(mid=c(0.9,0,0,0.1), r=list("M+H"=0.8, "M-H"=0.1, "M+H2O-CH4"=0.1), fml="C9H20O3Si2") vdiffr::expect_doppelganger( title = "recMID_Plot", fig = function() plot(rMID) @@ -29,6 +26,9 @@ testthat::test_that( testthat::test_that( desc = "recMID plot returns expected result with alternative options", code = { + # avoid creating a Rplots.pdf in testthat folder + pdf(NULL) + rMID <- CorMID::recMID(mid=c(0.9,0,0,0.1), r=list("M+H"=0.8, "M-H"=0.1, "M+H2O-CH4"=0.1), fml="C9H20O3Si2") vdiffr::expect_doppelganger( title = "recMID_Plot_alt", fig = function() plot(unname(rMID), xlab="test", ylab="test", lwd=9, lend=2, xlim=c(0,10), ylim=c(0,2), las=1) @@ -39,6 +39,9 @@ testthat::test_that( testthat::test_that( desc = "recMID plot returns expected result with more alternative options", code = { + # avoid creating a Rplots.pdf in testthat folder + pdf(NULL) + rMID <- CorMID::recMID(mid=c(0.9,0,0,0.1), r=list("M+H"=0.8, "M-H"=0.1, "M+H2O-CH4"=0.1), fml="C9H20O3Si2") names(rMID) <- 1:length(rMID) vdiffr::expect_doppelganger( title = "recMID_Plot_alt2",