File: test-block.R

package info (click to toggle)
r-cran-usethis 3.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,228 kB
  • sloc: sh: 26; makefile: 17; cpp: 6; ansic: 3
file content (18 lines) | stat: -rw-r--r-- 522 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
test_that("block_append() only writes unique lines", {

  path <- withr::local_tempfile()
  writeLines(block_create(), path)

  block_append("---", c("x", "y"), path)
  block_append("---", c("y", "x"), path)
  expect_equal(block_show(path), c("x", "y"))
})

test_that("block_append() can sort, if requested", {
  path <- withr::local_tempfile()
  writeLines(block_create(), path)

  block_append("---", c("z", "y"), path)
  block_append("---", "x", path, sort = TRUE)
  expect_equal(block_show(path), c("x", "y", "z"))
})