Unit Tests - Record, T2

- Added Record::get, ::set, ::get_int tests.
- Added T2 tests.
- Fixed Record::composeF4 bug
This commit is contained in:
Paul Beckingham 2009-06-04 00:37:23 -04:00
parent 25450b4a7c
commit b887f7267b
7 changed files with 140 additions and 5 deletions

View file

@ -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
{