From 622a538b209924f79ff0f81b48b10f5cca34faa1 Mon Sep 17 00:00:00 2001 From: m7pr Date: Tue, 23 Jan 2024 12:17:41 +0100 Subject: [PATCH] few more --- tests/testthat/test-PictureBlock.R | 35 ++++++++++++------------------ tests/testthat/test-ReportCard.R | 25 +++++++++------------ tests/testthat/test-yaml_utils.R | 5 ++--- 3 files changed, 26 insertions(+), 39 deletions(-) diff --git a/tests/testthat/test-PictureBlock.R b/tests/testthat/test-PictureBlock.R index 5d96c846..724a89a3 100644 --- a/tests/testthat/test-PictureBlock.R +++ b/tests/testthat/test-PictureBlock.R @@ -1,8 +1,7 @@ # Constructor testthat::test_that("PictureBlock object can be created", { - testthat::expect_error( - PictureBlock$new(), - regexp = NA + testthat::expect_no_error( + PictureBlock$new() ) }) @@ -13,9 +12,8 @@ testthat::test_that("new returns an object of type PictureBlock", { # set_content testthat::test_that("set_content accepts a plot object", { block <- PictureBlock$new() - testthat::expect_error( - block$set_content(ggplot2::ggplot(iris)), - regexp = NA + testthat::expect_no_error( + block$set_content(ggplot2::ggplot(iris)) ) }) @@ -61,9 +59,8 @@ testthat::test_that("get_content returns character(0) on a newly initialized Pic # set_title testthat::test_that("set_title accepts a string", { - testthat::expect_error( - PictureBlock$new()$set_title("Test"), - NA + testthat::expect_no_error( + PictureBlock$new()$set_title("Test") ) }) @@ -101,9 +98,8 @@ testthat::test_that("get_title returns the set title", { # set_dim testthat::test_that("set_dim accepts an array of two numeric values", { - testthat::expect_error( - PictureBlock$new()$set_dim(c(0, 0)), - regexp = NA + testthat::expect_no_error( + PictureBlock$new()$set_dim(c(0, 0)) ) }) @@ -132,23 +128,20 @@ testthat::test_that("set_content throws if the content is not of the supported t }) testthat::test_that("set_content accepts a `ggplot` object", { - testthat::expect_error( - PictureBlock$new()$set_content(ggplot2::ggplot(iris)), - regexp = NA + testthat::expect_no_error( + PictureBlock$new()$set_content(ggplot2::ggplot(iris)) ) }) testthat::test_that("set_content accepts a `grob` object", { - testthat::expect_error( - PictureBlock$new()$set_content(ggplot2::ggplotGrob(ggplot2::ggplot(iris))), - regexp = NA + testthat::expect_no_error( + PictureBlock$new()$set_content(ggplot2::ggplotGrob(ggplot2::ggplot(iris))) ) }) testthat::test_that("set_content accepts a `trellis` object", { - testthat::expect_error( - PictureBlock$new()$set_content(lattice::bwplot(1)), - regexp = NA + testthat::expect_no_error( + PictureBlock$new()$set_content(lattice::bwplot(1)) ) }) diff --git a/tests/testthat/test-ReportCard.R b/tests/testthat/test-ReportCard.R index 1a7aff6c..5c0f5a10 100644 --- a/tests/testthat/test-ReportCard.R +++ b/tests/testthat/test-ReportCard.R @@ -16,9 +16,8 @@ testthat::test_that("append_text returns self", { }) testthat::test_that("append_table accepts a data.frame", { - testthat::expect_error( - ReportCard$new()$append_table(iris), - regexp = NA + testthat::expect_no_error( + ReportCard$new()$append_table(iris) ) }) @@ -33,31 +32,27 @@ testthat::test_that("append_plot returns self", { }) testthat::test_that("append_plot accepts a ggplot", { - testthat::expect_error( - ReportCard$new()$append_plot(ggplot2::ggplot(iris)), - regexp = NA + testthat::expect_no_error( + ReportCard$new()$append_plot(ggplot2::ggplot(iris)) ) }) testthat::test_that("append_plot accepts a ggplot with a dim", { - testthat::expect_error( - ReportCard$new()$append_plot(ggplot2::ggplot(iris), c(1000L, 100L)), - regexp = NA + testthat::expect_no_error( + ReportCard$new()$append_plot(ggplot2::ggplot(iris), c(1000L, 100L)) ) }) testthat::test_that("append_rcode accepts a character", { - testthat::expect_error( - ReportCard$new()$append_rcode("x <- 2"), - regexp = NA + testthat::expect_no_error( + ReportCard$new()$append_rcode("x <- 2") ) }) testthat::test_that("append_rcode returns self", { - testthat::expect_error( - ReportCard$new()$append_rcode("x <- 2"), - regexp = NA + testthat::expect_no_error( + ReportCard$new()$append_rcode("x <- 2") ) }) diff --git a/tests/testthat/test-yaml_utils.R b/tests/testthat/test-yaml_utils.R index 8d47dacb..ce700ae9 100644 --- a/tests/testthat/test-yaml_utils.R +++ b/tests/testthat/test-yaml_utils.R @@ -132,11 +132,10 @@ testthat::test_that("as_yaml_auto - do not accept multi outputs without the mult }) testthat::test_that("as_yaml_auto - accept multi outputs with the multi_output argument", { - testthat::expect_error( + testthat::expect_no_error( as_yaml_auto(list(author = "", output = "pdf_document", output = "html_document", toc = TRUE, keep_tex = TRUE), silent = TRUE, multi_output = TRUE - ), - NA + ) ) })