tests/testthat/test_system_file.R

test_that(
  "system_file works correctly with no inputs",
  {
    actual <- system_file()
    expected <- normalizePath(find.package("base"), "/")
    substring(expected, 1, 1) <- toupper(substring(expected, 1, 1))
    expect_equal(actual, expected)
  }
)

test_that(
  "system_file works correctly with only a package input",
  {
    actual <- system_file(package = "stats")
    expected <- normalizePath(find.package("base"), "/")
  }
)

test_that(
  "system_file works correctly with a file inside the base package",
  {
    actual <- system_file("help", "AnIndex")
    expected <- normalizePath(
      file.path(find.package("base"), "help", "AnIndex"), 
      "/"
    )
  }
)

test_that(
  "system_file works correctly with a file inside another package",
  {
    actual <- system_file("R", "graphics.rdb", package = "graphics")
    expected <- normalizePath(
      file.path(find.package("graphics"), "R", "graphics.rdb"), 
      "/"
    )
  }
)

Try the pathological package in your browser

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

pathological documentation built on May 1, 2019, 10:22 p.m.