tests/testthat/test-get_path_info.R

# WARNING - Generated by {fusen} from dev/flat_utils.Rmd: do not edit by hand # nolint: line_length_linter.

test_that("get_path_info extracts names and segments", {
  p <- c("C:/Users/foo/report.xlsx", "/home/u/.bashrc", "rel/a/b.tar.gz", NA)
  expect_identical(get_path_info(p), c("report", ".bashrc", "b.tar", NA))
  expect_identical(get_path_info(p, n = 1), c("Users", "home", "rel", NA))
  expect_identical(get_path_info(p, n = c(-2, -1)),
                   c("foo/report.xlsx", "u/.bashrc", "a/b.tar.gz", NA))
})

test_that("get_path_info keeps absolute paths absolute", {
  p <- c("/a/b.txt", "C:\\x\\y.csv", "\\\\srv\\share\\f.r", "rel/z.gz")
  expect_identical(get_path_info(p, rm_path = FALSE),
                   c("/a/b", "C:/x/y", "//srv/share/f", "rel/z"))
})

test_that("get_path_info validates n", {
  expect_error(get_path_info("a/b", n = NA), "without NA")
  expect_error(get_path_info("a/b", n = 0), "must not contain 0")
})

Try the mintyr package in your browser

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

mintyr documentation built on Oct. 5, 2026, 5:08 p.m.