From 1efd76a10fac251bc5ceefcc9d4bc2062a5f3db5 Mon Sep 17 00:00:00 2001 From: Anders E Bilgrau Date: Sun, 25 Nov 2018 19:24:20 +0100 Subject: [PATCH] Added minimal set of tests for new theta functionatlity. Uses coveralls instead, so .codecov not needed. --- R/GMCM-package.R | 2 +- codecov.yml | 12 ------------ tests/testthat/test-as.theta.R | 14 ++++++++++++++ tests/testthat/test-plot.theta.R | 15 +++++++++++++++ tests/testthat/test-print.theta-summary.theta.R | 10 ++++++++++ 5 files changed, 40 insertions(+), 13 deletions(-) delete mode 100644 codecov.yml create mode 100644 tests/testthat/test-as.theta.R create mode 100644 tests/testthat/test-plot.theta.R create mode 100644 tests/testthat/test-print.theta-summary.theta.R diff --git a/R/GMCM-package.R b/R/GMCM-package.R index 536bd1a..af62107 100644 --- a/R/GMCM-package.R +++ b/R/GMCM-package.R @@ -200,7 +200,7 @@ NULL # The following ensures that the DLL is unloaded when the package is unloaded. # See http://r-pkgs.had.co.nz/src.html .onUnload <- function(libpath) { - library.dynam.unload("GMCM", libpath) + library.dynam.unload("GMCM", libpath) # nocov } # 6f037e235ba745d55fea4baa9f32caf64ce2d336ac431578a4ce67ee6e1aebf2 diff --git a/codecov.yml b/codecov.yml deleted file mode 100644 index 8f36b6c..0000000 --- a/codecov.yml +++ /dev/null @@ -1,12 +0,0 @@ -comment: false - -coverage: - status: - project: - default: - target: auto - threshold: 1% - patch: - default: - target: auto - threshold: 1% diff --git a/tests/testthat/test-as.theta.R b/tests/testthat/test-as.theta.R new file mode 100644 index 0000000..f7afce1 --- /dev/null +++ b/tests/testthat/test-as.theta.R @@ -0,0 +1,14 @@ +context("Check as.theta") + +m <- 2 +d <- 2 +x <- list(m = m, + d = d, + pie = c(0.5, 0.5), + mu = list(comp1 = rep(0,d), comp2 = rep(1,d)), + sigma = list(comp1 = diag(d), comp2 = diag(d))) + +test_that("Check that as.theta works as intended", { + expect_true(is.theta(as.theta(x))) + suppressWarnings(expect_error(as.theta(x[-4]))) +}) diff --git a/tests/testthat/test-plot.theta.R b/tests/testthat/test-plot.theta.R new file mode 100644 index 0000000..d0d3001 --- /dev/null +++ b/tests/testthat/test-plot.theta.R @@ -0,0 +1,15 @@ +context("Check plot.theta") + +theta <- rtheta() # Create a random correctly formatted theta +file <- tempfile(fileext = ".pdf") + +test_that("plotting theta objects works", { + pdf(file) + out <- plot(theta) + dev.off() + expect_true(is.list(out)) + expect_identical(length(out), 3L) + expect_identical(names(out), letters[24+0:2]) +}) + +unlink(file) diff --git a/tests/testthat/test-print.theta-summary.theta.R b/tests/testthat/test-print.theta-summary.theta.R new file mode 100644 index 0000000..dfd6164 --- /dev/null +++ b/tests/testthat/test-print.theta-summary.theta.R @@ -0,0 +1,10 @@ +context("Check print.theta and summary.theta") + +theta <- rtheta() # Create a random correctly formatted theta + +test_that("Printing theta works", capture_output({ + expect_output(print(theta)) + expect_output(summary(theta)) + expect_identical(theta, print(theta)) + expect_identical(theta, summary(theta)) +}))