File: test-strings.R

package info (click to toggle)
r-cran-prettycode 1.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 408 kB
  • sloc: sh: 13; makefile: 2
file content (33 lines) | stat: -rw-r--r-- 592 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

context("replace_in_place")

test_that("replace_in_place", {

  expect_equal(
    replace_in_place("1234567890", c(2, 6), c(5, 8), c("foobar", "xxx")),
    "1foobarxxx90"
  )

  expect_equal(
    replace_in_place("1234567890", c(1, 5), c(6, 10), c("A", "B")),
    "AB"
  )
})

test_that("replace_in_place corner cases", {

  expect_equal(
    replace_in_place("foobar", integer(), integer(), character()),
    "foobar"
  )

  expect_equal(
    replace_in_place("12345", 1L, 5L, "no!"),
    "no!"
  )

  expect_equal(
    replace_in_place("12345", 1:5, 1:5, letters[1:5]),
    "abcde"
  )
})