Skip to content

Commit

Permalink
recMID test modified to avoid external code outside testthat calls.
Browse files Browse the repository at this point in the history
  • Loading branch information
janlisec committed Jul 25, 2023
1 parent d703876 commit 1e09eef
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions tests/testthat/test-recMID.R
Original file line number Diff line number Diff line change
@@ -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)))
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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",
Expand Down

0 comments on commit 1e09eef

Please sign in to comment.