From fb5bf9d733a92026c96b5135183a30fa257ba47e Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Fri, 9 Aug 2024 12:47:44 -0400 Subject: [PATCH] A quick and dirty test with doctest. Should be good enough. --- meson.build | 5 +++++ tests/test1.cpp | 11 +++++++++++ 2 files changed, 16 insertions(+) create mode 100644 tests/test1.cpp diff --git a/meson.build b/meson.build index 52cfb16..a011829 100644 --- a/meson.build +++ b/meson.build @@ -20,6 +20,7 @@ fmt = dependency('fmt') ftxui_screen = dependency('ftxui-screen') ftxui_dom = dependency('ftxui-dom') ftxui_component = dependency('ftxui-component') +doctest = dependency('doctest') dependencies = [ fmt, libgit2package_dep, efsw_dep, @@ -38,3 +39,7 @@ executable('ftxtest', 'ftxtest.cpp', executable('ftx_thread_test', 'ftx_thread_test.cpp', dependencies: dependencies) + +executable('tests', [ + 'tests/test1.cpp'], + dependencies: dependencies + [doctest]) diff --git a/tests/test1.cpp b/tests/test1.cpp new file mode 100644 index 0000000..5406cd1 --- /dev/null +++ b/tests/test1.cpp @@ -0,0 +1,11 @@ +#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN +#include "doctest.h" + +int factorial(int number) { return number <= 1 ? number : factorial(number - 1) * number; } + +TEST_CASE("testing the factorial function") { + CHECK(factorial(1) == 1); + CHECK(factorial(2) == 2); + CHECK(factorial(3) == 6); + CHECK(factorial(10) == 3628800); +}