Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/tests/SelfTest
diff options
context:
space:
mode:
authorMartin Hořeňovský2022-10-18 10:44:10 +0200
committerMartin Hořeňovský2022-10-18 10:44:18 +0200
commit77f7c0104dbaa43c31e75147cfdbd4142484914b (patch)
tree09c57fc635507e09a43d8cfa5153bf2b36632850 /tests/SelfTest
parentbe060cde446d6a890469a5254926e45c165153c5 (diff)
downloadcatch3-77f7c0104dbaa43c31e75147cfdbd4142484914b.tar.gz
Fix fibonacci impl in benchmark tests
The previous implementation was always 1 number ahead. Fixing this is not important at all, but it was bugging me.
Diffstat (limited to 'tests/SelfTest')
-rw-r--r--tests/SelfTest/UsageTests/Benchmark.tests.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/tests/SelfTest/UsageTests/Benchmark.tests.cpp b/tests/SelfTest/UsageTests/Benchmark.tests.cpp
index ffedc9a2..275611fd 100644
--- a/tests/SelfTest/UsageTests/Benchmark.tests.cpp
+++ b/tests/SelfTest/UsageTests/Benchmark.tests.cpp
@@ -16,21 +16,23 @@
namespace {
std::uint64_t Fibonacci(std::uint64_t number) {
- return number < 2 ? 1 : Fibonacci(number - 1) + Fibonacci(number - 2);
+ return number < 2 ? number : Fibonacci(number - 1) + Fibonacci(number - 2);
}
}
TEST_CASE("Benchmark Fibonacci", "[!benchmark]") {
- CHECK(Fibonacci(0) == 1);
+ CHECK(Fibonacci(0) == 0);
// some more asserts..
- CHECK(Fibonacci(5) == 8);
+ CHECK(Fibonacci(5) == 5);
// some more asserts..
- BENCHMARK("Fibonacci 20") {
+ REQUIRE( Fibonacci( 20 ) == 6'765 );
+ BENCHMARK( "Fibonacci 20" ) {
return Fibonacci(20);
};
- BENCHMARK("Fibonacci 25") {
+ REQUIRE( Fibonacci( 25 ) == 75'025 );
+ BENCHMARK( "Fibonacci 25" ) {
return Fibonacci(25);
};