From 7beaff3db976ea1a865eacf6672e4a3f390f2313 Mon Sep 17 00:00:00 2001 From: njlyon0 Date: Fri, 3 May 2024 16:56:11 -0400 Subject: [PATCH] Unit tests for `monster_creator` --- tests/testthat/test-monster_creator.R | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tests/testthat/test-monster_creator.R diff --git a/tests/testthat/test-monster_creator.R b/tests/testthat/test-monster_creator.R new file mode 100644 index 0000000..6cb5e25 --- /dev/null +++ b/tests/testthat/test-monster_creator.R @@ -0,0 +1,26 @@ +# Run all tests in this script: +## testthat::test_file(file.path("tests", "testthat", "test-monster_creator.R")) + +# Error testing +test_that("Errors work as desired", { + expect_error(monster_creator(party_level = NULL, party_size = NULL)) + expect_error(monster_creator(party_level = 6, party_size = NULL)) + expect_error(monster_creator(party_level = NULL, party_size = 4)) + expect_error(monster_creator(party_level = "six", party_size = 4)) + expect_error(monster_creator(party_level = 6, party_size = "four")) +}) + +# # 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", { + expect_equal(class(monster_creator(party_level = 4, party_size = 4)), "data.frame") +})