##
## 1. typical use
##
tstVec <- c('Now', 'is', 'the', 'time')
msg <- createMessage(tstVec, 9, collapse=':',
endchars='//')
stopifnot(
all.equal(msg, 'Now:is://')
)
##
## 2. in a function
##
tstFn <- function(cl)createMessage(deparse(cl), 9)
Cl <- quote(plot(1:3, y=4:6, col='red', main='Title'))
msg0 <- tstFn(Cl)
# check
msg. <- 'plot(1...'
stopifnot(
all.equal(msg0, msg.)
)
##
## 3. default
##
y <- createMessage(character(3), default='y')
stopifnot(
all.equal(y, 'y')
)
Run the code above in your browser using DataLab