Code Cleanup

- Mod object is no longer necessary, and is removed.
This commit is contained in:
Paul Beckingham 2009-06-03 21:10:12 -04:00
parent ac871d9e8d
commit 55771cc999
9 changed files with 148 additions and 240 deletions

View file

@ -8,7 +8,6 @@ autocomplete.t
parse.t
seq.t
att.t
mod.t
record.t
stringtable.t
nibbler.t

View file

@ -1,5 +1,5 @@
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 nibbler.t subst.t
parse.t seq.t att.t stringtable.t record.t nibbler.t subst.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 \
@ -51,9 +51,6 @@ seq.t: seq.t.o $(OBJECTS) test.o
record.t: record.t.o $(OBJECTS) test.o
g++ record.t.o $(OBJECTS) test.o $(LFLAGS) -o record.t
mod.t: mod.t.o $(OBJECTS) test.o
g++ mod.t.o $(OBJECTS) test.o $(LFLAGS) -o mod.t
att.t: att.t.o $(OBJECTS) test.o
g++ att.t.o $(OBJECTS) test.o $(LFLAGS) -o att.t

View file

@ -33,7 +33,7 @@ Context context;
////////////////////////////////////////////////////////////////////////////////
int main (int argc, char** argv)
{
UnitTest t (42);
UnitTest t (59);
Att a1 ("name", "value");
t.is (a1.name (), "name", "Att::Att (name, value), Att.name");
@ -73,11 +73,84 @@ int main (int argc, char** argv)
t.ok (good, "Att::addMod (is)");
good = true;
try {a6.addMod (Mod ("fartwizzle"));} catch (...) {good = false;}
try {a6.addMod ("before");} catch (...) {good = false;}
t.ok (good, "Att::addMod (before)");
good = true;
try {a6.addMod ("after");} catch (...) {good = false;}
t.ok (good, "Att::addMod (after)");
good = true;
try {a6.addMod ("not");} catch (...) {good = false;}
t.ok (good, "Att::addMod (not)");
good = true;
try {a6.addMod ("none");} catch (...) {good = false;}
t.ok (good, "Att::addMod (none)");
good = true;
try {a6.addMod ("any");} catch (...) {good = false;}
t.ok (good, "Att::addMod (any)");
good = true;
try {a6.addMod ("over");} catch (...) {good = false;}
t.ok (good, "Att::addMod (over)");
good = true;
try {a6.addMod ("under");} catch (...) {good = false;}
t.ok (good, "Att::addMod (under)");
good = true;
try {a6.addMod ("synth");} catch (...) {good = false;}
t.ok (good, "Att::addMod (synth)");
good = true;
try {a6.addMod ("first");} catch (...) {good = false;}
t.ok (good, "Att::addMod (first)");
good = true;
try {a6.addMod ("last");} catch (...) {good = false;}
t.ok (good, "Att::addMod (last)");
good = true;
try {a6.addMod ("this");} catch (...) {good = false;}
t.ok (good, "Att::addMod (this)");
good = true;
try {a6.addMod ("next");} catch (...) {good = false;}
t.ok (good, "Att::addMod (next)");
good = true;
try {a6.addMod ("isnt");} catch (...) {good = false;}
t.ok (good, "Att::addMod (isnt)");
good = true;
try {a6.addMod ("has");} catch (...) {good = false;}
t.ok (good, "Att::addMod (has)");
good = true;
try {a6.addMod ("hasnt");} catch (...) {good = false;}
t.ok (good, "Att::addMod (hasnt)");
good = true;
try {a6.addMod ("startswith");} catch (...) {good = false;}
t.ok (good, "Att::addMod (startswith)");
good = true;
try {a6.addMod ("endswith");} catch (...) {good = false;}
t.ok (good, "Att::addMod (endswith)");
good = true;
try {a6.addMod ("fartwizzle");} catch (...) {good = false;}
t.notok (good, "Att::addMod (fartwizzle)");
// Att::mods
std::vector <Mod> mods;
std::vector <std::string> mods;
a6.mods (mods);
t.is (mods.size (), (size_t)1, "Att::mods () size == 1");
t.is (mods[0], "is", "Att::mods [0] == 'is'");

View file

@ -1,60 +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 <Context.h>
#include <Mod.h>
#include <test.h>
Context context;
////////////////////////////////////////////////////////////////////////////////
int main (int argc, char** argv)
{
UnitTest t (18);
Mod m = "before"; t.ok (m.valid (), "Mod: before is valid");
m = "after"; t.ok (m.valid (), "Mod: after is valid");
m = "not"; t.ok (m.valid (), "Mod: not is valid");
m = "none"; t.ok (m.valid (), "Mod: none is valid");
m = "any"; t.ok (m.valid (), "Mod: any is valid");
m = "over"; t.ok (m.valid (), "Mod: over is valid");
m = "under"; t.ok (m.valid (), "Mod: under is valid");
m = "synth"; t.ok (m.valid (), "Mod: synth is valid");
m = "first"; t.ok (m.valid (), "Mod: first is valid");
m = "last"; t.ok (m.valid (), "Mod: last is valid");
m = "this"; t.ok (m.valid (), "Mod: this is valid");
m = "next"; t.ok (m.valid (), "Mod: next is valid");
m = "is"; t.ok (m.valid (), "Mod: is is valid");
m = "isnt"; t.ok (m.valid (), "Mod: isnt is valid");
m = "has"; t.ok (m.valid (), "Mod: has is valid");
m = "hasnt"; t.ok (m.valid (), "Mod: hasnt is valid");
m = "startswith"; t.ok (m.valid (), "Mod: startswith is valid");
m = "endswith"; t.ok (m.valid (), "Mod: endswith is valid");
return 0;
}
////////////////////////////////////////////////////////////////////////////////