tests/testthat/test-rprintf.R

context("rprintf: general formatting")

test_that("rprintf works as expected", {
    expect_equivalent(rprintf("%s", "a"), "a")
    expect_equivalent(rprintf("$name:s", name = "a"), "a")
    expect_equivalent(rprintf("{1:s}", "a"), "a")
    expect_equivalent(rprintf("$name", name = "a"), "a")
    expect_equivalent(rprintf("{1}", "a"), "a")
    
    p <- list(name = "Ken", age = 25)
    expect_equivalent(rprintf("$name, $age", p), "Ken, 25")
}) 

Try the rprintf package in your browser

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

rprintf documentation built on May 1, 2019, 10:59 p.m.