Test: Merged t3.t.cpp into t.t.cpp
This commit is contained in:
37
test/t.t.cpp
37
test/t.t.cpp
@@ -34,7 +34,7 @@ Context context;
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main (int, char**)
|
||||
{
|
||||
UnitTest test (40);
|
||||
UnitTest test (49);
|
||||
|
||||
// Ensure environment has no influence.
|
||||
unsetenv ("TASKDATA");
|
||||
@@ -217,6 +217,41 @@ TODO Task::decode
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Task::attributes["description"] = "string";
|
||||
Task::attributes["entry"] = "date";
|
||||
Task::attributes["tags"] = "string";
|
||||
Task::attributes["uuid"] = "string";
|
||||
|
||||
good = true;
|
||||
try {Task t4 ("{}");}
|
||||
catch (const std::string& e){test.diag (e); good = false;}
|
||||
test.ok (good, "Task::Task ('{}')");
|
||||
|
||||
good = true;
|
||||
try {Task t5 ("{\"uuid\":\"00000000-0000-0000-000000000001\",\"description\":\"foo\",\"entry\":\"1234567890\"}");}
|
||||
catch (const std::string& e){test.diag (e); good = false;}
|
||||
test.ok (good, "Task::Task ('{<minimal>}')");
|
||||
|
||||
// Verify tag handling is correct between F4 and JSON.
|
||||
Task t6;
|
||||
t6.set ("entry", "20130602T224000Z");
|
||||
t6.set ("description", "DESC");
|
||||
t6.addTag ("tag1");
|
||||
test.is (t6.composeF4 (), "[description:\"DESC\" entry:\"20130602T224000Z\" tags:\"tag1\"]", "F4 good");
|
||||
test.is (t6.composeJSON (), "{\"description\":\"DESC\",\"entry\":\"20130602T224000Z\",\"tags\":[\"tag1\"]}", "JSON good");
|
||||
|
||||
t6.addTag ("tag2");
|
||||
test.is (t6.composeF4 (), "[description:\"DESC\" entry:\"20130602T224000Z\" tags:\"tag1,tag2\"]", "F4 good");
|
||||
test.is (t6.composeJSON (), "{\"description\":\"DESC\",\"entry\":\"20130602T224000Z\",\"tags\":[\"tag1\",\"tag2\"]}", "JSON good");
|
||||
|
||||
good = true;
|
||||
Task t7;
|
||||
try {t7 = Task ("{\"description\":\"DESC\",\"entry\":\"20130602T224000Z\",\"tags\":[\"tag1\",\"tag2\"]}");}
|
||||
catch (const std::string& e){test.diag (e); good = false;}
|
||||
test.ok (good, "Task::Task ('{two tags}')");
|
||||
test.is (t7.composeF4 (), "[description:\"DESC\" entry:\"1370212800\" tags:\"tag1,tag2\"]", "F4 good");
|
||||
test.is (t7.composeJSON (), "{\"description\":\"DESC\",\"entry\":\"20130602T224000Z\",\"tags\":[\"tag1\",\"tag2\"]}", "JSON good");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user