tests/testthat/test-bracketXtract.R

context("bracketXtract")

test_that("bracketXtract has base functionality", {
  expect_equal(bracketXtract("(hey there)", "("),
               list("hey there"))
  expect_equal(bracketXtract("(hey there)", "(", with=T),
               list("(hey there)"))
  expect_equal(bracketXtract("[hey there]", "["),
               list("hey there"))
  expect_equal(bracketXtract("[hey there]", "[", with=T),
               list("[hey there]"))
  expect_equal(bracketXtract("{hey there}", "{"),
               list("hey there"))
  expect_equal(bracketXtract("{hey there}", "{", with=T),
               list("{hey there}"))
  expect_equal(bracketXtract("(hey) {there}", "all"),
               list(c("hey", "there")))
  expect_equal(bracketXtract("(hey) {there}", "all", T),
               list(c("(hey)", "{there}")))
})
ecology-rocks/grammaR documentation built on May 15, 2019, 7:58 p.m.