mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Unit Tests - Record, T2
- Added Record::get, ::set, ::get_int tests. - Added T2 tests. - Fixed Record::composeF4 bug
This commit is contained in:
parent
25450b4a7c
commit
b887f7267b
7 changed files with 140 additions and 5 deletions
33
src/T2.cpp
33
src/T2.cpp
|
@ -29,6 +29,7 @@
|
|||
#include <string>
|
||||
#include "Nibbler.h"
|
||||
#include "T2.h"
|
||||
#include "text.h"
|
||||
#include "util.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -291,6 +292,38 @@ void T2::addAnnotation (const std::string& description)
|
|||
(*this)[s.str ()] = Att (s.str (), description);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void T2::addTag (const std::string& tag)
|
||||
{
|
||||
std::vector <std::string> tags;
|
||||
split (tags, get ("tags"), ',');
|
||||
|
||||
if (std::find (tags.begin (), tags.end (), tag) == tags.end ())
|
||||
{
|
||||
tags.push_back (tag);
|
||||
std::string combined;
|
||||
join (combined, ",", tags);
|
||||
set ("tags", combined);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void T2::removeTag (const std::string& tag)
|
||||
{
|
||||
std::vector <std::string> tags;
|
||||
split (tags, get ("tags"), ',');
|
||||
|
||||
std::vector <std::string>::iterator i;
|
||||
i = std::find (tags.begin (), tags.end (), tag);
|
||||
if (i != tags.end ())
|
||||
{
|
||||
tags.erase (i);
|
||||
std::string combined;
|
||||
join (combined, ",", tags);
|
||||
set ("tags", combined);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool T2::validate () const
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue