Skip to content

Commit

Permalink
test: add unit test binary data manipulation with an offset
Browse files Browse the repository at this point in the history
  • Loading branch information
sgibb committed Mar 15, 2023
1 parent 0bd3ebe commit 5494f27
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/testthat/test_OnDiskVector-class.R
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,16 @@ test_that("[", {
expect_equal((odv2[] <- 21:30)[1:10], 21:30)

expect_error(odv2[] <- 1:30, "Length")

f <- file(fn, "wb")
writeBin(as.double(1:30), f, size=4L, endian="little")
close(f)

odv3 <- OnDiskVector(path=fn, offset=4L * 10L, n=10L, size=4L)
expect_equal(odv3[], 11:20)
odv3[] <- -(11:20)
f <- file(fn, "rb")
fc <- readBin(fn, what="double", size=4L, endian="little", n=30)
close(f)
expect_equal(fc, c(1:10, -(11:20), 21:30))
})

0 comments on commit 5494f27

Please sign in to comment.