Added Catch2 tests, moved Age-class to own library
This commit is contained in:
parent
d1d635bd95
commit
a2b85eba83
15 changed files with 79 additions and 4 deletions
17
test/Age.cpp
Normal file
17
test/Age.cpp
Normal file
|
@ -0,0 +1,17 @@
|
|||
#include <catch2/catch.hpp>
|
||||
|
||||
#include "Age.h"
|
||||
|
||||
TEST_CASE("default initialization")
|
||||
{
|
||||
Age age;
|
||||
REQUIRE(age.years() == 0);
|
||||
REQUIRE(age.months() == 0);
|
||||
REQUIRE(age.toString() == "0;0");
|
||||
|
||||
Age age2;
|
||||
REQUIRE(!(age < age));
|
||||
REQUIRE(!(age < age2));
|
||||
}
|
||||
|
||||
|
21
test/CMakeLists.txt
Normal file
21
test/CMakeLists.txt
Normal file
|
@ -0,0 +1,21 @@
|
|||
cmake_minimum_required(VERSION 3.5)
|
||||
project(run-tests)
|
||||
|
||||
find_package(Catch2 REQUIRED)
|
||||
|
||||
add_executable(${PROJECT_NAME}
|
||||
main.cpp
|
||||
dummy.cpp
|
||||
Age.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
Catch2::Catch2
|
||||
Age
|
||||
)
|
||||
|
||||
include(CTest)
|
||||
include(Catch)
|
||||
catch_discover_tests(${PROJECT_NAME})
|
||||
|
7
test/dummy.cpp
Normal file
7
test/dummy.cpp
Normal file
|
@ -0,0 +1,7 @@
|
|||
#include <catch2/catch.hpp>
|
||||
|
||||
TEST_CASE("Dummy")
|
||||
{
|
||||
REQUIRE(true == true);
|
||||
}
|
||||
|
2
test/main.cpp
Normal file
2
test/main.cpp
Normal file
|
@ -0,0 +1,2 @@
|
|||
#define CATCH_CONFIG_MAIN
|
||||
#include <catch2/catch.hpp>
|
Loading…
Add table
Add a link
Reference in a new issue