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
|
@ -6,3 +6,4 @@ include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
|||
conan_basic_setup()
|
||||
|
||||
add_subdirectory(source)
|
||||
add_subdirectory(test)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
[requires]
|
||||
protobuf/3.6.1@bincrafters/stable
|
||||
catch2/2.4.2@bincrafters/stable
|
||||
|
||||
[generators]
|
||||
cmake
|
||||
|
|
23
source/Age/CMakeLists.txt
Normal file
23
source/Age/CMakeLists.txt
Normal file
|
@ -0,0 +1,23 @@
|
|||
cmake_minimum_required(VERSION 3.6)
|
||||
|
||||
project(Age LANGUAGES CXX)
|
||||
|
||||
find_package(Qt5Core REQUIRED)
|
||||
|
||||
add_library(${PROJECT_NAME}
|
||||
Age.cpp
|
||||
)
|
||||
|
||||
set_target_properties(${PROJECT_NAME}
|
||||
PROPERTIES CXX_STANDARD 14
|
||||
)
|
||||
|
||||
target_include_directories(${PROJECT_NAME}
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
PUBLIC
|
||||
Qt5::Core
|
||||
)
|
|
@ -37,7 +37,6 @@ add_executable(${PROJECT_NAME} WIN32
|
|||
LogoTest.cpp
|
||||
DataModel.cpp
|
||||
mainwindow.cpp
|
||||
Age.cpp
|
||||
${LOGO_TEST_UI}
|
||||
${LOGO_TEST_QRC}
|
||||
${DataModel_PROTO_SRCS}
|
||||
|
@ -57,6 +56,7 @@ target_include_directories(${PROJECT_NAME}
|
|||
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
Age
|
||||
CheckableItem
|
||||
CheckableTest
|
||||
CheckableTestModel
|
||||
|
@ -73,6 +73,7 @@ target_link_libraries(${PROJECT_NAME}
|
|||
${Protobuf_LIBRARIES}
|
||||
)
|
||||
|
||||
add_subdirectory(Age)
|
||||
add_subdirectory(CheckableItem)
|
||||
add_subdirectory(CheckableTest)
|
||||
add_subdirectory(CheckableTestModel)
|
||||
|
|
|
@ -41,6 +41,7 @@ target_include_directories(${PROJECT_NAME}
|
|||
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
Age
|
||||
Qt5::Widgets
|
||||
${Protobuf_LIBRARIES}
|
||||
)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "../Age.h"
|
||||
#include "Age.h"
|
||||
|
||||
#include "MetaDataModel.pb.h"
|
||||
|
||||
|
|
|
@ -30,5 +30,6 @@ target_include_directories(${PROJECT_NAME}
|
|||
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
Age
|
||||
Qt5::Widgets
|
||||
)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "../Age.h"
|
||||
#include "Age.h"
|
||||
#include <vector>
|
||||
|
||||
class PRMap
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "../Age.h"
|
||||
#include "Age.h"
|
||||
#include <QAbstractTableModel>
|
||||
|
||||
class TestResult
|
||||
|
|
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…
Reference in a new issue