tests/testthat/test-rd-markdown.R

test_that("generic keys produce expected output", {
  out <- roc_proc_text(rd_roclet(), "
    #' @title a
    #' @note test
    #' @author test
    #' @seealso test
    #' @references test
    #' @name a
    NULL")[[1]]
  expect_equal(out$get_value("references"), "test")
  expect_equal(out$get_value("note"), "test")
  expect_equal(out$get_value("seealso"), "test")
  expect_equal(out$get_value("author"), "test")
})

# format ------------------------------------------------------------------


test_that("@format overrides defaults", {
  out <- roc_proc_text(rd_roclet(), "
    #' Title
    #'
    #' @format abc
    #'
    x <- list(a = 1, b = 2)")[[1]]

  expect_equal(out$get_value("format"), "abc")
})

test_that("@format NULL suppresses default usage", {
  out <- roc_proc_text(rd_roclet(), "
    #' Title
    #'
    #' @format NULL
    x <- list(a = 1, b = 2)")[[1]]

  expect_equal(out$get_value("format"), NULL)
})

test_that("@format not escaped", {
  out <- roc_proc_text(rd_roclet(), "
    #' Title
    #' @format %
    x <- list(a = 1, b = 2)")[[1]]

  expect_equal(out$get_value("format"), "%")
  expect_equal(out$get_rd("format"), "\\format{\n%\n}")
})

Try the roxygen2 package in your browser

Any scripts or data that you put into this service are public.

roxygen2 documentation built on Sept. 8, 2021, 9:08 a.m.