tests/testthat/test-vec2string.R

context("vec2string")

test_that("vec2string works", {

    expect_equal(vec2string(NULL), "")
    expect_equal(vec2string("a"), "a")
    expect_equal(vec2string(c("a", "b")), "a and b")
    expect_equal(vec2string(c("a", "b", "c", "d")), "a, b, c, and d")

    expect_equal(vec2string(NULL, "or"), "")
    expect_equal(vec2string("a", "or"), "a")
    expect_equal(vec2string(c("a", "b"), "or"), "a or b")
    expect_equal(vec2string(c("a", "b", "c", "d"), "or"), "a, b, c, or d")

})

Try the broman package in your browser

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

broman documentation built on July 8, 2022, 5:07 p.m.