Skip to content

Commit

Permalink
Added minimal set of tests for new theta functionatlity.
Browse files Browse the repository at this point in the history
Uses coveralls instead, so .codecov not needed.
  • Loading branch information
AEBilgrau committed Nov 25, 2018
1 parent 544e3c1 commit 1efd76a
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 13 deletions.
2 changes: 1 addition & 1 deletion R/GMCM-package.R
Expand Up @@ -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
12 changes: 0 additions & 12 deletions codecov.yml

This file was deleted.

14 changes: 14 additions & 0 deletions 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])))
})
15 changes: 15 additions & 0 deletions 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)
10 changes: 10 additions & 0 deletions 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))
}))

0 comments on commit 1efd76a

Please sign in to comment.