summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAotrix <[email protected]>2025-10-23 21:28:51 +0200
committerAotrix <[email protected]>2025-10-23 21:28:51 +0200
commit22f0f64d883f4d5322d8ae071197ee24227262d2 (patch)
treea2959702f19fb309647f5bd3c2ba5830bc1cc378 /src
parent49adba52cc9238ba35afaa1d78cf67770ecf0ca4 (diff)
added an example of test
Diffstat (limited to 'src')
-rw-r--r--src/tests/tests.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/tests/tests.cpp b/src/tests/tests.cpp
index e69de29..d1a037b 100644
--- a/src/tests/tests.cpp
+++ b/src/tests/tests.cpp
@@ -0,0 +1,16 @@
+#include <catch2/benchmark/catch_benchmark.hpp>
+#include <catch2/catch_test_macros.hpp>
+
+#include <cstdint>
+
+uint64_t fibonacci(uint64_t number) { return number < 2 ? number : fibonacci(number - 1) + fibonacci(number - 2); }
+
+TEST_CASE("Benchmark Fibonacci", "[fibonacci]") {
+ REQUIRE(fibonacci(5) == 5);
+
+ REQUIRE(fibonacci(20) == 6'765);
+ BENCHMARK("fibonacci 20") { return fibonacci(20); };
+
+ REQUIRE(fibonacci(25) == 75'025);
+ BENCHMARK("fibonacci 25") { return fibonacci(25); };
+}