Skip to content

Commit

Permalink
New test Cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhi-1U committed Oct 18, 2024
1 parent 4084f3e commit e7b0389
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
20 changes: 20 additions & 0 deletions tests/testthat/test-code-tools.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
test_that("filter_code_env", {
target = "example"
replacement = "verbatim"
raw_lines = "\\begin{example}\n print('helloworld')\n \\end{example}"
expected_raw_lines = "\\begin{verbatim}\n print('helloworld')\n \\end{verbatim}"
fun_out = suppressMessages(texor:::filter_code_env(raw_lines,target,replacement))
expect_equal(fun_out,expected_raw_lines)
})

test_that("patch_code_env", {
article_dir <- system.file("examples/article", package = "texor")
dir.create(your_article_folder <- file.path(tempdir(), "tempdir"))
x <- file.copy(from = article_dir, to = your_article_folder,recursive = TRUE,)
your_article_path <- paste(your_article_folder,"article",sep="/")
file_data <- readLines(paste0(your_article_path,"/example.tex"))
suppressMessages(texor:::patch_code_env(your_article_path))
after_patch_data <- readLines(paste0(your_article_path,"/example.tex"))
expect_equal(after_patch_data,suppressMessages(texor:::filter_code_env(file_data,"example","verbatim")))
unlink(your_article_folder,recursive = TRUE)
})
9 changes: 9 additions & 0 deletions tests/testthat/test-file-tools.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,12 @@ test_that("comment filter", {

expect_equal(comment_filter(raw_text), expected_text)
})

test_that("find_wrapper",{
article_dir <- system.file("examples/article", package = "texor")
dir.create(your_article_folder <- file.path(tempdir(), "tempdir"))
x <- file.copy(from = article_dir, to = your_article_folder,recursive = TRUE,)
your_article_path <- paste(your_article_folder,"article",sep="/")
expect_equal(texor::find_wrapper(your_article_path),"RJwrapper.tex")
unlink(your_article_folder,recursive = TRUE)
})
2 changes: 1 addition & 1 deletion tests/testthat/test-rnw-tools.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ test_that("Convert Rnw to Rmd", {
x <- file.copy(from = article_dir, to = your_article_folder,recursive = TRUE)
your_article_path <- paste(your_article_folder, "sweave_article", "example.Rnw",sep="/")
your_article_path <- xfun::normalize_path(your_article_path)
expect_equal(texor::rnw_to_rmd(your_article_path, output_format = "bookdown", clean_up = TRUE, autonumber_sec = FALSE), texor::pandoc_version_check())
expect_equal(suppressMessages(texor::rnw_to_rmd(your_article_path, output_format = "bookdown", clean_up = TRUE, autonumber_sec = FALSE)), texor::pandoc_version_check())
# expect_equal(file.exists(
# xfun::normalize_path(
# paste(your_article_folder, "sweave_article", "example.Rmd", sep="/"))),
Expand Down

0 comments on commit e7b0389

Please sign in to comment.