Skip to content

Commit

Permalink
Adding (very simple) tests for encounter_creator and reroll funct…
Browse files Browse the repository at this point in the history
…ions (input testing handled by tests of upstream functions so only output testing is needed)
  • Loading branch information
njlyon0 committed May 3, 2024
1 parent 802a10d commit 0af47d8
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/testthat/test-encounter_creator.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Run all tests in this script:
## testthat::test_file(file.path("tests", "testthat", "test-encounter_creator.R"))

# # Error testing
# test_that("Errors work as desired", {
# All inputs received from/tested in `xp_pool` and/or `xp_cost`
# })

# # Warning testing
# test_that("Warnings work as desired", {
# # No warnings in this function
# })

# # Message testing
# test_that("Messages work as desired", {
# # No messages in this function
# })

# Output testing
test_that("Outputs are as expected", {
my_battle <- encounter_creator(party_level = 10, party_size = 4, difficulty = "hard")
expect_equal(class(my_battle), c("tbl_df", "tbl", "data.frame"))
})
26 changes: 26 additions & 0 deletions tests/testthat/test-reroll.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Run all tests in this script:
## testthat::test_file(file.path("tests", "testthat", "test-reroll.R"))

# NO INPUT TESTS CURRENTLY NEEDED
## `reroll` is only used inside of `roll` so it is not possible for it receive improper inputs

# # Error testing
# test_that("Errors work as desired", {
# All inputs received from/tested in `roll`
# })

# # Warning testing
# test_that("Warnings work as desired", {
# # No warnings in this function
# })

# # Message testing
# test_that("Messages work as desired", {
# # No messages in this function
# })

# Output testing
test_that("Outputs are as expected", {
new_values <- reroll(dice_faces = 1, first_result = c(1, 1, 5, 3, 6))
expect_equal(class(new_values), "numeric")
})

0 comments on commit 0af47d8

Please sign in to comment.