From 460df039393bb914660a740375bbf3134897c051 Mon Sep 17 00:00:00 2001 From: wlandau Date: Thu, 12 Oct 2023 13:47:43 -0400 Subject: [PATCH] tests --- tests/testthat/test-tar_seed_create.R | 15 ++++++++++++++ tests/testthat/test-utils_digest.R | 29 --------------------------- 2 files changed, 15 insertions(+), 29 deletions(-) diff --git a/tests/testthat/test-tar_seed_create.R b/tests/testthat/test-tar_seed_create.R index ac0bd851a..86f6f7e7d 100644 --- a/tests/testthat/test-tar_seed_create.R +++ b/tests/testthat/test-tar_seed_create.R @@ -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", { @@ -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", { diff --git a/tests/testthat/test-utils_digest.R b/tests/testthat/test-utils_digest.R index a9e507b7b..ae97b613c 100644 --- a/tests/testthat/test-utils_digest.R +++ b/tests/testthat/test-utils_digest.R @@ -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) - } -})