Skip to content

Commit

Permalink
DAMP > DRY: define a function and use it in all tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
maelle committed Jan 13, 2023
1 parent 381f244 commit 9cc0893
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tests/testthat/helper-swamp.R
@@ -1 +1,3 @@
test_object <- list(a = 1, b = 2)
basic_list <- function() {
list(a = 1, b = 2)
}
2 changes: 2 additions & 0 deletions tests/testthat/test-ok.R
@@ -1,7 +1,9 @@
test_that("division works", {
test_object <- basic_list()
expect_equal(test_object[["b"]] / 2, 1)
})

test_that("substraction works", {
test_object <- basic_list()
expect_equal(test_object[["a"]] - 1, 0)
})
2 changes: 2 additions & 0 deletions tests/testthat/test-works.R
@@ -1,7 +1,9 @@
test_that("multiplication works", {
test_object <- basic_list()
expect_equal(test_object[["b"]] * 2, 4)
})

test_that("addition works", {
test_object <- basic_list()
expect_equal(test_object[["a"]] + 2, 3)
})

0 comments on commit 9cc0893

Please sign in to comment.