mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-02 14:38:34 +02:00
Enhancements - Cmd object
- New Cmd object to handle localized commands, customReports and general command parsing. - Localized new Subst methods. - Relocate guess method from parse.cpp to text.cpp. - Converted Att object to use new valid/parse scheme. - Unit tests for Cmd object. - Fixed att.t.cpp unit tests.
This commit is contained in:
parent
ffa0c6e758
commit
24f31eeb00
17 changed files with 416 additions and 52 deletions
1
src/tests/.gitignore
vendored
1
src/tests/.gitignore
vendored
|
@ -14,3 +14,4 @@ stringtable.t
|
|||
nibbler.t
|
||||
subst.t
|
||||
filt.t
|
||||
cmd.t
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
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
|
||||
parse.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
|
||||
OBJECTS = ../TDB.o ../TDB2.o ../T.o ../T2.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
|
||||
../Filter.o ../Context.o ../Keymap.o ../Cmd.o
|
||||
|
||||
all: $(PROJECT)
|
||||
|
||||
|
@ -69,3 +70,6 @@ nibbler.t: nibbler.t.o $(OBJECTS) test.o
|
|||
filt.t: filt.t.o $(OBJECTS) test.o
|
||||
g++ filt.t.o $(OBJECTS) test.o $(LFLAGS) -o filt.t
|
||||
|
||||
cmd.t: cmd.t.o $(OBJECTS) test.o
|
||||
g++ cmd.t.o $(OBJECTS) test.o $(LFLAGS) -o cmd.t
|
||||
|
||||
|
|
|
@ -33,7 +33,25 @@ Context context;
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
UnitTest t (59);
|
||||
UnitTest t (74);
|
||||
|
||||
Att a;
|
||||
t.notok (a.valid ("name"), "Att::valid name -> fail");
|
||||
t.notok (a.valid (":"), "Att::valid : -> fail");
|
||||
t.notok (a.valid (":value"), "Att::valid :value -> fail");
|
||||
|
||||
t.ok (a.valid ("name:value"), "Att::valid name:value");
|
||||
t.ok (a.valid ("name:value "), "Att::valid name:value\\s");
|
||||
t.ok (a.valid ("name:'value'"), "Att::valid name:'value'");
|
||||
t.ok (a.valid ("name:'one two'"), "Att::valid name:'one two'");
|
||||
t.ok (a.valid ("name:\"value\""), "Att::valid name:\"value\"");
|
||||
t.ok (a.valid ("name:\"one two\""), "Att::valid name:\"one two\"");
|
||||
t.ok (a.valid ("name:"), "Att::valid name:");
|
||||
t.ok (a.valid ("name:""), "Att::valid "");
|
||||
t.ok (a.valid ("name.one:value"), "Att::valid name.one.value");
|
||||
t.ok (a.valid ("name.one.two:value"), "Att::valid name.one.two:value");
|
||||
t.ok (a.valid ("name.:value"), "Att::valid name.:value");
|
||||
t.ok (a.valid ("name..:value"), "Att::valid name..:value");
|
||||
|
||||
Att a1 ("name", "value");
|
||||
t.is (a1.name (), "name", "Att::Att (name, value), Att.name");
|
||||
|
|
71
src/tests/cmd.t.cpp
Normal file
71
src/tests/cmd.t.cpp
Normal file
|
@ -0,0 +1,71 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// 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 <Context.h>
|
||||
#include <Cmd.h>
|
||||
#include <test.h>
|
||||
|
||||
Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
UnitTest t (18);
|
||||
|
||||
context.config.set ("report.foo.columns", "id");
|
||||
|
||||
Cmd cmd;
|
||||
t.ok (cmd.valid ("annotate"), "Cmd::valid annotate");
|
||||
t.ok (cmd.valid ("annotat"), "Cmd::valid annotat");
|
||||
t.ok (cmd.valid ("annota"), "Cmd::valid annota");
|
||||
t.ok (cmd.valid ("annot"), "Cmd::valid annot");
|
||||
t.ok (cmd.valid ("anno"), "Cmd::valid anno");
|
||||
t.ok (cmd.valid ("ann"), "Cmd::valid ann");
|
||||
t.ok (cmd.valid ("an"), "Cmd::valid an");
|
||||
|
||||
t.ok (cmd.valid ("ANNOTATE"), "Cmd::valid ANNOTATE");
|
||||
t.ok (cmd.valid ("ANNOTAT"), "Cmd::valid ANNOTAT");
|
||||
t.ok (cmd.valid ("ANNOTA"), "Cmd::valid ANNOTA");
|
||||
t.ok (cmd.valid ("ANNOT"), "Cmd::valid ANNOT");
|
||||
t.ok (cmd.valid ("ANNO"), "Cmd::valid ANNO");
|
||||
t.ok (cmd.valid ("ANN"), "Cmd::valid ANN");
|
||||
t.ok (cmd.valid ("AN"), "Cmd::valid AN");
|
||||
|
||||
t.ok (cmd.validCustom ("foo"), "Cmd::validCustom foo");
|
||||
t.notok (cmd.validCustom ("bar"), "Cmd::validCustom bar -> fail");
|
||||
|
||||
bool good = true;
|
||||
try { cmd.parse ("a"); } catch (...) { good = false; }
|
||||
t.notok (good, "Cmd::parse a -> fail");
|
||||
|
||||
good = true;
|
||||
try { cmd.parse ("add"); } catch (...) { good = false; }
|
||||
t.ok (good, "Cmd::parse add");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
Loading…
Add table
Add a link
Reference in a new issue