mirror of
https://codeberg.org/vyn/mirai.git
synced 2025-07-03 10:13:42 +00:00
Change 'File' concept to a 'Resource' abstract concept
This commit is contained in:
parent
7eb54cddce
commit
ca34562a1c
23 changed files with 447 additions and 351 deletions
|
@ -1,74 +0,0 @@
|
|||
/*
|
||||
* 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("Creating task from string")
|
||||
{
|
||||
SECTION("All properties")
|
||||
{
|
||||
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");
|
||||
}
|
||||
|
||||
SECTION("All properties 2")
|
||||
{
|
||||
auto task = mirai::TodoMdFormat::stringToTask(
|
||||
"- [ ] 09:00-17:00 > This is another test -- #mirai #feature", "2024-04-20"
|
||||
);
|
||||
REQUIRE(task.date == "2024-04-20");
|
||||
REQUIRE(task.tags.size() == 2);
|
||||
REQUIRE(task.tags[0] == "mirai");
|
||||
REQUIRE(task.tags[1] == "feature");
|
||||
REQUIRE(task.text == "This is another test");
|
||||
REQUIRE(task.state == mirai::TODO);
|
||||
REQUIRE(task.startTime == "09:00");
|
||||
REQUIRE(task.endTime == "17:00");
|
||||
}
|
||||
|
||||
SECTION("Only text")
|
||||
{
|
||||
auto task = mirai::TodoMdFormat::stringToTask("- [ ] This is another test", "");
|
||||
REQUIRE(task.date == "");
|
||||
REQUIRE(task.tags.size() == 0);
|
||||
REQUIRE(task.text == "This is another test");
|
||||
REQUIRE(task.state == mirai::TODO);
|
||||
}
|
||||
|
||||
SECTION("Only text with a date")
|
||||
{
|
||||
auto task = mirai::TodoMdFormat::stringToTask("- [X] This is another test", "2025-02-03");
|
||||
REQUIRE(task.date == "2025-02-03");
|
||||
REQUIRE(task.tags.size() == 0);
|
||||
REQUIRE(task.text == "This is another test");
|
||||
REQUIRE(task.state == mirai::DONE);
|
||||
}
|
||||
|
||||
SECTION("Tags before -- are not tags")
|
||||
{
|
||||
auto task = mirai::TodoMdFormat::stringToTask(
|
||||
"- [ ] This is another test #ImNotATag -- #ImATag", ""
|
||||
);
|
||||
REQUIRE(task.date == "");
|
||||
REQUIRE(task.tags.size() == 1);
|
||||
REQUIRE(task.tags[0] == "ImATag");
|
||||
REQUIRE(task.text == "This is another test #ImNotATag");
|
||||
REQUIRE(task.state == mirai::TODO);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue