Added catch2 and cmakelists to test project, also translated math/mod tests to catch2
This commit is contained in:
parent
171b23d9c3
commit
ebdf8b85dd
15
Test/CMakeLists.txt
Normal file
15
Test/CMakeLists.txt
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
project(Tests)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
|
include_directories(..)
|
||||||
|
link_directories(../Eule/cmake-build-debug)
|
||||||
|
|
||||||
|
add_executable(Tests
|
||||||
|
Catch2.h
|
||||||
|
main.cpp
|
||||||
|
Math__Mod.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(Tests Eule)
|
17965
Test/Catch2.h
Normal file
17965
Test/Catch2.h
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,8 +1,7 @@
|
|||||||
#include "CppUnitTest.h"
|
#include "Catch2.h"
|
||||||
#include "../Eule/Math.h"
|
#include <Eule/Math.h>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
|
||||||
using namespace Eule;
|
using namespace Eule;
|
||||||
|
|
||||||
/** Equivalence classes:
|
/** Equivalence classes:
|
||||||
@ -20,64 +19,53 @@ using namespace Eule;
|
|||||||
* -- a = 0 && b = 0
|
* -- a = 0 && b = 0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace _Math
|
|
||||||
{
|
|
||||||
TEST_CLASS(_Mod)
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// a > 0 && b > 0
|
// a > 0 && b > 0
|
||||||
TEST_METHOD(a_gt_0_and_b_gt_0)
|
TEST_CASE(__FILE__"/a_gt_0_and_b_gt_0", "[Math][Mod]")
|
||||||
{
|
{
|
||||||
Assert::AreEqual(7, Math::Mod(199, 32));
|
REQUIRE(Math::Mod(199, 32) == 7);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// a < 0 && b > 0
|
// a < 0 && b > 0
|
||||||
TEST_METHOD(a_lt_0_and_b_gt_0)
|
TEST_CASE(__FILE__"/a_lt_0_and_b_gt_0", "[Math][Mod]")
|
||||||
{
|
{
|
||||||
Assert::AreEqual(25, Math::Mod(-199, 32));
|
REQUIRE(Math::Mod(-199, 32) == 25);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// a > 0 && b < 0
|
// a > 0 && b < 0
|
||||||
TEST_METHOD(a_gt_0_and_b_lt_0)
|
TEST_CASE(__FILE__"/a_gt_0_and_b_lt_0", "[Math][Mod]")
|
||||||
{
|
{
|
||||||
Assert::AreEqual(-25, Math::Mod(199, -32));
|
REQUIRE(Math::Mod(199, -32) == -25);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// a > 0 && b = 0
|
// a > 0 && b = 0
|
||||||
TEST_METHOD(a_gt_0_and_b_eq_0)
|
TEST_CASE(__FILE__"/a_gt_0_and_b_eq_0", "[Math][Mod]")
|
||||||
{
|
{
|
||||||
// Exppect divide-by-zero
|
// Exppect divide-by-zero
|
||||||
Assert::ExpectException<std::logic_error&>([]() {
|
REQUIRE_THROWS_AS(Math::Mod(-199, 0), std::logic_error);
|
||||||
Assert::AreEqual(0, Math::Mod(199, 0));
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// a = 0 && b > 0
|
// a = 0 && b > 0
|
||||||
TEST_METHOD(a_eq_0_and_b_gt_0)
|
TEST_CASE(__FILE__"/a_eq_0_and_b_gt_0", "[Math][Mod]")
|
||||||
{
|
{
|
||||||
Assert::AreEqual(0, Math::Mod(0, 32));
|
REQUIRE(Math::Mod(0, 32) == 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// a < 0 && b = 0
|
// a < 0 && b = 0
|
||||||
TEST_METHOD(a_lt_0_and_b_eq_0)
|
TEST_CASE(__FILE__"/a_lt_0_and_b_eq_0", "[Math][Mod]")
|
||||||
{
|
{
|
||||||
// Exppect divide-by-zero
|
// Expect divide-by-zero
|
||||||
Assert::ExpectException<std::logic_error&>([]() {
|
REQUIRE_THROWS_AS(Math::Mod(-199, 0), std::logic_error);
|
||||||
Assert::AreEqual(0, Math::Mod(-199, 0));
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// a = 0 && b < 0
|
// a = 0 && b < 0
|
||||||
TEST_METHOD(a_eq_0_and_b_lt_0)
|
TEST_CASE(__FILE__"/a_eq_0_and_b_lt_0", "[Math][Mod]")
|
||||||
{
|
{
|
||||||
Assert::AreEqual(0, Math::Mod(0, -32));
|
REQUIRE(Math::Mod(0, -32) == 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
}
|
|
||||||
|
2
Test/main.cpp
Normal file
2
Test/main.cpp
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
#define CATCH_CONFIG_MAIN
|
||||||
|
#include "Catch2.h"
|
Loading…
x
Reference in New Issue
Block a user