Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions R/print.data.table.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ print.data.table = function(x, topn=getOption("datatable.print.topn"),
# trunc.cols - should only the columns be printed that can fit in the console? (FALSE)
if (!col.names %chin% c("auto", "top", "none"))
stop("Valid options for col.names are 'auto', 'top', and 'none'")
if (length(trunc.cols) != 1L || !is.logical(trunc.cols) || is.na(trunc.cols))
stop("Valid options for trunc.cols are TRUE and FALSE")
if (col.names == "none" && class)
warning("Column classes will be suppressed when col.names is 'none'")
if (!shouldPrint(x)) {
Expand Down
7 changes: 7 additions & 0 deletions inst/tests/tests.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -17319,3 +17319,10 @@ if (identical(text, enc2native(text))) { # ensure native encoding can represent
}
test(2167.3, fwrite(dt, csvfile, encoding="nativ"), error="Argument 'encoding' must be")
unlink(csvfile)

# check valid trunc.cols=, #4766
DT = data.table(x = rnorm(10))
test(2168.01, print(DT, trunc.cols = 5L), error=c("Valid options for trunc.cols are TRUE and FALSE"))
test(2168.02, print(DT, trunc.cols = NA), error=c("Valid options for trunc.cols are TRUE and FALSE"))
test(2168.03, print(DT, trunc.cols = "thing"), error=c("Valid options for trunc.cols are TRUE and FALSE"))
test(2168.04, print(DT, trunc.cols = c(TRUE, FALSE)), error=c("Valid options for trunc.cols are TRUE and FALSE"))