add mt
This commit is contained in:
@@ -1,20 +0,0 @@
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
static int Factorial(int number)
|
||||
{
|
||||
// return number <= 1 ? number : Factorial(number - 1) * number; // fail
|
||||
return number <= 1 ? 1 : Factorial(number - 1) * number; // pass
|
||||
}
|
||||
|
||||
TEST_CASE("[base_test_fib] Factorial of 0 is 1 (fail)", "[single-file]")
|
||||
{
|
||||
REQUIRE(Factorial(0) == 1);
|
||||
}
|
||||
|
||||
TEST_CASE("[base_test_fib] Factorials of 1 and higher are computed (pass)", "[single-file]")
|
||||
{
|
||||
REQUIRE(Factorial(1) == 1);
|
||||
REQUIRE(Factorial(2) == 2);
|
||||
REQUIRE(Factorial(3) == 6);
|
||||
REQUIRE(Factorial(10) == 3628800);
|
||||
}
|
||||
@@ -2,4 +2,5 @@ catch2_with_main_dep = dependency('catch2-with-main')
|
||||
dep = [hack_dep, catch2_with_main_dep]
|
||||
|
||||
test('patterns', executable('patterns', ['patterns/ring_buffer.cpp'], dependencies : dep))
|
||||
test('mt', executable('mt', ['mt/max.cpp'], dependencies : dep))
|
||||
|
||||
|
||||
13
tests/mt/max.cpp
Normal file
13
tests/mt/max.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#include "catch2/catch_test_macros.hpp"
|
||||
#include "hack/mt/algorithms/max.hpp"
|
||||
|
||||
TEST_CASE("mt")
|
||||
{
|
||||
SECTION("max buffer")
|
||||
{
|
||||
int a = 4, b = 5;
|
||||
int& c = a;
|
||||
REQUIRE(hack::mt::algorithms::max(4, 5) == 5);
|
||||
REQUIRE(hack::mt::algorithms::max(c, b) == 5);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user