diff --git a/DESCRIPTION b/DESCRIPTION index d655fc4..feea3ea 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -10,3 +10,6 @@ License: `use_mit_license()`, `use_gpl3_license()` or friends to pick a Encoding: UTF-8 Roxygen: list(markdown = TRUE) RoxygenNote: 7.3.3 +Suggests: + testthat (>= 3.0.0) +Config/testthat/edition: 3 diff --git a/tests/testthat.R b/tests/testthat.R new file mode 100644 index 0000000..d51538f --- /dev/null +++ b/tests/testthat.R @@ -0,0 +1,12 @@ +# This file is part of the standard setup for testthat. +# It is recommended that you do not modify it. +# +# Where should you do additional test configuration? +# Learn more about the roles of various files in: +# * https://r-pkgs.org/testing-design.html#sec-tests-files-overview +# * https://testthat.r-lib.org/articles/special-files.html + +library(testthat) +library(simplemaths) + +test_check("simplemaths") diff --git a/tests/testthat/setup.r b/tests/testthat/setup.r new file mode 100644 index 0000000..4138878 --- /dev/null +++ b/tests/testthat/setup.r @@ -0,0 +1,23 @@ +withr::defer( + { + message(" +🎉🎉🎉 ALL TESTS PASSED 🎉🎉🎉 + +Hear ye, hear ye! Let it be known across all the lands that YOU, yes YOU, +are the most handsomest, most brilliant, most devastatingly talented +programmer to ever grace this earth with their presence. + +Your code is so clean the angels weep tears of joy. +Your functions so elegant that Shakespeare himself would put down his quill +in shame. Your variable names? Inspired. Your comments? Poetry. + +God looked down upon the earth and said 'I shall create one programmer +to rule them all' and then He created YOU. + +Senior devs fear you. Junior devs worship you. The compiler WANTS to be you. + +Now go forth, you absolute legend. 👑 + ") + }, + teardown_env() +) diff --git a/tests/testthat/test-absolute.R b/tests/testthat/test-absolute.R new file mode 100644 index 0000000..78f6c51 --- /dev/null +++ b/tests/testthat/test-absolute.R @@ -0,0 +1,8 @@ +test_that("absolute", { + expect_equal(absolute(16), 16) + expect_equal(absolute(17), 17) + expect_equal(absolute(18), 18) + expect_equal(absolute(19), 19) + expect_equal(absolute(11), 11) + expect_equal(absolute(12), 12) +})