File: example.R

package info (click to toggle)
r-cran-testthat 3.2.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,452 kB
  • sloc: cpp: 9,261; ansic: 37; sh: 14; makefile: 5
file content (24 lines) | stat: -rw-r--r-- 609 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
#' Retrieve paths to built-in example test files
#'
#' `testthat_examples()` retrieves path to directory of test files,
#' `testthat_example()` retrieves path to a single test file.
#'
#' @keywords internal
#' @param filename Name of test file
#' @export
#' @examples
#' dir(testthat_examples())
#' testthat_example("success")
testthat_examples <- function() {
  system.file("examples", package = "testthat")
}

#' @export
#' @rdname testthat_examples
testthat_example <- function(filename) {
  system.file(
    "examples", paste0("test-", filename, ".R"),
    package = "testthat",
    mustWork = TRUE
  )
}