mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-20 13:23:08 +02:00
Unit Tests
- Added Tree object unit tests.
This commit is contained in:
parent
f293e74ae6
commit
8f9a48c3ff
3 changed files with 80 additions and 3 deletions
1
test/.gitignore
vendored
1
test/.gitignore
vendored
|
@ -22,6 +22,7 @@ t2.t
|
||||||
taskmod.t
|
taskmod.t
|
||||||
tdb2.t
|
tdb2.t
|
||||||
text.t
|
text.t
|
||||||
|
tree.t
|
||||||
uri.t
|
uri.t
|
||||||
utf8.t
|
utf8.t
|
||||||
util.t
|
util.t
|
||||||
|
|
|
@ -3,13 +3,14 @@ include_directories (${CMAKE_SOURCE_DIR}
|
||||||
${CMAKE_SOURCE_DIR}/src
|
${CMAKE_SOURCE_DIR}/src
|
||||||
${CMAKE_SOURCE_DIR}/src/commands
|
${CMAKE_SOURCE_DIR}/src/commands
|
||||||
${CMAKE_SOURCE_DIR}/src/columns
|
${CMAKE_SOURCE_DIR}/src/columns
|
||||||
|
${CMAKE_SOURCE_DIR}/src/parser
|
||||||
${CMAKE_SOURCE_DIR}/test
|
${CMAKE_SOURCE_DIR}/test
|
||||||
${TASK_INCLUDE_DIRS})
|
${TASK_INCLUDE_DIRS})
|
||||||
|
|
||||||
set (test_SRCS autocomplete.t color.t config.t date.t directory.t dom.t
|
set (test_SRCS autocomplete.t color.t config.t date.t directory.t dom.t
|
||||||
duration.t file.t i18n.t json.t list.t msg.t nibbler.t path.t
|
duration.t file.t i18n.t json.t list.t msg.t nibbler.t path.t
|
||||||
rx.t t.t t2.t taskmod.t tdb2.t text.t uri.t utf8.t util.t view.t
|
rx.t t.t t2.t taskmod.t tdb2.t text.t tree.t uri.t utf8.t util.t
|
||||||
width.t json_test)
|
view.t width.t json_test)
|
||||||
|
|
||||||
message ("-- Configuring run_all")
|
message ("-- Configuring run_all")
|
||||||
if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
|
if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
|
||||||
|
@ -41,7 +42,7 @@ add_custom_target (build_tests DEPENDS ${test_SRCS}
|
||||||
|
|
||||||
foreach (src_FILE ${test_SRCS})
|
foreach (src_FILE ${test_SRCS})
|
||||||
add_executable (${src_FILE} "${src_FILE}.cpp" test.cpp)
|
add_executable (${src_FILE} "${src_FILE}.cpp" test.cpp)
|
||||||
target_link_libraries (${src_FILE} task commands task columns ${TASK_LIBRARIES})
|
target_link_libraries (${src_FILE} task commands task columns parser ${TASK_LIBRARIES})
|
||||||
endforeach (src_FILE)
|
endforeach (src_FILE)
|
||||||
|
|
||||||
#SET(CMAKE_BUILD_TYPE gcov)
|
#SET(CMAKE_BUILD_TYPE gcov)
|
||||||
|
|
75
test/tree.t.cpp
Normal file
75
test/tree.t.cpp
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// taskwarrior - a command line task list manager.
|
||||||
|
//
|
||||||
|
// Copyright 2006-2013, Paul Beckingham, Federico Hernandez.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included
|
||||||
|
// in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
// SOFTWARE.
|
||||||
|
//
|
||||||
|
// http://www.opensource.org/licenses/mit-license.php
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include <Tree.h>
|
||||||
|
#include <Context.h>
|
||||||
|
#include <test.h>
|
||||||
|
|
||||||
|
Context context;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
int main (int argc, char** argv)
|
||||||
|
{
|
||||||
|
UnitTest ut (8);
|
||||||
|
|
||||||
|
// Construct tree as shown above.
|
||||||
|
Tree t ("root");
|
||||||
|
|
||||||
|
Tree* b = t.addBranch (new Tree ("c1"));
|
||||||
|
b->attribute ("name", "c1");
|
||||||
|
b->tag ("tag");
|
||||||
|
|
||||||
|
b = t.addBranch (new Tree ("c2"));
|
||||||
|
b->attribute ("name", "c2");
|
||||||
|
|
||||||
|
b = t.addBranch (new Tree ("c3"));
|
||||||
|
b->attribute ("name", "c3");
|
||||||
|
|
||||||
|
Tree* l = b->addBranch (new Tree ("c4"));
|
||||||
|
l->attribute ("name", "c4");
|
||||||
|
|
||||||
|
// Iterate over tree.
|
||||||
|
ut.is (t._branches[0]->attribute ("name"), "c1", "c1");
|
||||||
|
ut.is (t._branches[1]->attribute ("name"), "c2", "c2");
|
||||||
|
ut.is (t._branches[2]->attribute ("name"), "c3", "c3");
|
||||||
|
ut.is (t._branches[2]->_branches[0]->attribute ("name"), "c4", "c4");
|
||||||
|
|
||||||
|
t._branches[2]->_branches[0]->tag ("one");
|
||||||
|
t._branches[2]->_branches[0]->tag ("two");
|
||||||
|
ut.ok (t._branches[2]->_branches[0]->hasTag ("one"), "hasTag +");
|
||||||
|
ut.notok (t._branches[2]->_branches[0]->hasTag ("three"), "hasTag -");
|
||||||
|
|
||||||
|
t._branches[2]->_branches[0]->unTag ("one");
|
||||||
|
ut.notok (t._branches[2]->_branches[0]->hasTag ("one"), "unTag");
|
||||||
|
|
||||||
|
ut.is (t.count (), 5, "t.count");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue