Added an example test case

This commit is contained in:
Quinn Henthorne
2024-12-10 16:49:31 -05:00
parent 175c0354f8
commit ebdf279a5e
2 changed files with 29 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
cmake_minimum_required (VERSION 3.11)
project ("test_driver")
include(FetchContent)
FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v3.0.1 # or a later release
)
FetchContent_MakeAvailable(Catch2)
add_executable(tests matrix-tests.cpp)
target_link_libraries(tests PRIVATE Catch2::Catch2WithMain)

View File

@@ -0,0 +1,12 @@
#include <catch2/catch_test_macros.hpp>
unsigned int Factorial(unsigned int number) {
return number <= 1 ? number : Factorial(number - 1) * number;
}
TEST_CASE("Factorials are computed", "[factorial]") {
REQUIRE(Factorial(1) == 1);
REQUIRE(Factorial(2) == 2);
REQUIRE(Factorial(3) == 6);
REQUIRE(Factorial(10) == 3628800);
}