File: test-convert.R

package info (click to toggle)
r-cran-pander 0.6.3%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,804 kB
  • sloc: javascript: 301; cpp: 145; lisp: 94; makefile: 21
file content (26 lines) | stat: -rw-r--r-- 722 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
library(testthat)
library(pander)
context('Pandoc.convert')

test_that('openFileInOS works correctly', {
    tf <- paste(tempfile(), '.txt', sep = '')
    sink(file = tf)
    cat('Some info')
    sink()
#    expect_equal(openFileInOS(tf), 0)
    expect_error(openFileInOS('NEWS2'))
    unlink(tf)
})

test_that('Pandoc.convert works correctly', {
    tf <- tempfile()
    cat('% test\n', file = tf)
    sink(tf, append = TRUE)
    pander(mtcars[1:3, 1:4])
    sink()
    res1 <- Pandoc.convert(tf, open = FALSE)
    expect_equal(dirname(tf), dirname(res1))
    res2 <- Pandoc.convert(text = readLines(tf), open = FALSE)
    expect_equal(readLines(res1), readLines(res2)) # text or file gives same result
    unlink(tf)
})