boB Rudis
5 years ago
6 changed files with 38 additions and 47 deletions
@ -0,0 +1,13 @@ |
|||
library(ndjson) |
|||
|
|||
f <- system.file("extdata", "test.json", package="ndjson") |
|||
expect_true(validate(f)) |
|||
expect_equal(nrow(stream_in(f)), 100) |
|||
expect_true(inherits(stream_in(f), "tbl_dt")) |
|||
expect_true(inherits(stream_in(f, "tbl"), "tbl_df")) |
|||
|
|||
gzf <- system.file("extdata", "testgz.json.gz", package="ndjson") |
|||
expect_true(validate(gzf)) |
|||
expect_equal(nrow(stream_in(gzf)), 100) |
|||
expect_true(inherits(stream_in(gzf), "tbl_dt")) |
|||
expect_true(inherits(stream_in(gzf, "tbl"), "tbl_df")) |
@ -1,2 +0,0 @@ |
|||
library(testthat) |
|||
test_check("ndjson") |
@ -1,21 +0,0 @@ |
|||
context("uncompressed files (validation and streaming)") |
|||
test_that("validation and streaming works in uncompressed files (validation and streaming)", { |
|||
|
|||
f <- system.file("extdata", "test.json", package="ndjson") |
|||
expect_that(validate(f), equals(TRUE)) |
|||
expect_that(nrow(stream_in(f)), equals(100)) |
|||
expect_that(stream_in(f), is_a("tbl_dt")) |
|||
expect_that(stream_in(f, "tbl"), is_a("tbl_df")) |
|||
|
|||
}) |
|||
|
|||
context("compressed files (validation and streaming)") |
|||
test_that("validation and streaming works in compressed files", { |
|||
|
|||
gzf <- system.file("extdata", "testgz.json.gz", package="ndjson") |
|||
expect_that(validate(gzf), equals(TRUE)) |
|||
expect_that(nrow(stream_in(gzf)), equals(100)) |
|||
expect_that(stream_in(gzf), is_a("tbl_dt")) |
|||
expect_that(stream_in(gzf, "tbl"), is_a("tbl_df")) |
|||
|
|||
}) |
@ -0,0 +1,3 @@ |
|||
if ( requireNamespace("tinytest", quietly=TRUE) ){ |
|||
tinytest::test_package("ndjson") |
|||
} |
Loading…
Reference in new issue