tests/testthat/test_paste.R

context("Test string pasting")

test_that("Single strings can be pasted",{
  result <- rope:::string_paste_single("foo", "bar")
  expect_that(result, equals("foobar"))
})

test_that("Single strings can be pasted with custom separators",{
  result <- rope:::string_paste_single("foo", "bar", "baz")
  expect_that(result, equals("foobazbar"))
})

test_that("Multiple strings can be pasted",{
  result <- rope:::string_paste_vector(c("foo", "bar"), c("baz", "qux"))
  expect_that(result, equals(c("foobaz", "barqux")))
})

test_that("Multiple strings can be pasted with a custom separator",{
  result <- rope:::string_paste_vector(c("foo", "bar"), c("baz", "qux"), "+")
  expect_that(result, equals(c("foo+baz", "bar+qux")))
})

test_that("Multiple strings can be pasted with a single y value",{
  result <- rope:::string_paste_vector(c("foo", "bar"), "baz")
  expect_that(result, equals(c("foobaz", "barbaz")))
})

test_that("Multiple strings can be pasted with a single y value and a custom separator",{
  result <- rope:::string_paste_vector(c("foo", "bar"), "baz", "+")
  expect_that(result, equals(c("foo+baz", "bar+baz")))
})

test_that("Errors are thrown correctly in string pasting",{
  expect_error(rope:::string_paste_vector(c("foo", "bar","baz"), c("foo","bar")))
})
PeteHaitch/rope documentation built on May 8, 2019, 1:32 a.m.