diff --git a/R/fread.R b/R/fread.R index b95e0f9b0..fc69f074e 100644 --- a/R/fread.R +++ b/R/fread.R @@ -55,7 +55,7 @@ yaml=FALSE, tmpdir=tempdir(), tz="UTC") else stopifnot( nchar(sep)==1L ) # otherwise an actual character to use as sep } stopifnot( is.character(dec), length(dec)==1L) - if (dec == "auto") dec = "" else stopifnot(nchar(dec) == 1L) + if (identical(dec, "auto")) dec = "" else stopifnot(nchar(dec) == 1L) # handle encoding, #563 if (length(encoding) != 1L || !encoding %chin% c("unknown", "UTF-8", "Latin-1")) { stopf("Argument 'encoding' must be 'unknown', 'UTF-8' or 'Latin-1'.") diff --git a/inst/tests/tests.Rraw b/inst/tests/tests.Rraw index 9f924f773..b83ab8212 100644 --- a/inst/tests/tests.Rraw +++ b/inst/tests/tests.Rraw @@ -21605,3 +21605,6 @@ test(2370.2, yearmon(x, format="numeric"), yearmon(x)) # numeric is the default test(2370.3, yearmon(x, format="character"), c("1111M11", "2019M01", "2019M02", "2019M03", "2019M12", "2020M02", "2020M03", "2020M12", "2040M01", "2040M12", "2100M03", NA_character_)) test(2370.4, yearmon("2016-08-03 01:02:03.45", format="character"), "2016M08") test(2370.5, yearmon(NA, format="character"), NA_character_) + +## validation of dec argument +test(7737.1, fread(input = "whatever.csv", dec = NA_character_), error=base_messages$stopifnot("nchar(dec) == 1L"))