Tree Container Library: Examples: Polymorphic
tree

The Tree Container Library

A C++ generic tree container library which, not only works much like the STL, but is also compatible with the STL algorithms. The Tree Container Library is used worldwide in thousands of industries and organizations. It is completely free to use, and is licensed under the zlib/libpng license.

The TCL Test Suite is a group of classes and operations which were created to vigorously test all operations of all four tree containers in the TCL. This suite is a never ending project, so check back often for the latest Test Suite. The updated date will be provided on the download button below, to keep you informed of any changes made to this test suite. This test suite is compatible with VC7, VC8, and gcc. At this time, the test suite is not compatible with VC6.

The suite is used to check for insure proper operations for every tree interface. These tests are especially important during development and after any TCL implementation change, to insure that no operations were broken during modification of TCL's source code.

There are three good reasons you may want to download and use this test suite:

  • To study the source code in the test suite, to gain insight on using the library.
    Although the examples on this site give you a good idea on how to use the TCL, the source code in the test suite are a little more advanced. Studying the code may give you insight on different ways to use the TCL which you have not previously considered.
  • To insure yourself that the TCL is operating properly and as expected.
    If you are unsure about specific operations in the TCL, and how they should perform, studying the tests for those operations in the test suite may give you more insight on the use of those operations.
  • When making your own changes to the TCL.
    If you make any changes to the TCL yourself, this test suite is essential to insure all operations are still working properly.

To use the test suite, place create a test suite project, and add the source code files to the project. The main source file which includes main() is tcl_test_suite.cpp. You may need to edit the include paths for the TCL tree classes, depending on where you're TCL library files reside in respect to the test suite files. For Visual C++ users, you may need to un-comment the top line of the cpp files, #include "stdafx.h", if your project uses pre-compiled headers.

The test suite currently populates the four trees with the hierarchies shown to the right, for testing purposes. The operation populate_tree() populates the trees according to figure 1. The operation insert_double_vowels() in the associative tree tester adds (or attempts to add) duplicate nodes for the vowels, which would result in figure 2. The operation populate_wide_tree() results in the tree hierarchy displayed in figure 3.

When using descendant iterators in the test operations, note carefully which type of descendant iterators are being used, as the order of the node traversal will depend on the type of iterator. The list below displays the traversal order of the tree hierarchy in figure 1, for the three types of descendant iterators.

  • pre_order_iterator: A D J K R S E L B F M T U N V C G H O W P I Q X Y Z
  • post_order_iterator: J R S K D L E A T U M V N F B G W O P H Y Z X Q I C
  • level_order_iterator: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

A tree hierarchy is used for the sequential_tree tests which is similar to that in figure 3, except the nodes are not in alphabetical order within their parent. This allows the proper testing of the sort operations.

Please email me if you have any questions, problems, or suggestions for this test suite.

Download TCL Test Suite for TCL version 5.0.6, Updated 1/01/08

Description Date Updated Download Links
TCL Test SuiteJune 13 2020

Figure 1

Test Suite example hierarchy

Figure 2

Test Suite added vowels

Figure 3

Test Suite wide tree

Figure 1