Skip to content

Commit

Permalink
further test suite fixes for CRAN release
Browse files Browse the repository at this point in the history
  • Loading branch information
leeper committed Feb 1, 2018
1 parent 66ed08a commit b3d112a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 13 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
@@ -1,8 +1,8 @@
Package: rio
Type: Package
Title: A Swiss-Army Knife for Data I/O
Version: 0.5.8
Date: 2018-01-31
Version: 0.5.9
Date: 2018-02-01
Authors@R: c(person("Jason", "Becker", role = "ctb", email = "jason@jbecker.co"),
person("Chung-hong", "Chan", role = "aut", email = "chainsawtiney@gmail.com"),
person("Geoffrey CH", "Chan", role = "ctb", email = "gefchchan@gmail.com"),
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
@@ -1,3 +1,7 @@
# CHANGES TO v0.5.9

* Removed longstanding warnings from the tests of `export()` to fixed-width format.

# CHANGES TO v0.5.8

* Export the `get_ext()` function. (#169)
Expand Down
12 changes: 9 additions & 3 deletions R/export_methods.R
Expand Up @@ -58,9 +58,15 @@ export_delim <- function(file, x, fwrite = TRUE, sep = "\t", row.names = FALSE,
return(sprintf("%i",col))
}
if (is.numeric(col)) {
s <- strsplit(as.character(col), ".", fixed = TRUE)
m1 <- max(nchar(sapply(s, `[`, 1)), na.rm = TRUE)
m2 <- max(nchar(sapply(s, `[`, 2)), na.rm = TRUE)
decimals <- strsplit(as.character(col), ".", fixed = TRUE)
m1 <- max(nchar(unlist(lapply(decimals, `[`, 1))), na.rm = TRUE)
decimals_2 <- unlist(lapply(decimals, `[`, 2))
decimals_2_nchar <- nchar(decimals_2[!is.na(decimals_2)])
if (length(decimals_2_nchar)) {
m2 <- max(decimals_2_nchar, na.rm = TRUE)
} else {
m2 <- 0
}
if (!is.finite(m2)) {
m2 <- digits
}
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test_format_csvy.R
Expand Up @@ -7,12 +7,12 @@ test_that("Export to CSVY", {
})

test_that("Import from CSVY", {
d <- import(system.file("examples", "example.csvy", package = "csvy"))
suppressWarnings(d <- import(system.file("examples", "example.csvy", package = "csvy")))
expect_true(inherits(d, "data.frame"))

d2 <- import(system.file("examples", "example2.csvy", package = "csvy"))
suppressWarnings(d2 <- import(system.file("examples", "example2.csvy", package = "csvy")))
expect_true(all(c("title", "units", "source") %in% names(attributes(d2))))

d3 <- import(system.file("examples", "example3.csvy", package = "csvy"))
suppressWarnings(d3 <- import(system.file("examples", "example3.csvy", package = "csvy")))
expect_true(identical(dim(d3), c(2L, 3L)))
})
5 changes: 0 additions & 5 deletions tests/testthat/test_import_list.R
Expand Up @@ -36,9 +36,6 @@ test_that("Using setclass in import_list()", {
expect_true(inherits(dat1, "data.table"))
dat2 <- import_list(rep("mtcars.rds", 2), setclass = "tbl", rbind = TRUE)
expect_true(inherits(dat2, "tbl"))
expect_warning(dat3 <- import_list(rep("mtcars.rds", 2), setclass = "data.frame", rbind = TRUE, data.table = TRUE))
expect_true(inherits(dat3, "data.frame"))

})

test_that("Object names are preserved by import_list()", {
Expand All @@ -51,11 +48,9 @@ test_that("Object names are preserved by import_list()", {
expected_names <- c("mtcars1", "mtcars2", "mtcars3")
dat_xls <- import_list("mtcars.xlsx")
dat_csv <- import_list(c("mtcars1.csv","mtcars2.tsv","mtcars3.csv"))
dat_html <- import_list(system.file("examples", "twotables.html", package = "rio"))

expect_identical(names(dat_xls), expected_names)
expect_identical(names(dat_csv), expected_names)
expect_identical(names(dat_html), c("mtcars", ""))

unlink(c("mtcars.xlsx", "mtcars1.csv","mtcars2.tsv","mtcars3.csv"))
})
Expand Down

0 comments on commit b3d112a

Please sign in to comment.