tests/testthat/test_replacement.R

context("Test string replacement")

test_that("instances can be replaced",{
  result <- rope:::string_replace_single("this is a string", "string", "turnip")
  expect_that(result, equals("this is a turnip"))
})

test_that("instances can be replaced in multiple strings",{
  result <- rope:::string_replace_vector(rep("this is a string",3), "string", "turnip")
  expect_that(result, equals(rep("this is a turnip", 3)))
})

test_that("first instances can be replaced",{
  result <- rope:::string_replace_first_single("this is a string string", "string", "turnip")
  expect_that(result, equals("this is a turnip string"))
})

test_that("first instances can be replaced in multiple strings",{
  result <- rope:::string_replace_first_vector(rep("this is a string string",3), "string", "turnip")
  expect_that(result, equals(rep("this is a turnip string", 3)))
})
PeteHaitch/rope documentation built on May 8, 2019, 1:32 a.m.