mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Unit tests - subst
- Implemented basic subst tests, awaiting Record/T integration before this can be expanded.
This commit is contained in:
parent
54789082c9
commit
4fda101f28
2 changed files with 68 additions and 2 deletions
|
@ -1,10 +1,10 @@
|
|||
PROJECT = t.t tdb.t date.t duration.t t.benchmark.t text.t autocomplete.t \
|
||||
parse.t seq.t att.t mod.t stringtable.t # record.t
|
||||
parse.t seq.t att.t mod.t stringtable.t # subst.t record.t
|
||||
CFLAGS = -I. -I.. -Wall -pedantic -ggdb3 -fno-rtti
|
||||
LFLAGS = -L/usr/local/lib
|
||||
OBJECTS = ../TDB.o ../T.o ../parse.o ../text.o ../Date.o ../Duration.o \
|
||||
../util.o ../Config.o ../Sequence.o ../Att.o ../Record.o ../Mod.o \
|
||||
../StringTable.o
|
||||
../StringTable.o ../Subst.o
|
||||
|
||||
all: $(PROJECT)
|
||||
|
||||
|
@ -59,3 +59,6 @@ att.t: att.t.o $(OBJECTS) test.o
|
|||
stringtable.t: stringtable.t.o $(OBJECTS) test.o
|
||||
g++ stringtable.t.o $(OBJECTS) test.o $(LFLAGS) -o stringtable.t
|
||||
|
||||
subst.t: subst.t.o $(OBJECTS) test.o
|
||||
g++ subst.t.o $(OBJECTS) test.o $(LFLAGS) -o subst.t
|
||||
|
||||
|
|
63
src/tests/subst.t.cpp
Normal file
63
src/tests/subst.t.cpp
Normal file
|
@ -0,0 +1,63 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// 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 <T.h>
|
||||
#include <Subst.h>
|
||||
#include <test.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
UnitTest t (2);
|
||||
|
||||
T task;
|
||||
task.set ("description", "one two three four");
|
||||
|
||||
Subst s;
|
||||
if (s.parse ("/two/TWO/"))
|
||||
{
|
||||
s.apply (task);
|
||||
t.is (task.get ("description"), "one TWO three four", "single word subst");
|
||||
}
|
||||
else
|
||||
{
|
||||
t.fail ("failed to parse '/two/TWO/'");
|
||||
}
|
||||
|
||||
if (s.parse ("/e /E /g"))
|
||||
{
|
||||
s.apply (task);
|
||||
t.is (task.get ("description"), "onE TWO threE four", "multiple word subst");
|
||||
}
|
||||
else
|
||||
{
|
||||
t.fail ("failed to parse '/e /E /g'");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
Loading…
Add table
Add a link
Reference in a new issue