Merge branch 'feature/add-unittests' into develop
This commit is contained in:
commit
458de36cbc
15 changed files with 107 additions and 9 deletions
|
@ -6,3 +6,4 @@ include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
||||||
conan_basic_setup()
|
conan_basic_setup()
|
||||||
|
|
||||||
add_subdirectory(source)
|
add_subdirectory(source)
|
||||||
|
add_subdirectory(test)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
[requires]
|
[requires]
|
||||||
protobuf/3.6.1@bincrafters/stable
|
protobuf/3.6.1@bincrafters/stable
|
||||||
|
catch2/2.4.2@bincrafters/stable
|
||||||
|
|
||||||
[generators]
|
[generators]
|
||||||
cmake
|
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
|
LogoTest.cpp
|
||||||
DataModel.cpp
|
DataModel.cpp
|
||||||
mainwindow.cpp
|
mainwindow.cpp
|
||||||
Age.cpp
|
|
||||||
${LOGO_TEST_UI}
|
${LOGO_TEST_UI}
|
||||||
${LOGO_TEST_QRC}
|
${LOGO_TEST_QRC}
|
||||||
${DataModel_PROTO_SRCS}
|
${DataModel_PROTO_SRCS}
|
||||||
|
@ -57,6 +56,7 @@ target_include_directories(${PROJECT_NAME}
|
||||||
|
|
||||||
target_link_libraries(${PROJECT_NAME}
|
target_link_libraries(${PROJECT_NAME}
|
||||||
PRIVATE
|
PRIVATE
|
||||||
|
Age
|
||||||
CheckableItem
|
CheckableItem
|
||||||
CheckableTest
|
CheckableTest
|
||||||
CheckableTestModel
|
CheckableTestModel
|
||||||
|
@ -73,6 +73,7 @@ target_link_libraries(${PROJECT_NAME}
|
||||||
${Protobuf_LIBRARIES}
|
${Protobuf_LIBRARIES}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
add_subdirectory(Age)
|
||||||
add_subdirectory(CheckableItem)
|
add_subdirectory(CheckableItem)
|
||||||
add_subdirectory(CheckableTest)
|
add_subdirectory(CheckableTest)
|
||||||
add_subdirectory(CheckableTestModel)
|
add_subdirectory(CheckableTestModel)
|
||||||
|
|
|
@ -41,6 +41,7 @@ target_include_directories(${PROJECT_NAME}
|
||||||
|
|
||||||
target_link_libraries(${PROJECT_NAME}
|
target_link_libraries(${PROJECT_NAME}
|
||||||
PRIVATE
|
PRIVATE
|
||||||
|
Age
|
||||||
Qt5::Widgets
|
Qt5::Widgets
|
||||||
${Protobuf_LIBRARIES}
|
${Protobuf_LIBRARIES}
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../Age.h"
|
#include "Age.h"
|
||||||
|
|
||||||
#include "MetaDataModel.pb.h"
|
#include "MetaDataModel.pb.h"
|
||||||
|
|
||||||
|
|
|
@ -30,5 +30,6 @@ target_include_directories(${PROJECT_NAME}
|
||||||
|
|
||||||
target_link_libraries(${PROJECT_NAME}
|
target_link_libraries(${PROJECT_NAME}
|
||||||
PRIVATE
|
PRIVATE
|
||||||
|
Age
|
||||||
Qt5::Widgets
|
Qt5::Widgets
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../Age.h"
|
#include "Age.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class PRMap
|
class PRMap
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../Age.h"
|
#include "Age.h"
|
||||||
#include <QAbstractTableModel>
|
#include <QAbstractTableModel>
|
||||||
|
|
||||||
class TestResult
|
class TestResult
|
||||||
|
|
40
test/Age.cpp
Normal file
40
test/Age.cpp
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
#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));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("year/month initialization")
|
||||||
|
{
|
||||||
|
for (unsigned int year = 0; year <= 100; ++year)
|
||||||
|
{
|
||||||
|
for (unsigned int month = 0; month < 12; ++month)
|
||||||
|
{
|
||||||
|
Age age(year, month);
|
||||||
|
|
||||||
|
REQUIRE(age.years() == year);
|
||||||
|
REQUIRE(age.months() == month);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("age by reference")
|
||||||
|
{
|
||||||
|
QDate birth(1970, 1, 1);
|
||||||
|
QDate reference(1980, 1, 1);
|
||||||
|
|
||||||
|
Age age(birth, reference);
|
||||||
|
|
||||||
|
REQUIRE(age.years() == 10);
|
||||||
|
REQUIRE(age.months() == 0);
|
||||||
|
}
|
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