Skip to content

Commit

Permalink
few more
Browse files Browse the repository at this point in the history
  • Loading branch information
m7pr committed Jan 23, 2024
1 parent 9e5f898 commit 622a538
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 39 deletions.
35 changes: 14 additions & 21 deletions tests/testthat/test-PictureBlock.R
Original file line number Diff line number Diff line change
@@ -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()
)
})

Expand All @@ -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))
)
})

Expand Down Expand Up @@ -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")
)
})

Expand Down Expand Up @@ -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))
)
})

Expand Down Expand Up @@ -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))
)
})

Expand Down
25 changes: 10 additions & 15 deletions tests/testthat/test-ReportCard.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
})

Expand All @@ -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")
)
})

Expand Down
5 changes: 2 additions & 3 deletions tests/testthat/test-yaml_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
)
})

Expand Down

0 comments on commit 622a538

Please sign in to comment.