Debian Codegraph @

inst/tests/test-convert.R

raw
1 library(testthat)
2 library(pander)
3 context('Pandoc.convert')
4
5 test_that('openFileInOS works correctly', {
6 tf <- paste(tempfile(), '.txt', sep = '')
7 sink(file = tf)
8 cat('Some info')
9 sink()
10 # expect_equal(openFileInOS(tf), 0)
11 expect_error(openFileInOS('NEWS2'))
12 unlink(tf)
13 })
14
15 test_that('Pandoc.convert works correctly', {
16 tf <- tempfile()
17 cat('% test\n', file = tf)
18 sink(tf, append = TRUE)
19 pander(mtcars[1:3, 1:4])
20 sink()
21 res1 <- Pandoc.convert(tf, open = FALSE)
22 expect_equal(dirname(tf), dirname(res1))
23 res2 <- Pandoc.convert(text = readLines(tf), open = FALSE)
24 expect_equal(readLines(res1), readLines(res2)) # text or file gives same result
25 unlink(tf)
26 })