Debian Codegraph @

tests/testthat/test-path.R

raw
1
2 test_that("renv_path_absolute() reports common absolute paths", {
3
4 abs <- c(
5 "/path/to/file",
6 "~/path/to/file",
7 "C:/path/to/file",
8 "C:\\path\\to\\file",
9 "\\\\server\\path\\to\\file"
10 )
11
12 rel <- c(
13 "path/to/file",
14 "./path/to/file",
15 "../path/to/file",
16 "::/weird/path"
17 )
18
19 for (path in abs)
20 expect_true(renv_path_absolute(path))
21
22 for (path in rel)
23 expect_false(renv_path_absolute(path))
24
25 })
26
27 test_that("renv_path_normalize() normalizes relative paths that don't exist", {
28
29 prefix <- renv_path_normalize(".", mustWork = TRUE)
30 path <- "i/dont/exist"
31
32 actual <- renv_path_normalize(path)
33 expected <- paste(prefix, "i/dont/exist", sep = "/")
34 expect_equal(actual, expected)
35
36 })