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:
Paul Beckingham
2009-06-07 14:00:14 -04:00
parent ffa0c6e758
commit 24f31eeb00
17 changed files with 416 additions and 52 deletions

71
src/tests/cmd.t.cpp Normal file
View 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;
}
////////////////////////////////////////////////////////////////////////////////