tests/testthat/test-replace_leading_whitespace.R

test_that("Test replacement of leading whitespace", {
  x <- c("Hello there", "  Goodbye Friend ",  "\tNice to meet you", "  \t What are you up to? \t \t ")

  expect_equal(
    replace_leading_whitespace(x),
    c("Hello there", "&nbsp;&nbsp;Goodbye Friend ",
      "&nbsp;&nbsp;&nbsp;&nbsp;Nice to meet you", "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;What are you up to? \t \t ")
  )

  expect_equal(
    replace_leading_whitespace(x, tab=2),
    c("Hello there", "&nbsp;&nbsp;Goodbye Friend ",
      "&nbsp;&nbsp;Nice to meet you", "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;What are you up to? \t \t ")
  )
})

Try the Tplyr package in your browser

Any scripts or data that you put into this service are public.

Tplyr documentation built on May 29, 2024, 10:37 a.m.