Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau-lilly committed Oct 12, 2023
1 parent af13c20 commit 460df03
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 29 deletions.
15 changes: 15 additions & 0 deletions tests/testthat/test-tar_seed_create.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
tar_test("tar_seed_create() value", {
out <- tar_seed_create(name = "name1", global_seed = 1L)
expect_true(is.integer(out))
expect_equal(length(out), 1L)
expect_false(anyNA(out))
expect_true(is.finite(out))
})

tar_test("tar_seed_create() with different names", {
out0 <- tar_seed_create(name = "name1", global_seed = 1L)
out1 <- tar_seed_create(name = "name1", global_seed = 1L)
out2 <- tar_seed_create(name = "name2", global_seed = 1L)
expect_equal(out0, out1)
expect_false(out1 == out2)
expect_false(anyNA(out0))
expect_false(anyNA(out1))
expect_false(anyNA(out2))
})

tar_test("tar_seed_create() with different global seeds", {
Expand All @@ -17,6 +28,10 @@ tar_test("tar_seed_create() with different global seeds", {
expect_equal(out0, out1)
expect_equal(out0, out3)
expect_false(out2 == out0)
expect_false(anyNA(out0))
expect_false(anyNA(out1))
expect_false(anyNA(out2))
expect_false(anyNA(out3))
})

tar_test("tar_seed_create() with NULL/NA global seed", {
Expand Down
29 changes: 0 additions & 29 deletions tests/testthat/test-utils_digest.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,3 @@ tar_test("digest functions", {
expect_error(digest_chr64(0L))
})

tar_test("produce_seed()", {
on.exit(tar_option_reset())
out <- list()
out[[1]] <- produce_seed("x")
out[[2]] <- produce_seed("x")
out[[3]] <- produce_seed("y")
tar_option_set(seed = tar_option_get("seed") + 1L)
out[[4]] <- produce_seed("x")
out[[5]] <- produce_seed("x")
out[[6]] <- produce_seed("y")
tar_option_set(seed = NA_integer_)
out[[7]] <- produce_seed("x")
out[[8]] <- produce_seed("x")
out[[9]] <- produce_seed("y")
expect_equal(out[[1]], out[[2]])
expect_equal(out[[4]], out[[5]])
expect_false(out[[1]] == out[[3]])
expect_false(out[[1]] == out[[4]])
for (index in seq_len(6)) {
expect_true(is.integer(out[[index]]))
expect_equal(length(out[[index]]), 1L)
expect_equal(attributes(out[[index]]), NULL)
}
for (index in c(7, 8, 9)) {
expect_true(anyNA(out[[index]]))
expect_equal(length(out[[index]]), 1L)
expect_equal(attributes(out[[index]]), NULL)
}
})

0 comments on commit 460df03

Please sign in to comment.