Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3781c92
commit d7adc78
Showing
6 changed files
with
50 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,47 @@ | ||
context("Testing write_h5 and read_h5") | ||
|
||
obj <- get_h5_test_data() | ||
if (require("hdf5r")) { | ||
obj <- get_h5_test_data() | ||
|
||
test_that("write_h5 and read_h5 works", { | ||
file <- tempfile() | ||
on.exit(file.remove(file)) | ||
test_that("write_h5 and read_h5 works", { | ||
file <- tempfile() | ||
on.exit(file.remove(file)) | ||
|
||
write_h5(obj, file) | ||
write_h5(obj, file) | ||
|
||
obj2 <- read_h5(file) | ||
obj2 <- read_h5(file) | ||
|
||
testthat::expect_equivalent(obj2, obj) | ||
}) | ||
testthat::expect_equivalent(obj2, obj) | ||
}) | ||
|
||
test_that("test_h5_installation works", { | ||
expect_true(test_h5_installation()) | ||
expect_message(test_h5_installation(detailed = TRUE), "HDF5 test successful") | ||
test_that("test_h5_installation works", { | ||
expect_true(test_h5_installation()) | ||
expect_message(test_h5_installation(detailed = TRUE), "HDF5 test successful") | ||
|
||
expect_output(expect_error(test_h5_installation_write(detailed = TRUE, obj = list(x = print)))) | ||
expect_output(expect_error(test_h5_installation_read(detailed = TRUE, file = tempfile()))) | ||
expect_output(expect_error(test_h5_installation_equal(detailed = TRUE, obj = 1, obj2 = 2))) | ||
}) | ||
expect_output(expect_error(test_h5_installation_write(detailed = TRUE, obj = list(x = print)))) | ||
expect_output(expect_error(test_h5_installation_read(detailed = TRUE, file = tempfile()))) | ||
expect_output(expect_error(test_h5_installation_equal(detailed = TRUE, obj = 1, obj2 = 2))) | ||
}) | ||
|
||
test_that("is_sparse works", { | ||
expect_false(is_sparse(matrix(c(1:10)))) | ||
test_that("is_sparse works", { | ||
expect_false(is_sparse(matrix(c(1:10)))) | ||
|
||
m <- Matrix::Matrix(matrix(c(1:10)), sparse = FALSE) | ||
expect_false(is_sparse(m)) | ||
expect_true(is_sparse(methods::as(m, "CsparseMatrix"))) | ||
expect_false(is_sparse(methods::as(m, "dgeMatrix"))) | ||
}) | ||
m <- Matrix::Matrix(matrix(c(1:10)), sparse = FALSE) | ||
expect_false(is_sparse(m)) | ||
expect_true(is_sparse(methods::as(m, "CsparseMatrix"))) | ||
expect_false(is_sparse(methods::as(m, "dgeMatrix"))) | ||
}) | ||
|
||
|
||
test_that("errors gracefully", { | ||
file <- tempfile() | ||
on.exit(file.remove(file)) | ||
test_that("errors gracefully", { | ||
file <- tempfile() | ||
on.exit(file.remove(file)) | ||
|
||
h5file <- hdf5r::H5File$new(file, mode = "w") | ||
h5file[["a"]] <- 1 | ||
h5file$close_all() | ||
h5file <- hdf5r::H5File$new(file, mode = "w") | ||
h5file[["a"]] <- 1 | ||
h5file$close_all() | ||
|
||
expect_error(read_h5(file), regexp = "Object class not found") | ||
}) | ||
expect_error(read_h5(file), regexp = "Object class not found") | ||
}) | ||
|
||
} |