mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Unit Tests - parse
- Eliminated parse.t. - Fixed t.t.cpp tests.
This commit is contained in:
parent
6ac8bdc5ca
commit
c9807f4636
4 changed files with 15 additions and 172 deletions
|
@ -1,6 +1,6 @@
|
|||
PROJECT = t.t t2.t tdb.t date.t duration.t t.benchmark.t text.t autocomplete.t \
|
||||
parse.t seq.t att.t stringtable.t record.t nibbler.t subst.t filt.t \
|
||||
cmd.t config.t
|
||||
config.t seq.t att.t stringtable.t record.t nibbler.t subst.t filt.t \
|
||||
cmd.t
|
||||
CFLAGS = -I. -I.. -Wall -pedantic -ggdb3 -fno-rtti
|
||||
LFLAGS = -L/usr/local/lib -lncurses
|
||||
OBJECTS = ../TDB2.o ../T.o ../Task.o ../valid.o ../text.o ../Date.o ../Table.o \
|
||||
|
@ -47,9 +47,6 @@ text.t: text.t.o $(OBJECTS) test.o
|
|||
autocomplete.t: autocomplete.t.o $(OBJECTS) test.o
|
||||
g++ autocomplete.t.o $(OBJECTS) test.o $(LFLAGS) -o autocomplete.t
|
||||
|
||||
parse.t: parse.t.o $(OBJECTS) test.o
|
||||
g++ parse.t.o $(OBJECTS) test.o $(LFLAGS) -o parse.t
|
||||
|
||||
seq.t: seq.t.o $(OBJECTS) test.o
|
||||
g++ seq.t.o $(OBJECTS) test.o $(LFLAGS) -o seq.t
|
||||
|
||||
|
|
|
@ -67,57 +67,49 @@ int main (int argc, char** argv)
|
|||
Task mods;
|
||||
mods.set ("name", "value");
|
||||
|
||||
Att a ("name", "value");
|
||||
a.addMod ("is");
|
||||
Att a ("name", "is", "value");
|
||||
f.clear ();
|
||||
f.push_back (a);
|
||||
test.ok (f.pass (mods), "name:value -> name.is:value = match");
|
||||
// TODO test inverse.
|
||||
|
||||
a = Att ("name", "value");
|
||||
a.addMod ("isnt");
|
||||
a = Att ("name", "isnt", "value");
|
||||
f.clear ();
|
||||
f.push_back (a);
|
||||
test.notok (f.pass (mods), "name:value -> name.isnt:value = no match");
|
||||
// TODO test inverse.
|
||||
|
||||
a = Att ("name", "val");
|
||||
a.addMod ("startswith");
|
||||
a = Att ("name", "startswith", "val");
|
||||
f.clear ();
|
||||
f.push_back (a);
|
||||
test.ok (f.pass (mods), "name:value -> name.startswith:val = match");
|
||||
// TODO test inverse.
|
||||
|
||||
a = Att ("name", "lue");
|
||||
a.addMod ("endswith");
|
||||
a = Att ("name", "endswith", "lue");
|
||||
f.clear ();
|
||||
f.push_back (a);
|
||||
test.ok (f.pass (mods), "name:value -> name.endswith:lue = match");
|
||||
// TODO test inverse.
|
||||
|
||||
a = Att ("name", "value");
|
||||
a.addMod ("has");
|
||||
a = Att ("name", "has", "alu");
|
||||
f.clear ();
|
||||
f.push_back (a);
|
||||
test.ok (f.pass (mods), "name:value -> name.has:alu = match");
|
||||
// TODO test inverse.
|
||||
|
||||
a = Att ("name", "value");
|
||||
a.addMod ("hasnt");
|
||||
a = Att ("name", "hasnt", "alu");
|
||||
f.clear ();
|
||||
f.push_back (a);
|
||||
test.notok (f.pass (mods), "name:value -> name.hasnt:alu = no match");
|
||||
// TODO test inverse.
|
||||
|
||||
a = Att ("name", "");
|
||||
a.addMod ("any");
|
||||
a = Att ("name", "any", "");
|
||||
f.clear ();
|
||||
f.push_back (a);
|
||||
test.ok (f.pass (mods), "name:value -> name.any: = match");
|
||||
// TODO test inverse.
|
||||
|
||||
a = Att ("name", "");
|
||||
a.addMod ("none");
|
||||
a = Att ("name", "none", "");
|
||||
f.clear ();
|
||||
f.push_back (a);
|
||||
test.notok (f.pass (mods), "name:value -> name.none: = no match");
|
||||
|
@ -126,14 +118,10 @@ int main (int argc, char** argv)
|
|||
/*
|
||||
"before"
|
||||
"after"
|
||||
"not"
|
||||
"synth"
|
||||
"under"
|
||||
"over"
|
||||
"first"
|
||||
"last"
|
||||
"this"
|
||||
"next"
|
||||
"above"
|
||||
"below"
|
||||
*/
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -1,136 +0,0 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2009, Paul Beckingham.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU General Public License as published by the Free Software
|
||||
// Foundation; either version 2 of the License, or (at your option) any later
|
||||
// version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
// details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along with
|
||||
// this program; if not, write to the
|
||||
//
|
||||
// Free Software Foundation, Inc.,
|
||||
// 51 Franklin Street, Fifth Floor,
|
||||
// Boston, MA
|
||||
// 02110-1301
|
||||
// USA
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#include <iostream>
|
||||
#include "main.h"
|
||||
#include "text.h"
|
||||
#include "test.h"
|
||||
|
||||
Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
UnitTest t (18);
|
||||
|
||||
std::vector <std::string> args;
|
||||
std::string command;
|
||||
|
||||
context.config.set ("dateformat", "m/d/Y");
|
||||
|
||||
{
|
||||
T task;
|
||||
split (args, "add foo", ' ');
|
||||
parse (args, command, task);
|
||||
t.is (command, "add", "(1) command found");
|
||||
t.is (task.getId (), 0, "(1) zero id on add");
|
||||
t.is (task.getDescription (), "foo", "(1) correct description");
|
||||
}
|
||||
|
||||
{
|
||||
T task;
|
||||
split (args, "delete 1,3-5,7", ' ');
|
||||
parse (args, command, task);
|
||||
std::vector <int> sequence = task.getAllIds ();
|
||||
t.is (sequence.size (), (size_t)5, "(2) sequence length");
|
||||
if (sequence.size () == 5)
|
||||
{
|
||||
t.is (sequence[0], 1, "(2) sequence[0] == 1");
|
||||
t.is (sequence[1], 3, "(2) sequence[1] == 3");
|
||||
t.is (sequence[2], 4, "(2) sequence[2] == 4");
|
||||
t.is (sequence[3], 5, "(2) sequence[3] == 5");
|
||||
t.is (sequence[4], 7, "(2) sequence[4] == 7");
|
||||
}
|
||||
else
|
||||
{
|
||||
t.fail ("(2) sequence[0] == 1");
|
||||
t.fail ("(2) sequence[1] == 3");
|
||||
t.fail ("(2) sequence[2] == 4");
|
||||
t.fail ("(2) sequence[3] == 5");
|
||||
t.fail ("(2) sequence[4] == 7");
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
T task;
|
||||
split (args, "delete 1,2 3,4", ' ');
|
||||
parse (args, command, task);
|
||||
std::vector <int> sequence = task.getAllIds ();
|
||||
t.is (sequence.size (), (size_t)4, "(3) sequence length");
|
||||
if (sequence.size () == 4)
|
||||
{
|
||||
t.is (sequence[0], 1, "(3) sequence[0] == 1");
|
||||
t.is (sequence[1], 2, "(3) sequence[1] == 2");
|
||||
t.is (sequence[2], 3, "(3) sequence[2] == 3");
|
||||
t.is (sequence[3], 4, "(3) sequence[3] == 4");
|
||||
}
|
||||
else
|
||||
{
|
||||
t.fail ("(3) sequence[0] == 1");
|
||||
t.fail ("(3) sequence[1] == 2");
|
||||
t.fail ("(3) sequence[2] == 3");
|
||||
t.fail ("(3) sequence[3] == 4");
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
T task;
|
||||
split (args, "1 There are 7 days in a week", ' ');
|
||||
parse (args, command, task);
|
||||
std::vector <int> sequence = task.getAllIds ();
|
||||
t.is (sequence.size (), (size_t)1, "(4) sequence length");
|
||||
if (sequence.size () == 1)
|
||||
{
|
||||
t.is (sequence[0], 1, "(4) sequence[0] == 1");
|
||||
}
|
||||
else
|
||||
{
|
||||
t.fail ("(4) sequence[0] == 1");
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
T task;
|
||||
args.clear ();
|
||||
args.push_back ("1");
|
||||
args.push_back ("4-123 is back-ordered");
|
||||
parse (args, command, task);
|
||||
std::vector <int> sequence = task.getAllIds ();
|
||||
t.is (sequence.size (), (size_t)1, "(5) sequence length");
|
||||
if (sequence.size () == 1)
|
||||
{
|
||||
t.is (sequence[0], 1, "(5) sequence[0] == 1");
|
||||
}
|
||||
else
|
||||
{
|
||||
t.fail ("(5) sequence[0] == 1");
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -33,7 +33,7 @@ Context context;
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
UnitTest test (9);
|
||||
UnitTest test (8);
|
||||
|
||||
T t;
|
||||
std::string s = t.compose ();
|
||||
|
@ -57,16 +57,10 @@ int main (int argc, char** argv)
|
|||
|
||||
std::string format3 = "00000000-0000-0000-0000-000000000000 - [] [] [] Sample\n";
|
||||
|
||||
// Format 1 Round trip test.
|
||||
std::string sample = "[] [] Sample";
|
||||
T tf1;
|
||||
tf1.parse (sample);
|
||||
test.is (tf1.compose ().substr (36, std::string::npos),
|
||||
format3.substr (36, std::string::npos),
|
||||
"T::parse format 1 -> T::compose round trip");
|
||||
// Format 1 Not supported as of 1.8.0.
|
||||
|
||||
// Format 2 Round trip test.
|
||||
sample = "00000000-0000-0000-0000-000000000000 - [] [] Sample";
|
||||
std::string sample = "00000000-0000-0000-0000-000000000000 - [] [] Sample";
|
||||
T tf2;
|
||||
tf2.parse (sample);
|
||||
test.is (tf2.compose (), format3, "T::parse format 2 -> T::compose round trip");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue