mirror of
https://codeberg.org/vyn/mirai.git
synced 2025-07-02 01:13:19 +00:00
Add Catch2 dependency for tests
This commit is contained in:
parent
cd01c39ed7
commit
bfc4d0e21e
4 changed files with 48 additions and 9 deletions
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
[submodule "libs/Catch2"]
|
||||
path = libs/Catch2
|
||||
url = https://github.com/catchorg/Catch2.git
|
|
@ -13,6 +13,15 @@ include_directories(libs)
|
|||
|
||||
qt_standard_project_setup(REQUIRES 6.6)
|
||||
|
||||
add_library(mirai-core
|
||||
src/core/Mirai.h src/core/Mirai.cpp
|
||||
src/core/TaskItem.h src/core/TaskItem.cpp
|
||||
src/core/TasksFile.h src/core/TasksFile.cpp
|
||||
src/core/TasksView.h src/core/TasksView.cpp
|
||||
src/core/TodoMd.h src/core/TodoMd.cpp
|
||||
src/core/utils.h src/core/utils.cpp
|
||||
)
|
||||
|
||||
qt_add_executable(mirai
|
||||
src/main.cpp
|
||||
)
|
||||
|
@ -49,21 +58,20 @@ qt_add_qml_module(mirai
|
|||
src/qml/views/ListView.qml
|
||||
src/qml/views/CalendarView.qml
|
||||
SOURCES
|
||||
# Qt related files
|
||||
src/Backend.h src/Backend.cpp
|
||||
src/TaskItem.h src/TaskItem.cpp
|
||||
src/TasksFile.h src/TasksFile.cpp
|
||||
# Core related files
|
||||
src/core/Mirai.h src/core/Mirai.cpp
|
||||
src/core/TaskItem.h src/core/TaskItem.cpp
|
||||
src/core/TasksFile.h src/core/TasksFile.cpp
|
||||
src/core/TasksView.h src/core/TasksView.cpp
|
||||
src/core/TodoMd.h src/core/TodoMd.cpp
|
||||
# src/core/TodoTxt.h
|
||||
src/core/utils.h src/core/utils.cpp
|
||||
RESOURCES
|
||||
src/images/calendar.png
|
||||
src/images/add.png
|
||||
)
|
||||
|
||||
target_link_libraries(mirai PRIVATE Qt6::Quick)
|
||||
target_link_libraries(mirai PRIVATE mirai-core)
|
||||
|
||||
|
||||
# Tests
|
||||
add_subdirectory(libs/Catch2)
|
||||
add_executable(tests tests/test.cpp)
|
||||
target_link_libraries(tests PRIVATE mirai-core)
|
||||
target_link_libraries(tests PRIVATE Catch2::Catch2WithMain)
|
||||
|
|
1
libs/Catch2
Submodule
1
libs/Catch2
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit f2320724a74f95d83f8c259e1a96cf2cd9a1d6aa
|
27
tests/test.cpp
Normal file
27
tests/test.cpp
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Mirai. Copyright (C) 2024 Vyn
|
||||
* This file is licensed under version 3 of the GNU General Public License (GPL-3.0-only)
|
||||
* The license can be found in the LICENSE file or at https://www.gnu.org/licenses/gpl-3.0.txt
|
||||
*/
|
||||
|
||||
// TODO this is just a quick setup for later
|
||||
|
||||
#include "core/Mirai.h"
|
||||
#include "core/TaskItem.h"
|
||||
#include "core/TodoMd.h"
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
TEST_CASE("TODO make tests", "[todo]")
|
||||
{
|
||||
mirai::Mirai mirai;
|
||||
auto task = mirai::TodoMdFormat::StringToTask(
|
||||
"- [X] 08:00-10:00 > This is a test -- #mirai", "2024-04-19"
|
||||
);
|
||||
REQUIRE(task.date == "2024-04-19");
|
||||
REQUIRE(task.tags.size() == 1);
|
||||
REQUIRE(task.tags[0] == "#mirai");
|
||||
REQUIRE(task.text == "This is a test");
|
||||
REQUIRE(task.state == mirai::DONE);
|
||||
REQUIRE(task.startTime == "08:00");
|
||||
REQUIRE(task.endTime == "10:00");
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue