tests/testthat/test_escapeContent.R

context("escapeContent")

p <- escapeContent('bla bla { }', escapeBraces_b_1 = TRUE)

test_that("escapeContent", {
  expect_equal(escapeContent('neonira@gmail.com') , 'neonira@@gmail.com')
  expect_equal(escapeContent('neonira@@gmail.com'), 'neonira@@gmail.com')
  expect_equal(escapeContent('neonira@@@gmail.com'), 'neonira@@@@gmail.com')
  expect_equal(escapeContent('neonira@@@@gmail.com'), 'neonira@@@@gmail.com')
  expect_equal(escapeContent('neonira@@@@@gmail.com'), 'neonira@@@@@@gmail.com')
  expect_equal(escapeContent('neonira@@@@@@gmail.com'), 'neonira@@@@@@gmail.com')

  expect_equal(escapeContent('x %% y == 3'), 'x \\%\\% y == 3')
  expect_equal(escapeContent('x \\%% y == 3'), 'x \\%\\% y == 3')
  expect_equal(escapeContent('x %\\% y == 3'), 'x \\%\\% y == 3')
  expect_equal(escapeContent('x \\%\\% y == 3'), 'x \\%\\% y == 3')

  expect_equal(escapeContent('x %\\% y == 3', TRUE), 'x \\%\\% y == 3') # coverage
  expect_equal(escapeContent('x \\%\\% y == 3', TRUE), 'x \\%\\% y == 3') # coverage

  expect_equal(escapeContent('function() { Inf }', TRUE), 'function() \\{ Inf \\}')
  expect_equal(escapeContent('function() \\{ Inf }', TRUE), 'function() \\{ Inf \\}')
  expect_equal(escapeContent('function() { Inf \\}', TRUE), 'function() \\{ Inf \\}')

  expect_equal(p, 'bla bla \\{ \\}')
})

Try the wyz.code.rdoc package in your browser

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

wyz.code.rdoc documentation built on Oct. 6, 2021, 9:07 a.m.