mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Code Cleanup
- Removed unused Tree code.
This commit is contained in:
parent
8e4a757200
commit
3f58e5a2ee
7 changed files with 1 additions and 672 deletions
2
test/.gitignore
vendored
2
test/.gitignore
vendored
|
@ -30,8 +30,6 @@ tdb.t
|
|||
tdb2.t
|
||||
text.t
|
||||
transport.t
|
||||
tree.t
|
||||
tree2.t
|
||||
uri.t
|
||||
util.t
|
||||
variant.t
|
||||
|
|
|
@ -8,8 +8,7 @@ include_directories (${CMAKE_SOURCE_DIR}/src
|
|||
set (test_SRCS att.t autocomplete.t cmd.t color.t config.t date.t directory.t
|
||||
dom.t duration.t file.t filt.t json.t list.t nibbler.t path.t
|
||||
record.t rectangle.t rx.t seq.t subst.t t.benchmark.t t.t
|
||||
taskmod.t tdb.t tdb2.t text.t tree.t tree2.t uri.t util.t
|
||||
variant.t view.t
|
||||
taskmod.t tdb.t tdb2.t text.t uri.t util.t variant.t view.t
|
||||
json_test)
|
||||
|
||||
add_custom_target (test ./run_all DEPENDS ${test_SRCS}
|
||||
|
|
|
@ -1,82 +0,0 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2011, Paul Beckingham, Federico Hernandez.
|
||||
// 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 "Tree.h"
|
||||
#include "test.h"
|
||||
|
||||
Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
UnitTest ut (8);
|
||||
|
||||
// Construct tree as shown above.
|
||||
Tree t ("");
|
||||
|
||||
Tree* b = new Tree ("");
|
||||
b->attribute ("name", "c1");
|
||||
b->tag ("tag");
|
||||
t.addBranch (b);
|
||||
|
||||
b = new Tree ("");
|
||||
b->attribute ("name", "c2");
|
||||
t.addBranch (b);
|
||||
|
||||
b = new Tree ("");
|
||||
b->attribute ("name", "c3");
|
||||
t.addBranch (b);
|
||||
|
||||
Tree* l = new Tree ("");
|
||||
l->attribute ("name", "c4");
|
||||
|
||||
b->addBranch (l);
|
||||
|
||||
// Iterate over tree.
|
||||
std::vector <Tree*> all;
|
||||
t.enumerate (all);
|
||||
ut.is (all[0]->attribute ("name"), "c1", "c1");
|
||||
ut.is (all[1]->attribute ("name"), "c2", "c2");
|
||||
ut.is (all[2]->attribute ("name"), "c4", "c4");
|
||||
ut.is (all[3]->attribute ("name"), "c3", "c3");
|
||||
|
||||
all[3]->tag ("one");
|
||||
all[3]->tag ("two");
|
||||
ut.ok (all[3]->hasTag ("one"), "hasTag +");
|
||||
ut.notok (all[3]->hasTag ("three"), "hasTag -");
|
||||
|
||||
ut.is (t.count (), 5, "t.count");
|
||||
|
||||
all.clear ();
|
||||
b->enumerate (all);
|
||||
ut.is (all[0]->attribute ("name"), "c4", "t -> c3 -> c4");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
156
test/tree2.t.cpp
156
test/tree2.t.cpp
|
@ -1,156 +0,0 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// taskwarrior - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2011, Paul Beckingham, Federico Hernandez.
|
||||
// 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 "Tree.h"
|
||||
#include "test.h"
|
||||
|
||||
Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
UnitTest ut (30);
|
||||
|
||||
// Create the following tree:
|
||||
// t
|
||||
// |
|
||||
// +---+---+-+-+---+---+
|
||||
// | | | | | |
|
||||
// a b c d e f
|
||||
|
||||
// Create a tree.
|
||||
Tree t ("");
|
||||
|
||||
// Create six branches.
|
||||
Tree* a = new Tree (""); a->attribute ("name", "a");
|
||||
Tree* b = new Tree (""); b->attribute ("name", "b");
|
||||
Tree* c = new Tree (""); c->attribute ("name", "c");
|
||||
Tree* d = new Tree (""); d->attribute ("name", "d");
|
||||
Tree* e = new Tree (""); e->attribute ("name", "e");
|
||||
Tree* f = new Tree (""); f->attribute ("name", "f");
|
||||
|
||||
// Create two branches.
|
||||
Tree* x = new Tree (""); x->attribute ("name", "x");
|
||||
Tree* y = new Tree (""); y->attribute ("name", "y");
|
||||
|
||||
// Add the six.
|
||||
t.addBranch (a);
|
||||
t.addBranch (b);
|
||||
t.addBranch (c);
|
||||
t.addBranch (d);
|
||||
t.addBranch (e);
|
||||
t.addBranch (f);
|
||||
|
||||
// Verify tree structure.
|
||||
ut.ok (a->parent () == &t, "a -> t");
|
||||
ut.ok (b->parent () == &t, "b -> t");
|
||||
ut.ok (c->parent () == &t, "c -> t");
|
||||
ut.ok (d->parent () == &t, "d -> t");
|
||||
ut.ok (e->parent () == &t, "e -> t");
|
||||
ut.ok (f->parent () == &t, "f -> t");
|
||||
ut.ok (x->parent () == NULL, "x -> NULL");
|
||||
ut.ok (y->parent () == NULL, "y -> NULL");
|
||||
|
||||
ut.ok (t.branches () == 6, "t[6]");
|
||||
|
||||
ut.diag ("---------------------------------------------------------");
|
||||
|
||||
// Modify the tree to become:
|
||||
// t
|
||||
// |
|
||||
// +---+-+-+---+
|
||||
// | | | |
|
||||
// a b x f
|
||||
// |
|
||||
// +---+---+
|
||||
// | | |
|
||||
// c d e
|
||||
|
||||
// Make x the parent of c, d and e.
|
||||
x->addBranch (c);
|
||||
x->addBranch (d);
|
||||
x->addBranch (e);
|
||||
|
||||
// Make x replace c as one of t's branches.
|
||||
t.replaceBranch (c, x);
|
||||
t.removeBranch (d);
|
||||
t.removeBranch (e);
|
||||
|
||||
// Verify structure.
|
||||
ut.ok (a->parent () == &t, "a -> t");
|
||||
ut.ok (b->parent () == &t, "b -> t");
|
||||
ut.ok (c->parent () == x, "c -> x");
|
||||
ut.ok (d->parent () == x, "d -> x");
|
||||
ut.ok (e->parent () == x, "e -> x");
|
||||
ut.ok (f->parent () == &t, "f -> t");
|
||||
ut.ok (x->parent () == &t, "x -> t");
|
||||
ut.ok (y->parent () == NULL, "y -> NULL");
|
||||
|
||||
ut.ok (t.branches () == 4, "t[4]");
|
||||
ut.ok (x->branches () == 3, "x[3]");
|
||||
|
||||
ut.diag ("---------------------------------------------------------");
|
||||
|
||||
// Modify the tree to become:
|
||||
// t
|
||||
// |
|
||||
// +---+---+
|
||||
// | | |
|
||||
// a y f
|
||||
// |
|
||||
// +-+-+
|
||||
// | |
|
||||
// b x
|
||||
// |
|
||||
// +---+---+
|
||||
// | | |
|
||||
// c d e
|
||||
|
||||
// Now insert y to be parent of b, x.
|
||||
y->addBranch (b);
|
||||
y->addBranch (x);
|
||||
t.replaceBranch (x, y);
|
||||
t.removeBranch (b);
|
||||
|
||||
ut.ok (a->parent () == &t, "a -> t");
|
||||
ut.ok (b->parent () == y, "b -> y");
|
||||
ut.ok (c->parent () == x, "c -> x");
|
||||
ut.ok (d->parent () == x, "d -> x");
|
||||
ut.ok (e->parent () == x, "e -> x");
|
||||
ut.ok (f->parent () == &t, "f -> t");
|
||||
ut.ok (x->parent () == y, "x -> y");
|
||||
ut.ok (y->parent () == &t, "y -> t");
|
||||
|
||||
ut.ok (t.branches () == 3, "t[3]");
|
||||
ut.ok (x->branches () == 3, "x[3]");
|
||||
ut.ok (y->branches () == 2, "y[2]");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue