Code Cleanup
- Renamed T2.h -> Task.h, T2.cpp -> Task.cpp. This permanently avoids the problem where g++ on OpenBSD 4.5 fails because of the T class, which probably conflicts with C++ templates. Who knows.
This commit is contained in:
@@ -3,7 +3,7 @@ PROJECT = t.t t2.t tdb.t date.t duration.t t.benchmark.t text.t autocomplete.t \
|
||||
cmd.t config.t
|
||||
CFLAGS = -I. -I.. -Wall -pedantic -ggdb3 -fno-rtti
|
||||
LFLAGS = -L/usr/local/lib -lncurses
|
||||
OBJECTS = ../TDB.o ../TDB2.o ../T.o ../T2.o ../parse.o ../text.o ../Date.o \
|
||||
OBJECTS = ../TDB.o ../TDB2.o ../T.o ../Task.o ../parse.o ../text.o ../Date.o \
|
||||
../Duration.o ../util.o ../Config.o ../Sequence.o ../Att.o \
|
||||
../Record.o ../StringTable.o ../Subst.o ../Nibbler.o ../Location.o \
|
||||
../Filter.o ../Context.o ../Keymap.o ../Cmd.o ../command.o \
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include "main.h"
|
||||
#include "test.h"
|
||||
#include "Filter.h"
|
||||
#include "T2.h"
|
||||
#include "Task.h"
|
||||
|
||||
Context context;
|
||||
|
||||
@@ -42,8 +42,8 @@ int main (int argc, char** argv)
|
||||
f.push_back (Att ("name2", "value2"));
|
||||
test.is (f.size (), (size_t)2, "Filter created");
|
||||
|
||||
// Create a T2 to match against.
|
||||
T2 yes;
|
||||
// Create a Task to match against.
|
||||
Task yes;
|
||||
yes.set ("name1", "value1");
|
||||
yes.set ("name2", "value2");
|
||||
test.ok (f.pass (yes), "full match");
|
||||
@@ -52,19 +52,19 @@ int main (int argc, char** argv)
|
||||
test.ok (f.pass (yes), "over match");
|
||||
|
||||
// Negative tests.
|
||||
T2 no0;
|
||||
test.notok (f.pass (no0), "no match against default T2");
|
||||
Task no0;
|
||||
test.notok (f.pass (no0), "no match against default Task");
|
||||
|
||||
T2 no1;
|
||||
Task no1;
|
||||
no1.set ("name3", "value3");
|
||||
test.notok (f.pass (no1), "no match against mismatch T2");
|
||||
test.notok (f.pass (no1), "no match against mismatch Task");
|
||||
|
||||
T2 partial;
|
||||
Task partial;
|
||||
partial.set ("name1", "value1");
|
||||
test.notok (f.pass (partial), "no match against partial T2");
|
||||
test.notok (f.pass (partial), "no match against partial Task");
|
||||
|
||||
// Modifiers.
|
||||
T2 mods;
|
||||
Task mods;
|
||||
mods.set ("name", "value");
|
||||
|
||||
Att a ("name", "value");
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#include <Context.h>
|
||||
#include <T2.h>
|
||||
#include <Task.h>
|
||||
#include <Subst.h>
|
||||
#include <test.h>
|
||||
|
||||
@@ -36,7 +36,7 @@ int main (int argc, char** argv)
|
||||
{
|
||||
UnitTest t (15);
|
||||
|
||||
T2 task;
|
||||
Task task;
|
||||
task.set ("description", "one two three four");
|
||||
|
||||
Subst s;
|
||||
|
||||
@@ -34,18 +34,18 @@ int main (int argc, char** argv)
|
||||
{
|
||||
UnitTest test (34);
|
||||
|
||||
test.is ((int)T2::textToStatus ("pending"), (int)T2::pending, "textToStatus pending");
|
||||
test.is ((int)T2::textToStatus ("completed"), (int)T2::completed, "textToStatus completed");
|
||||
test.is ((int)T2::textToStatus ("deleted"), (int)T2::deleted, "textToStatus deleted");
|
||||
test.is ((int)T2::textToStatus ("recurring"), (int)T2::recurring, "textToStatus recurring");
|
||||
test.is ((int)Task::textToStatus ("pending"), (int)Task::pending, "textToStatus pending");
|
||||
test.is ((int)Task::textToStatus ("completed"), (int)Task::completed, "textToStatus completed");
|
||||
test.is ((int)Task::textToStatus ("deleted"), (int)Task::deleted, "textToStatus deleted");
|
||||
test.is ((int)Task::textToStatus ("recurring"), (int)Task::recurring, "textToStatus recurring");
|
||||
|
||||
test.is (T2::statusToText (T2::pending), "pending", "statusToText pending");
|
||||
test.is (T2::statusToText (T2::completed), "completed", "statusToText completed");
|
||||
test.is (T2::statusToText (T2::deleted), "deleted", "statusToText deleted");
|
||||
test.is (T2::statusToText (T2::recurring), "recurring", "statusToText recurring");
|
||||
test.is (Task::statusToText (Task::pending), "pending", "statusToText pending");
|
||||
test.is (Task::statusToText (Task::completed), "completed", "statusToText completed");
|
||||
test.is (Task::statusToText (Task::deleted), "deleted", "statusToText deleted");
|
||||
test.is (Task::statusToText (Task::recurring), "recurring", "statusToText recurring");
|
||||
|
||||
// Round-trip testing.
|
||||
T2 t3;
|
||||
Task t3;
|
||||
std::string before = t3.composeF4 ();
|
||||
t3.parse (before);
|
||||
std::string after = t3.composeF4 ();
|
||||
@@ -53,7 +53,7 @@ int main (int argc, char** argv)
|
||||
after = t3.composeF4 ();
|
||||
t3.parse (after);
|
||||
after = t3.composeF4 ();
|
||||
test.is (before, after, "T2::composeF4 -> parse round trip 4 iterations");
|
||||
test.is (before, after, "Task::composeF4 -> parse round trip 4 iterations");
|
||||
|
||||
// Legacy Format 1
|
||||
// [tags] [attributes] description\n
|
||||
@@ -64,7 +64,7 @@ int main (int argc, char** argv)
|
||||
"[att1:value1 att2:value2] "
|
||||
"Description";
|
||||
bool good = true;
|
||||
try { T2 ff1 (sample); } catch (...) { good = false; }
|
||||
try { Task ff1 (sample); } catch (...) { good = false; }
|
||||
test.notok (good, "Support for ff1 removed");
|
||||
|
||||
// Legacy Format 2
|
||||
@@ -74,7 +74,7 @@ int main (int argc, char** argv)
|
||||
"[tag1 tag2] "
|
||||
"[att1:value1 att2:value2] "
|
||||
"Description";
|
||||
T2 ff2 (sample);
|
||||
Task ff2 (sample);
|
||||
std::string value = ff2.get ("uuid");
|
||||
test.is (value, "00000000-0000-0000-0000-000000000000", "ff2 uuid");
|
||||
value = ff2.get ("status");
|
||||
@@ -96,7 +96,7 @@ int main (int argc, char** argv)
|
||||
"[tag1 tag2] "
|
||||
"[att1:value1 att2:value2] "
|
||||
"[123:ann1 456:ann2] Description";
|
||||
T2 ff3 (sample);
|
||||
Task ff3 (sample);
|
||||
value = ff2.get ("uuid");
|
||||
test.is (value, "00000000-0000-0000-0000-000000000000", "ff3 uuid");
|
||||
value = ff2.get ("status");
|
||||
@@ -121,7 +121,7 @@ int main (int argc, char** argv)
|
||||
"att2:\"value2\" "
|
||||
"description:\"Description\""
|
||||
"]";
|
||||
T2 ff4 (sample);
|
||||
Task ff4 (sample);
|
||||
value = ff2.get ("uuid");
|
||||
test.is (value, "00000000-0000-0000-0000-000000000000", "ff4 uuid");
|
||||
value = ff2.get ("status");
|
||||
@@ -138,11 +138,11 @@ int main (int argc, char** argv)
|
||||
|
||||
/*
|
||||
|
||||
T2::composeCSV
|
||||
T2::id
|
||||
T2::*Status
|
||||
T2::*Tag*
|
||||
T2::*Annotation*
|
||||
Task::composeCSV
|
||||
Task::id
|
||||
Task::*Status
|
||||
Task::*Tag*
|
||||
Task::*Annotation*
|
||||
|
||||
*/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user