Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fbenke-pik committed Nov 15, 2023
1 parent 9a6ec24 commit 61f565e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion R/sortExtraPages.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
sortExtraPages <- function(extraPage) {
out <- list()
attrPattern <- "^(\\w+)-(\\w+)"
for (i in seq(extraPage)) {
for (i in seq_along(extraPage)) {
type <- sub(attrPattern, "\\1", names(extraPage)[i])
page <- sub(attrPattern, "\\2", names(extraPage)[i])
l <- list(extraPage[[i]])
Expand Down
14 changes: 11 additions & 3 deletions tests/testthat/test-goxygen.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,32 @@ test_that("extract documentation from modular dummy model", {
docfolder <- file.path(withr::local_tempdir(), "doc_modular")

out <- suppressWarnings(try(goxygen(path = system.file("dummymodel", package = "gms"), output = c("html", "tex"),
docfolder = docfolder, includeCore = TRUE, cff = "HOWTOCITE.cff", DoNotPlot = TRUE)))
docfolder = docfolder, includeCore = TRUE,
cff = "HOWTOCITE.cff", DoNotPlot = TRUE)))
expect_null(out)
expect_true(file.exists(file.path(docfolder, "html", "index.htm")))
expect_true(file.exists(file.path(docfolder, "html", "core.htm")))
expect_true(file.exists(file.path(docfolder, "html", "01_fancymodule.htm")))
expect_true(file.exists(file.path(docfolder, "html", "02_crazymodule.htm")))
expect_true(file.exists(file.path(docfolder, "html", "crazy.htm")))
expect_true(file.exists(file.path(docfolder, "html", "settings.htm")))
expect_true(file.exists(file.path(docfolder, "documentation.tex")))
})

test_that("extract HTML documentation from modular dummy model with classic style", {
docfolder <- file.path(withr::local_tempdir(), "doc_modular_classic")

out <- suppressWarnings(try(goxygen(path = system.file("dummymodel", package = "gms"),
htmlStyle = "classic", output = "html",
docfolder = docfolder, includeCore = TRUE, cff = "HOWTOCITE.cff", DoNotPlot = TRUE)))
htmlStyle = "classic", output = "html",
docfolder = docfolder, includeCore = TRUE,
cff = "HOWTOCITE.cff", DoNotPlot = TRUE)))
expect_null(out)
expect_true(file.exists(file.path(docfolder, "html", "index.htm")))
expect_true(file.exists(file.path(docfolder, "html", "core.htm")))
expect_true(file.exists(file.path(docfolder, "html", "01_fancymodule.htm")))
expect_true(file.exists(file.path(docfolder, "html", "02_crazymodule.htm")))
expect_true(file.exists(file.path(docfolder, "html", "crazy.htm")))
expect_true(file.exists(file.path(docfolder, "html", "settings.htm")))
})

test_that("cache and unknown output", {
Expand All @@ -44,5 +50,7 @@ test_that("extract documentation from simple dummy model", {
expect_true(file.exists(file.path(docfolder, "html", "index.htm")))
expect_true(file.exists(file.path(docfolder, "html", "modules_01_fancymodule_default_calculations.htm")))
expect_true(file.exists(file.path(docfolder, "html", "modules_02_crazymodule_module.htm")))
expect_true(file.exists(file.path(docfolder, "html", "crazy.htm")))
expect_true(file.exists(file.path(docfolder, "html", "settings.htm")))
expect_true(file.exists(file.path(docfolder, "documentation.tex")))
})

0 comments on commit 61f565e

Please sign in to comment.