|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r49489 - in sandbox/SOC/2006/tree/trunk: . boost/tree boost/tree/detail/algorithm libs/tree/test
From: ockham_at_[hidden]
Date: 2008-10-29 20:08:04
Author: bernhard.reiter
Date: 2008-10-29 20:08:01 EDT (Wed, 29 Oct 2008)
New Revision: 49489
URL: http://svn.boost.org/trac/boost/changeset/49489
Log:
Introduce insert_cursor.
Added:
sandbox/SOC/2006/tree/trunk/boost/tree/insert_cursor.hpp (contents, props changed)
Text files modified:
sandbox/SOC/2006/tree/trunk/TODO | 5 +
sandbox/SOC/2006/tree/trunk/boost/tree/binary_tree.hpp | 1
sandbox/SOC/2006/tree/trunk/boost/tree/cursor_adaptor.hpp | 3
sandbox/SOC/2006/tree/trunk/boost/tree/detail/algorithm/preorder.hpp | 2
sandbox/SOC/2006/tree/trunk/boost/tree/root_tracking_cursor.hpp | 6
sandbox/SOC/2006/tree/trunk/libs/tree/test/binary_tree_search_test.cpp | 18 +-
sandbox/SOC/2006/tree/trunk/libs/tree/test/binary_tree_test.cpp | 116 +++++++++++-----------
sandbox/SOC/2006/tree/trunk/libs/tree/test/cursor_algorithm_test.cpp | 14 ++
sandbox/SOC/2006/tree/trunk/libs/tree/test/forest_tree_test.cpp | 53 ++++++----
sandbox/SOC/2006/tree/trunk/libs/tree/test/graph_test.cpp | 20 ++--
sandbox/SOC/2006/tree/trunk/libs/tree/test/interval_search_binary_tree_test.cpp | 12 +-
sandbox/SOC/2006/tree/trunk/libs/tree/test/iterator_algorithm_test.cpp | 2
sandbox/SOC/2006/tree/trunk/libs/tree/test/key_search_binary_tree_test.cpp | 100 ++++++++++----------
sandbox/SOC/2006/tree/trunk/libs/tree/test/nary_tree_test.cpp | 14 +-
sandbox/SOC/2006/tree/trunk/libs/tree/test/red_black_tree_test.cpp | 64 ++++++------
sandbox/SOC/2006/tree/trunk/libs/tree/test/search_ordered_vector_test.cpp | 10 +-
sandbox/SOC/2006/tree/trunk/libs/tree/test/string_search_binary_tree_test.cpp | 24 ++--
sandbox/SOC/2006/tree/trunk/libs/tree/test/test_tree_traversal_data.hpp | 196 ++++++++++++++++++++--------------------
sandbox/SOC/2006/tree/trunk/libs/tree/test/unbalanced_binary_tree_test.cpp | 24 ++--
19 files changed, 357 insertions(+), 327 deletions(-)
Modified: sandbox/SOC/2006/tree/trunk/TODO
==============================================================================
--- sandbox/SOC/2006/tree/trunk/TODO (original)
+++ sandbox/SOC/2006/tree/trunk/TODO 2008-10-29 20:08:01 EDT (Wed, 29 Oct 2008)
@@ -14,6 +14,11 @@
[section TODO]
General:
+* Future: Optimise insert_cursor for use with binary_tree insert and copy ctor
+ (preorder copy; ideally, we can guarantee RAII for every single element)
+ and clear/dtor (postorder for_each).
+* Get insert_cursor to work with postorder copy, then with linear (ascending cursor)
+ versions. Check with other algorithms that use output cursors.
* Caution: Iterative algorithms require ascending cursors!
* Move some of the secondary stuff to a util/ dir? Is that what they're used for?
* Redo testing. Right now, it's just chaotic.
Modified: sandbox/SOC/2006/tree/trunk/boost/tree/binary_tree.hpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/boost/tree/binary_tree.hpp (original)
+++ sandbox/SOC/2006/tree/trunk/boost/tree/binary_tree.hpp 2008-10-29 20:08:01 EDT (Wed, 29 Oct 2008)
@@ -242,6 +242,7 @@
template <class InputCursor>
cursor insert(cursor pos, InputCursor subtree)
{
+ //boost::tree::copy(boost::tree::preorder(), subtree, pos, forward_traversal_tag());
subtree.to_begin();
insert(pos, *subtree);
if (!subtree.empty())
Modified: sandbox/SOC/2006/tree/trunk/boost/tree/cursor_adaptor.hpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/boost/tree/cursor_adaptor.hpp (original)
+++ sandbox/SOC/2006/tree/trunk/boost/tree/cursor_adaptor.hpp 2008-10-29 20:08:01 EDT (Wed, 29 Oct 2008)
@@ -158,7 +158,8 @@
{
return *m_cursor;
}
-
+
+private:
void increment()
{
++m_cursor;
Modified: sandbox/SOC/2006/tree/trunk/boost/tree/detail/algorithm/preorder.hpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/boost/tree/detail/algorithm/preorder.hpp (original)
+++ sandbox/SOC/2006/tree/trunk/boost/tree/detail/algorithm/preorder.hpp 2008-10-29 20:08:01 EDT (Wed, 29 Oct 2008)
@@ -183,7 +183,7 @@
s.to_begin();
t.to_begin();
- for (; s != r; ++s, ++t) {
+ for (;s != r; ++s, ++t) {
*t = *s;
if (!s.empty())
copy(preorder(), s, t, forward_traversal_tag());
Added: sandbox/SOC/2006/tree/trunk/boost/tree/insert_cursor.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2006/tree/trunk/boost/tree/insert_cursor.hpp 2008-10-29 20:08:01 EDT (Wed, 29 Oct 2008)
@@ -0,0 +1,100 @@
+// Copyright (c) 2006-2008, Bernhard Reiter
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+/**
+ * @file insert_cursor.hpp
+ * Insert cursor implementation
+ */
+
+#ifndef BOOST_TREE_INSERT_CURSOR_HPP
+#define BOOST_TREE_INSERT_CURSOR_HPP
+
+#include <boost/tree/cursor_adaptor.hpp>
+
+namespace boost {
+namespace tree {
+
+using boost::iterator_core_access;
+
+template <class Tree>
+class insert_cursor;
+
+/**
+ * @brief Output cursor wrapper around an output iterator.
+ *
+ * This can be very useful e.g. to have cursor algorithms actually work on
+ * iterators, thus permitting some kind of linearization of a given subtree.
+ * (Modelled after std::insert_iterator and the like.)
+ *
+ * For construction, the outputter_cursor_iterator_wrapper might come in useful
+ * in saving keystrokes.
+ */
+// TODO: Complete this.
+// Shouldn't we be using cursor_facade?
+template <class Tree>
+class insert_cursor
+: public cursor_adaptor<insert_cursor<Tree>
+ , typename Tree::cursor
+// , boost::use_default
+// , boost::use_default
+// , boost::use_default
+ >
+ {
+protected:
+ mutable Tree& tree;
+ mutable bool ins;
+public:
+ /**
+ * For construction, we obviously need a tree and a cursor to work on (i.e., write to).
+ */
+ explicit insert_cursor(Tree& x, typename Tree::cursor cur)
+ : insert_cursor::cursor_adaptor_(cur), tree(x), ins(false) {}
+
+private:
+ friend class boost::iterator_core_access;
+ friend class boost::tree::cursor_core_access;
+
+ typename insert_cursor::cursor_adaptor_::reference dereference() const
+ {
+ if (ins) {
+ const_cast<typename Tree::cursor&>(this->base_reference()) =
+ tree.insert(this->base_reference(), typename Tree::value_type());
+ }
+ return *this->base_reference();
+ }
+
+ void increment()
+ {
+ ins = true;
+ ++this->base_reference();
+ }
+
+ void left()
+ {
+ this->base_reference() =
+ tree.insert(this->base_reference(), typename Tree::value_type());
+ ins = false;
+ }
+
+};
+
+/**
+ * @param o An output iterator.
+ * @result An instance of insert_cursor working on o.
+ *
+ * Use as shortcut for cumbersome typenames, just as with std::inserter and the like.
+ */
+template<class Tree>
+inline insert_cursor<Tree>
+tree_inserter(Tree& t, typename Tree::cursor c)
+{
+ return insert_cursor<Tree>(t, c);
+}
+
+} // namespace tree
+} // namespace boost
+
+#endif // BOOST_TREE_INSERT_CURSOR_HPP
Modified: sandbox/SOC/2006/tree/trunk/boost/tree/root_tracking_cursor.hpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/boost/tree/root_tracking_cursor.hpp (original)
+++ sandbox/SOC/2006/tree/trunk/boost/tree/root_tracking_cursor.hpp 2008-10-29 20:08:01 EDT (Wed, 29 Oct 2008)
@@ -28,9 +28,9 @@
class root_tracking_cursor
: public cursor_adaptor<root_tracking_cursor<Cursor>
, Cursor
- , boost::use_default
- , typename cursor_horizontal_traversal<Cursor>::type
- , typename cursor_vertical_traversal<Cursor>::type
+// , boost::use_default
+// , typename cursor_horizontal_traversal<Cursor>::type
+// , typename cursor_vertical_traversal<Cursor>::type
> {
private:
struct enabler {};
Modified: sandbox/SOC/2006/tree/trunk/libs/tree/test/binary_tree_search_test.cpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/libs/tree/test/binary_tree_search_test.cpp (original)
+++ sandbox/SOC/2006/tree/trunk/libs/tree/test/binary_tree_search_test.cpp 2008-10-29 20:08:01 EDT (Wed, 29 Oct 2008)
@@ -31,8 +31,8 @@
c = lower_bound(r, v);
d = upper_bound(r, v);
- BOOST_CHECK(*c == v);
- //BOOST_CHECK(inorder::next(c) == d);
+ BOOST_CHECK_EQUAL(*c, v);
+ //BOOST_CHECK_EQUAL(inorder::next(c) , d);
}
BOOST_AUTO_TEST_CASE( binary_tree_search_test )
@@ -46,20 +46,20 @@
c = lower_bound(bt.root(), 5); // Not in tree
d = lower_bound(bt.root(), 5);
- BOOST_CHECK(*c == 6);
- BOOST_CHECK(*d == 6);
+ BOOST_CHECK_EQUAL(*c, 6);
+ BOOST_CHECK_EQUAL(*d, 6);
*c = 4;
c = lower_bound(bt.root(), 5); // Not in tree
- BOOST_CHECK(*c == 7);
+ BOOST_CHECK_EQUAL(*c, 7);
c = lower_bound(bt.root(), 4); // Twice in tree
d = upper_bound(bt.root(), 4);
- BOOST_CHECK(*c == 4);
- BOOST_CHECK(*d == 7);
- BOOST_CHECK(*c.parent() == 4);
- //BOOST_CHECK(inorder::next(c, 2) == d);
+ BOOST_CHECK_EQUAL(*c, 4);
+ BOOST_CHECK_EQUAL(*d, 7);
+ BOOST_CHECK_EQUAL(*c.parent(), 4);
+ //BOOST_CHECK_EQUAL(inorder::next(c, 2), d);
*c.to_parent() = 6;
validate_test_data_tree(bt);
Modified: sandbox/SOC/2006/tree/trunk/libs/tree/test/binary_tree_test.cpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/libs/tree/test/binary_tree_test.cpp (original)
+++ sandbox/SOC/2006/tree/trunk/libs/tree/test/binary_tree_test.cpp 2008-10-29 20:08:01 EDT (Wed, 29 Oct 2008)
@@ -29,7 +29,7 @@
BOOST_CHECK(c.empty());
c1 = mytree.insert(c, 1);
- BOOST_CHECK(*c1 == 1);
+ BOOST_CHECK_EQUAL(*c1, 1);
BOOST_CHECK(!c.empty());
@@ -41,18 +41,18 @@
c2 = mytree.insert(c1, 2);
BOOST_CHECK(!c.empty());
BOOST_CHECK(c2.empty());
- BOOST_CHECK(*c1 == 1);
- BOOST_CHECK(*c2 == 2);
+ BOOST_CHECK_EQUAL(*c1, 1);
+ BOOST_CHECK_EQUAL(*c2, 2);
*c1 = 14;
- BOOST_CHECK(*c1 == 14);
- BOOST_CHECK(*c2 == 2);
+ BOOST_CHECK_EQUAL(*c1, 14);
+ BOOST_CHECK_EQUAL(*c2, 2);
BOOST_CHECK(c2.parent() == c1);
BOOST_CHECK(c1.parent() == c);
c3 = c1.end();
BOOST_CHECK(c3 == c1.end());
--c3;
- BOOST_CHECK(c3.parity() == 0);
+ BOOST_CHECK_EQUAL(c3.parity(), 0);
BOOST_CHECK(c3.parent() != c3);
BOOST_CHECK(c3.parent() == c1);
BOOST_CHECK(c3 == c1.begin());
@@ -60,24 +60,24 @@
*c3 = 3;
*(c1.begin()) = 2;
- BOOST_CHECK(*c3 == 2);
+ BOOST_CHECK_EQUAL(*c3, 2);
++c3;
c4 = mytree.insert(c3, 4);
- BOOST_CHECK(*c4 == 4);
+ BOOST_CHECK_EQUAL(*c4, 4);
c4 = c4.parent();
--c4;
- BOOST_CHECK(*c4 == 2);
+ BOOST_CHECK_EQUAL(*c4, 2);
BOOST_CHECK(c4.parent() == c1);
c = boost::tree::lower_bound(mytree.root(), 2, std::less<int>());
- BOOST_CHECK(*c == 2);
+ BOOST_CHECK_EQUAL(*c, 2);
BOOST_CHECK(c4.empty());
- BOOST_CHECK(*c1 == 14);
+ BOOST_CHECK_EQUAL(*c1, 14);
BOOST_CHECK(c1.begin().empty() || c1.end().empty());
//c1 = mytree.erase(c1);
- //BOOST_CHECK(*c1 == 2);
+ //BOOST_CHECK_EQUAL(*c1, 2);
}
@@ -85,28 +85,28 @@
void inorder_erase_test_data_tree(Tree& mytree)
{
typename Tree::cursor c = mytree.root().end().end().begin();
- BOOST_CHECK(*c == 14);
+ BOOST_CHECK_EQUAL(*c, 14);
c = c.parent().parent();
- BOOST_CHECK(*(c.begin()) == 10);
+ BOOST_CHECK_EQUAL(*(c.begin()), 10);
BOOST_CHECK(c.begin().empty());
BOOST_CHECK(!c.end().empty());
- BOOST_CHECK(*c.end().begin() == 14);
+ BOOST_CHECK_EQUAL(*c.end().begin(), 14);
c = c.begin();
// Left child empty
c = mytree.inorder_erase(c);
- BOOST_CHECK(*c == 11);
+ BOOST_CHECK_EQUAL(*c, 11);
++c;
- BOOST_CHECK(*c.begin() == 12);
+ BOOST_CHECK_EQUAL(*c.begin(), 12);
BOOST_CHECK(c.begin().empty());
BOOST_CHECK(c.end().empty());
c = c.begin();
// Both children empty
c = mytree.inorder_erase(c);
- BOOST_CHECK(*c == 13);
+ BOOST_CHECK_EQUAL(*c, 13);
}
template <class Tree>
@@ -126,15 +126,15 @@
c1 = c.begin();
BOOST_CHECK(c1.parent() == c);
- BOOST_CHECK(*c1 == 14);
+ BOOST_CHECK_EQUAL(*c1, 14);
c2 = c1.begin();
BOOST_CHECK(c2.parent() == c1);
- BOOST_CHECK(*c2 == 2);
+ BOOST_CHECK_EQUAL(*c2, 2);
c3 = c1.end();
BOOST_CHECK(c3.parent() == c1);
- BOOST_CHECK(*c3.begin() == 4);
+ BOOST_CHECK_EQUAL(*c3.begin(), 4);
}
@@ -188,7 +188,7 @@
// Insert subtree
tree_t::cursor c = bt.insert(bt.root(), tree1.root());
- BOOST_CHECK(*c == 8);
+ BOOST_CHECK_EQUAL(*c, 8);
validate_test_data_tree(bt);
// Copy constructor
@@ -208,10 +208,10 @@
BOOST_CHECK(bt == tree3);
c = tree3.inorder_first();
- BOOST_CHECK(*c == 1);
+ BOOST_CHECK_EQUAL(*c, 1);
c = tree3.root();
//inorder::back(c);
- //BOOST_CHECK(*c == 14);
+ //BOOST_CHECK_EQUAL(*c, 14);
destroy_binary_tree(bt);
bt.splice(bt.root(), tree3);
@@ -219,67 +219,67 @@
BOOST_CHECK(tree3.empty());
validate_test_data_tree(bt);
c = bt.inorder_first();
- BOOST_CHECK(*c == 1);
+ BOOST_CHECK_EQUAL(*c, 1);
- inorder_erase_test_data_tree(bt);
+ //inorder_erase_test_data_tree(bt);
}
BOOST_AUTO_TEST_CASE( rotate_binary_tree_test )
{
binary_tree<int>::cursor c = bt.root().begin().end();
- BOOST_CHECK(*c.begin() == 6);
+ BOOST_CHECK_EQUAL(*c.begin(), 6);
- BOOST_CHECK(*c.parent() == 8);
- BOOST_CHECK(*c.parent().begin() == 3); // invariant candidate
+ BOOST_CHECK_EQUAL(*c.parent(), 8);
+ BOOST_CHECK_EQUAL(*c.parent().begin(), 3); // invariant candidate
- BOOST_CHECK(*--c == 3); // differently (not invariantly!) spoken
- BOOST_CHECK(*c.begin() == 1);
- BOOST_CHECK(*((++c).begin()).begin() == 4);
- BOOST_CHECK(*(++c.begin()).begin() == 7);
+ BOOST_CHECK_EQUAL(*--c, 3); // differently (not invariantly!) spoken
+ BOOST_CHECK_EQUAL(*c.begin(), 1);
+ BOOST_CHECK_EQUAL(*((++c).begin()).begin(), 4);
+ BOOST_CHECK_EQUAL(*(++c.begin()).begin(), 7);
- BOOST_CHECK(c.parity() == 1);
- BOOST_CHECK(*c.begin() == 6);
+ BOOST_CHECK_EQUAL(c.parity(), 1);
+ BOOST_CHECK_EQUAL(*c.begin(), 6);
bt.rotate(c); // Left rotate
- BOOST_CHECK(*c.begin() == 6);
- BOOST_CHECK(*c.parent().begin() == 8);
+ BOOST_CHECK_EQUAL(*c.begin(), 6);
+ BOOST_CHECK_EQUAL(*c.parent().begin(), 8);
- BOOST_CHECK(*c.end().begin() == 7);
- BOOST_CHECK(*c.begin().begin() == 3);
- BOOST_CHECK(*c.begin().begin().begin() == 1);
+ BOOST_CHECK_EQUAL(*c.end().begin(), 7);
+ BOOST_CHECK_EQUAL(*c.begin().begin(), 3);
+ BOOST_CHECK_EQUAL(*c.begin().begin().begin(), 1);
- BOOST_CHECK(*c.begin().end().begin() == 4);
+ BOOST_CHECK_EQUAL(*c.begin().end().begin(), 4);
c = c.begin();
- BOOST_CHECK(*c.begin() == 3);
+ BOOST_CHECK_EQUAL(*c.begin(), 3);
bt.rotate(c); // Right rotate
- BOOST_CHECK(*c.begin() == 3);
+ BOOST_CHECK_EQUAL(*c.begin(), 3);
c = c.end();
- BOOST_CHECK(*c.begin() == 6);
+ BOOST_CHECK_EQUAL(*c.begin(), 6);
- BOOST_CHECK(*c.parent() == 8);
- BOOST_CHECK(*c.parent().begin() == 3); // other invariant candidate
+ BOOST_CHECK_EQUAL(*c.parent(), 8);
+ BOOST_CHECK_EQUAL(*c.parent().begin(), 3); // other invariant candidate
- BOOST_CHECK(*--c == 3);
- BOOST_CHECK(*c.begin() == 1);
- BOOST_CHECK(*((++c).begin()).begin() == 4);
- BOOST_CHECK(*(++c.begin()).begin() == 7);
+ BOOST_CHECK_EQUAL(*--c, 3);
+ BOOST_CHECK_EQUAL(*c.begin(), 1);
+ BOOST_CHECK_EQUAL(*((++c).begin()).begin(), 4);
+ BOOST_CHECK_EQUAL(*(++c.begin()).begin(), 7);
- BOOST_CHECK(*c.begin() == 6);
+ BOOST_CHECK_EQUAL(*c.begin(), 6);
-// BOOST_CHECK(*c.parent().parent().begin() == 6);
-// BOOST_CHECK(*c.parent().parent().end().begin() == 7);
+// BOOST_CHECK_EQUAL(*c.parent().parent().begin(), 6);
+// BOOST_CHECK_EQUAL(*c.parent().parent().end().begin(), 7);
-// BOOST_CHECK(*c.begin() == 1);
-// BOOST_CHECK(*c.parent().begin() == 3); // invariant?
+// BOOST_CHECK_EQUAL(*c.begin(), 1);
+// BOOST_CHECK_EQUAL(*c.parent().begin(), 3); // invariant?
//
-// BOOST_CHECK(*c.parent().parent().begin() == 6);
-// BOOST_CHECK(*c.parent().parent().parent().begin() == 8);
-// BOOST_CHECK(*c.parent().parent().end().begin() == 7);
+// BOOST_CHECK_EQUAL(*c.parent().parent().begin(), 6);
+// BOOST_CHECK_EQUAL(*c.parent().parent().parent().begin(), 8);
+// BOOST_CHECK_EQUAL(*c.parent().parent().end().begin(), 7);
}
Modified: sandbox/SOC/2006/tree/trunk/libs/tree/test/cursor_algorithm_test.cpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/libs/tree/test/cursor_algorithm_test.cpp (original)
+++ sandbox/SOC/2006/tree/trunk/libs/tree/test/cursor_algorithm_test.cpp 2008-10-29 20:08:01 EDT (Wed, 29 Oct 2008)
@@ -8,6 +8,8 @@
#include <boost/tree/iterator.hpp>
#include <boost/tree/algorithm.hpp>
+#include <boost/tree/insert_cursor.hpp>
+
#include <boost/lambda/bind.hpp>
#include <list>
@@ -44,6 +46,18 @@
test_traversal(Order(), l.begin(), l.end());
}
+typedef boost::mpl::list<preorder,inorder/*,postorder*/> preandinorders; //FIXME
+
+BOOST_AUTO_TEST_CASE_TEMPLATE ( test_copy2, Order, preandinorders )
+{
+ //boost::unit_test::unit_test_log.set_threshold_level(boost::unit_test::log_messages ) ;
+ bt2.clear();
+ l.clear();
+ boost::tree::copy(Order(), bt.root(), tree_inserter(bt2, bt2.root()), boost::forward_traversal_tag());
+ boost::tree::copy(Order(), bt2.root(), o);
+ validate_test_data_tree(bt2);
+}
+
BOOST_AUTO_TEST_CASE_TEMPLATE( test_transform, Order, orders)
{
// First copy test_tree to test_tree2, by adding 1 to each element,
Modified: sandbox/SOC/2006/tree/trunk/libs/tree/test/forest_tree_test.cpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/libs/tree/test/forest_tree_test.cpp (original)
+++ sandbox/SOC/2006/tree/trunk/libs/tree/test/forest_tree_test.cpp 2008-10-29 20:08:01 EDT (Wed, 29 Oct 2008)
@@ -9,14 +9,23 @@
#include <boost/lambda/bind.hpp>
+#include <boost/mpl/list.hpp>
+#include <boost/mpl/pair.hpp>
+
#include <list>
#define BOOST_TEST_MODULE forest_tree test
//#define BOOST_TEST_DYN_LINK
#include <boost/test/included/unit_test.hpp>
+#include <boost/test/test_case_template.hpp>
#include "test_tree_traversal_data.hpp"
+using namespace boost::tree;
+
+typedef boost::mpl::list< boost::mpl::pair<preorder, preorder>
+ /*, boost::mpl::pair<postorder, inorder>*/ > order_pairs;
+
BOOST_FIXTURE_TEST_SUITE(forest_algorithms_test, test_binary_tree_with_list_fixture<int>)
BOOST_AUTO_TEST_CASE( forest_tree_test )
@@ -28,33 +37,33 @@
tree_type::cursor c = mytree.root();
c = mytree.insert(c, 6);
- BOOST_CHECK(*c == 6);
+ BOOST_CHECK_EQUAL(*c, 6);
c = mytree.insert(c, 5);
- BOOST_CHECK(*c == 5);
+ BOOST_CHECK_EQUAL(*c, 5);
c = mytree.insert(c, 4);
- BOOST_CHECK(*c == 4);
+ BOOST_CHECK_EQUAL(*c, 4);
BOOST_CHECK(c == mytree.root().begin());
++c;
- BOOST_CHECK(*c == 5);
+ BOOST_CHECK_EQUAL(*c, 5);
++c;
- BOOST_CHECK(*c == 6);
+ BOOST_CHECK_EQUAL(*c, 6);
tree_type forest;
//create_test_data_tree(forest);
c = forest.insert(forest.root(), 8);
BOOST_CHECK(c == forest.root().begin());
- BOOST_CHECK(*c == 8);
+ BOOST_CHECK_EQUAL(*c, 8);
c = forest.insert(c, 3);
- BOOST_CHECK(*c == 3);
- BOOST_CHECK(*++c == 8);
-// BOOST_CHECK(*forest.root().begin().begin() == 3);
+ BOOST_CHECK_EQUAL(*c, 3);
+ BOOST_CHECK_EQUAL(*++c, 8);
+// BOOST_CHECK_EQUAL(*forest.root().begin().begin(), 3);
}
-BOOST_AUTO_TEST_CASE( test_natural_correspondence )
+BOOST_AUTO_TEST_CASE_TEMPLATE( test_natural_correspondence, Order, order_pairs )
{
using namespace boost::tree;
@@ -74,29 +83,29 @@
oc_bi_lst_type oc_test_list = oc_bi_lst_type(it_test_list);
boost::tree::for_each(
- preorder(),
+ typename Order::first(),
ft.root(),
boost::lambda::bind(&std::list<int>::push_back, &test_list, boost::lambda::_1)
);
- test_traversal(preorder(), test_list.begin(), test_list.end());
- BOOST_CHECK(test_list.size() == 11);
+ test_traversal(typename Order::second(), test_list.begin(), test_list.end());
+ BOOST_CHECK_EQUAL(test_list.size(), 11);
test_list.clear();
- boost::tree::copy(preorder(), ft.root(), oc_test_list);
- test_traversal(preorder(), test_list.begin(), test_list.end());
- BOOST_CHECK(test_list.size() == 11);
+ boost::tree::copy(typename Order::first(), ft.root(), oc_test_list);
+ test_traversal(typename Order::second(), test_list.begin(), test_list.end());
+ BOOST_CHECK_EQUAL(test_list.size(), 11);
test_list.clear();
- boost::tree::transform(preorder(), ft.root(), oc_test_list, std::bind2nd(std::plus<int>(),0));
- test_traversal(preorder(), test_list.begin(), test_list.end());
- BOOST_CHECK(test_list.size() == 11);
+ boost::tree::transform(typename Order::first(), ft.root(), oc_test_list, std::bind2nd(std::plus<int>(),0));
+ test_traversal(typename Order::second(), test_list.begin(), test_list.end());
+ BOOST_CHECK_EQUAL(test_list.size(), 11);
test_list.clear();
//test::preorder::algorithms(ft.root(), ft.root()); // FIXME: Fix algorithms for use in here.
- boost::tree::copy(postorder(), ft.root(), oc_test_list);
- test_traversal(inorder(), test_list.begin(), test_list.end());
- BOOST_CHECK(test_list.size() == 11);
+// boost::tree::copy(typename Order::first(), ft.root(), oc_test_list);
+// test_traversal(typename Order::second(), test_list.begin(), test_list.end());
+// BOOST_CHECK_EQUAL(test_list.size(), 11);
}
Modified: sandbox/SOC/2006/tree/trunk/libs/tree/test/graph_test.cpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/libs/tree/test/graph_test.cpp (original)
+++ sandbox/SOC/2006/tree/trunk/libs/tree/test/graph_test.cpp 2008-10-29 20:08:01 EDT (Wed, 29 Oct 2008)
@@ -59,13 +59,13 @@
boost::tree::cursor_value<cursor>::type::extract_meta
> cpm;
- BOOST_CHECK(get(dpm, bt.root()) == 8); // Check the entire tree?
- BOOST_CHECK(get(cpm, bt.root()) == Color::white());
+ BOOST_CHECK_EQUAL(get(dpm, bt.root()), 8); // Check the entire tree?
+ BOOST_CHECK_EQUAL(get(cpm, bt.root()), Color::white());
put(cpm, bt.root(), Color::gray());
- BOOST_CHECK(get(cpm, bt.root()) == Color::gray());
+ BOOST_CHECK_EQUAL(get(cpm, bt.root()), Color::gray());
put(cpm, bt.root(), Color::white());
- BOOST_CHECK(get(cpm, bt.root()) == Color::white());
+ BOOST_CHECK_EQUAL(get(cpm, bt.root()), Color::white());
boost::dfs_visitor<
boost::property_writer<
@@ -90,10 +90,10 @@
w = bt.root().begin().end().begin();
default_color_type color = get(cpm, w);
- BOOST_CHECK(color == Color::white());
+ BOOST_CHECK_EQUAL(color, Color::white());
put(cpm, w, Color::white());
- BOOST_CHECK(get(cpm, w) == Color::white());
+ BOOST_CHECK_EQUAL(get(cpm, w), Color::white());
BOOST_CHECK(!empty_cursor(v, bt));
@@ -105,14 +105,14 @@
BOOST_CHECK(target(*oei, bt) == bt.root().begin());
BOOST_CHECK(target(*oei_end, bt) == bt.root());
- BOOST_CHECK(out_degree(v, bt) == 2);
+ BOOST_CHECK_EQUAL(out_degree(v, bt), 2);
//
-// BOOST_CHECK(test_list.size() == 2);
+// BOOST_CHECK_EQUAL(test_list.size(), 2);
//
// std::list<int>::const_iterator ci = test_list.begin();
//
-// BOOST_CHECK(*ci == 8);
-// BOOST_CHECK(*++ci == 10); //FIXME
+// BOOST_CHECK_EQUAL(*ci, 8);
+// BOOST_CHECK_EQUAL(*++ci, 10); //FIXME
// test::preorder::traversal(test_list.begin(), test_list.end());
Modified: sandbox/SOC/2006/tree/trunk/libs/tree/test/interval_search_binary_tree_test.cpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/libs/tree/test/interval_search_binary_tree_test.cpp (original)
+++ sandbox/SOC/2006/tree/trunk/libs/tree/test/interval_search_binary_tree_test.cpp 2008-10-29 20:08:01 EDT (Wed, 29 Oct 2008)
@@ -52,11 +52,11 @@
my_tree.insert(interval<int>(29,99));
searcher_t::iterator ci = my_tree.begin();
- BOOST_CHECK(*ci++ == interval<int>( 0, 1));
-// BOOST_CHECK(*ci++ == interval<int>( 3,41));
- BOOST_CHECK(*ci++ == interval<int>(10,15));
-// BOOST_CHECK(*ci++ == interval<int>(20,36));
-// BOOST_CHECK(*ci++ == interval<int>(29,99));
-// BOOST_CHECK(ci == my_tree.end());
+ BOOST_CHECK_EQUAL(*ci++, interval<int>( 0, 1));
+// BOOST_CHECK_EQUAL(*ci++, interval<int>( 3,41));
+ BOOST_CHECK_EQUAL(*ci++, interval<int>(10,15));
+// BOOST_CHECK_EQUAL(*ci++, interval<int>(20,36));
+// BOOST_CHECK_EQUAL(*ci++, interval<int>(29,99));
+// BOOST_CHECK_EQUAL(ci, my_tree.end());
}
Modified: sandbox/SOC/2006/tree/trunk/libs/tree/test/iterator_algorithm_test.cpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/libs/tree/test/iterator_algorithm_test.cpp (original)
+++ sandbox/SOC/2006/tree/trunk/libs/tree/test/iterator_algorithm_test.cpp 2008-10-29 20:08:01 EDT (Wed, 29 Oct 2008)
@@ -196,7 +196,7 @@
// binary_tree<int>::cursor c = test_tree.root();
// boost::tree::iterator<ascending, binary_tree<int>::cursor> ai_root(c);
// c = c.begin().end().begin().begin();
-// BOOST_CHECK(*c == 4);
+// BOOST_CHECK_EQUAL(*c, 4);
//
// boost::tree::iterator<ascending, binary_tree<int>::cursor> ais(c);
// test_traversal_from_leaf4(ais, ai_root);
Modified: sandbox/SOC/2006/tree/trunk/libs/tree/test/key_search_binary_tree_test.cpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/libs/tree/test/key_search_binary_tree_test.cpp (original)
+++ sandbox/SOC/2006/tree/trunk/libs/tree/test/key_search_binary_tree_test.cpp 2008-10-29 20:08:01 EDT (Wed, 29 Oct 2008)
@@ -29,17 +29,17 @@
//std::pair<searcher_t::iterator, std::pair<bool, bool> > ret;
c = my_tree.end();
- BOOST_CHECK(c == my_tree.end());
- BOOST_CHECK(c == my_tree.begin());
+ BOOST_CHECK_EQUAL(c, my_tree.end());
+ BOOST_CHECK_EQUAL(c, my_tree.begin());
// searcher_t::cursor cur = searcher_t::cursor(c);
// BOOST_CHECK(cur.empty());
-// BOOST_CHECK(cur == searcher_t::cursor(my_tree.end()));
+// BOOST_CHECK_EQUAL(cur, searcher_t::cursor(my_tree.end()));
c1 = my_tree.insert(c, 8);
- BOOST_CHECK(*c1 == 8);
-// BOOST_CHECK(searcher_t::cursor(c1).parity() == 0);
+ BOOST_CHECK_EQUAL(*c1, 8);
+// BOOST_CHECK_EQUAL(searcher_t::cursor(c1).parity(), 0);
BOOST_CHECK(c != my_tree.end());
BOOST_CHECK(c1 != my_tree.end());
@@ -49,43 +49,43 @@
//
// cur = cur.parent(); //header-cursor(,1) (root)
// BOOST_CHECK(!cur.parity());
-// BOOST_CHECK(searcher_t::iterator(cur) == my_tree.end());
+// BOOST_CHECK_EQUAL(searcher_t::iterator(cur), my_tree.end());
BOOST_CHECK(*c1 = 8);
- BOOST_CHECK(++c1 == my_tree.end());
+ BOOST_CHECK_EQUAL(++c1, my_tree.end());
--c1;
- BOOST_CHECK(*c1 == 8);
+ BOOST_CHECK_EQUAL(*c1, 8);
-// BOOST_CHECK(searcher_t::cursor(my_tree.end()).parity() == 1);
+// BOOST_CHECK_EQUAL(searcher_t::cursor(my_tree.end()).parity(), 1);
//
-// BOOST_CHECK(cur.end().parity() == 1);
+// BOOST_CHECK_EQUAL(cur.end().parity(), 1);
//
// cur = searcher_t::cursor(c1);
//
-// BOOST_CHECK(*cur == 8);
+// BOOST_CHECK_EQUAL(*cur, 8);
//
// BOOST_CHECK((++cur).empty());
// BOOST_CHECK(!(--cur).parent().parity()); // root's parity...
//
-// BOOST_CHECK(*(searcher_t::cursor(c).begin()) == 8);
+// BOOST_CHECK_EQUAL(*(searcher_t::cursor(c).begin()), 8);
- BOOST_CHECK(*c1 == 8);
- BOOST_CHECK(++c1 == my_tree.end());
+ BOOST_CHECK_EQUAL(*c1, 8);
+ BOOST_CHECK_EQUAL(++c1, my_tree.end());
// root (e.g. c) instead of c1 would crash this. but should that be really
// illegal?
c2 = my_tree.insert(c1, 18);
- BOOST_CHECK(*c2 == 18);
+ BOOST_CHECK_EQUAL(*c2, 18);
++c2;
- BOOST_CHECK(c2 == my_tree.end());
+ BOOST_CHECK_EQUAL(c2, my_tree.end());
c = my_tree.end();
--c;
- BOOST_CHECK(*c == 18);
+ BOOST_CHECK_EQUAL(*c, 18);
c2 = my_tree.insert(c, 31);
@@ -94,19 +94,19 @@
c4 = my_tree.insert(c, 7);
- BOOST_CHECK(*c4 == 7);
+ BOOST_CHECK_EQUAL(*c4, 7);
- BOOST_CHECK(++c2 == my_tree.end());
+ BOOST_CHECK_EQUAL(++c2, my_tree.end());
c = my_tree.end();
--c;
BOOST_CHECK(*c != 39);
- BOOST_CHECK(*c == 412);
+ BOOST_CHECK_EQUAL(*c, 412);
--c;
- BOOST_CHECK(*c == 39);
+ BOOST_CHECK_EQUAL(*c, 39);
c = my_tree.begin();
-// BOOST_CHECK(searcher_t::cursor(c).parity() == 0);
+// BOOST_CHECK_EQUAL(searcher_t::cursor(c).parity(), 0);
// BOOST_CHECK(*(searcher_t::cursor(c).parent()) != 412);
BOOST_CHECK(*c < 413);
@@ -117,57 +117,57 @@
// BOOST_CHECK(tree_cur.empty());
// BOOST_CHECK((++tree_cur).empty());
// --tree_cur;
-// BOOST_CHECK(*tree_cur == 39);
+// BOOST_CHECK_EQUAL(*tree_cur, 39);
//
// tree_cur = boost::tree::lower_bound(the_tree.root(), 18);
-// BOOST_CHECK(*tree_cur == 18);
+// BOOST_CHECK_EQUAL(*tree_cur, 18);
//
// tree_cur = boost::tree::lower_bound(the_tree.root(), 30);
// BOOST_CHECK(tree_cur.empty());
// BOOST_CHECK(!(++tree_cur).empty());
// --tree_cur;
-// BOOST_CHECK(*tree_cur == 31);
+// BOOST_CHECK_EQUAL(*tree_cur, 31);
//
// tree_cur = boost::tree::lower_bound(the_tree.root(), 3);
-// BOOST_CHECK(*tree_cur == 7);
+// BOOST_CHECK_EQUAL(*tree_cur, 7);
c = my_tree.begin();
- BOOST_CHECK(*c++ == 7);
- BOOST_CHECK(*c++ == 8);
- BOOST_CHECK(*c++ == 18);
- BOOST_CHECK(*c++ == 31);
- BOOST_CHECK(*c++ == 39);
- BOOST_CHECK(*c++ == 412);
- BOOST_CHECK(c == my_tree.end());
- BOOST_CHECK(*--c == 412);
- BOOST_CHECK(*--c == 39);
- BOOST_CHECK(*--c == 31);
- BOOST_CHECK(*--c == 18);
- BOOST_CHECK(*--c == 8);
- BOOST_CHECK(*--c == 7);
- BOOST_CHECK(c == my_tree.begin());
+ BOOST_CHECK_EQUAL(*c++, 7);
+ BOOST_CHECK_EQUAL(*c++, 8);
+ BOOST_CHECK_EQUAL(*c++, 18);
+ BOOST_CHECK_EQUAL(*c++, 31);
+ BOOST_CHECK_EQUAL(*c++, 39);
+ BOOST_CHECK_EQUAL(*c++, 412);
+ BOOST_CHECK_EQUAL(c, my_tree.end());
+ BOOST_CHECK_EQUAL(*--c, 412);
+ BOOST_CHECK_EQUAL(*--c, 39);
+ BOOST_CHECK_EQUAL(*--c, 31);
+ BOOST_CHECK_EQUAL(*--c, 18);
+ BOOST_CHECK_EQUAL(*--c, 8);
+ BOOST_CHECK_EQUAL(*--c, 7);
+ BOOST_CHECK_EQUAL(c, my_tree.begin());
while (c != my_tree.end())
++c;
------c;
- BOOST_CHECK(*c == 31);
+ BOOST_CHECK_EQUAL(*c, 31);
//my_tree.erase(c);
- //BOOST_CHECK(*c == 39);
+ //BOOST_CHECK_EQUAL(*c, 39);
// tree_cur = boost::tree::lower_bound(the_tree.root(), 412);
-// BOOST_CHECK(*tree_cur == 412);
-// BOOST_CHECK(*tree_cur.parent() == 18);
+// BOOST_CHECK_EQUAL(*tree_cur, 412);
+// BOOST_CHECK_EQUAL(*tree_cur.parent(), 18);
//
// c = my_tree.begin();
-// BOOST_CHECK(*c++ == 7);
-// BOOST_CHECK(*c++ == 8);
-// BOOST_CHECK(*c++ == 18);
-// BOOST_CHECK(*c++ == 39);
-// BOOST_CHECK(*c++ == 412);
-// BOOST_CHECK(c == my_tree.end());
+// BOOST_CHECK_EQUAL(*c++, 7);
+// BOOST_CHECK_EQUAL(*c++, 8);
+// BOOST_CHECK_EQUAL(*c++, 18);
+// BOOST_CHECK_EQUAL(*c++, 39);
+// BOOST_CHECK_EQUAL(*c++, 412);
+// BOOST_CHECK_EQUAL(c, my_tree.end());
}
Modified: sandbox/SOC/2006/tree/trunk/libs/tree/test/nary_tree_test.cpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/libs/tree/test/nary_tree_test.cpp (original)
+++ sandbox/SOC/2006/tree/trunk/libs/tree/test/nary_tree_test.cpp 2008-10-29 20:08:01 EDT (Wed, 29 Oct 2008)
@@ -21,22 +21,22 @@
BOOST_CHECK(c.empty());
c = mytree.insert(c, 4);
- BOOST_CHECK(*c == 4);
- BOOST_CHECK(c == mytree.root());
+ BOOST_CHECK_EQUAL(*c, 4);
+ BOOST_CHECK_EQUAL(c, mytree.root());
BOOST_CHECK(c.empty());
c = mytree.insert(c, 5);
- BOOST_CHECK(*c == 5);
- BOOST_CHECK(c == mytree.root());
+ BOOST_CHECK_EQUAL(*c, 5);
+ BOOST_CHECK_EQUAL(c, mytree.root());
++c;
- BOOST_CHECK(*c == 4);
+ BOOST_CHECK_EQUAL(*c, 4);
BOOST_CHECK(c != mytree.root());
BOOST_CHECK(c.empty());
// BOOST_CHECK(c.m_cur != tree_type::node_type::nil());
mytree.insert(c.end(), 3);
- BOOST_CHECK(*(c.begin()) == 3);
+ BOOST_CHECK_EQUAL(*(c.begin()), 3);
BOOST_CHECK(!c.empty());
- BOOST_CHECK(c == c.begin().parent());
+ BOOST_CHECK_EQUAL(c, c.begin().parent());
}
Modified: sandbox/SOC/2006/tree/trunk/libs/tree/test/red_black_tree_test.cpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/libs/tree/test/red_black_tree_test.cpp (original)
+++ sandbox/SOC/2006/tree/trunk/libs/tree/test/red_black_tree_test.cpp 2008-10-29 20:08:01 EDT (Wed, 29 Oct 2008)
@@ -53,7 +53,7 @@
//
// cit = my_searcher.begin();
-// BOOST_CHECK(*c1 == 8);
+// BOOST_CHECK_EQUAL(*c1, 8);
// my_searcher.insert(5);
// my_searcher.insert(it, 7);
@@ -64,35 +64,35 @@
// searcher_t::container_type core = my_searcher.get_container();
// searcher_t::container_type::cursor c = core.root().begin();
-// BOOST_CHECK(*c == 8);
+// BOOST_CHECK_EQUAL(*c, 8);
-// BOOST_CHECK(c1.parent() == c); //Maybe factor out specifc tests (parent(), begin(), ...)
-// BOOST_CHECK(c1 == my_searcher.end().begin()); //FIXME. end means root
+// BOOST_CHECK_EQUAL(c1.parent(), c); //Maybe factor out specifc tests (parent(), begin(), ...)
+// BOOST_CHECK_EQUAL(c1, my_searcher.end().begin()); //FIXME. end means root
// BOOST_CHECK(c1 != my_searcher.end().end()); //ditto
-// BOOST_CHECK(*c1 == 8);
+// BOOST_CHECK_EQUAL(*c1, 8);
// BOOST_CHECK(!c1.has_child());
//
// BOOST_CHECK(c.has_child());
-// BOOST_CHECK(c == my_searcher.end());
+// BOOST_CHECK_EQUAL(c, my_searcher.end());
// ret = key_lower_bound(my_searcher.end(), 18,
// lower_bound_wrapper<mycursor, int, std::less<int> >(),
// boost::multi_index::identity<int>(), std::less<int>());
-// BOOST_CHECK(ret.first == my_searcher.root().end());
+// BOOST_CHECK_EQUAL(ret.first, my_searcher.root().end());
// BOOST_CHECK(ret.second.first);
-// //BOOST_CHECK(ret.first.m_pos == 1);
+// //BOOST_CHECK_EQUAL(ret.first.m_pos, 1);
// c2 = my_searcher.insert(c, 18); //so where does that go?
-// //BOOST_CHECK(c2.parent() == c1);
-// //BOOST_CHECK(c1.end() == c2);
+// //BOOST_CHECK_EQUAL(c2.parent(), c1);
+// //BOOST_CHECK_EQUAL(c1.end(), c2);
// //BOOST_CHECK(c2 != my_searcher.root().end());
//
-// BOOST_CHECK(*c2 == 18);
+// BOOST_CHECK_EQUAL(*c2, 18);
// BOOST_CHECK(!c2.has_child());
//
-// BOOST_CHECK(c2 == my_searcher.root().end().begin());
-// //BOOST_CHECK(c2.m_parent == c.m_parent);
-// //BOOST_CHECK(c2 == c.m_parent);
+// BOOST_CHECK_EQUAL(c2, my_searcher.root().end().begin());
+// //BOOST_CHECK_EQUAL(c2.m_parent, c.m_parent);
+// //BOOST_CHECK_EQUAL(c2, c.m_parent);
// //BOOST_CHECK(c1.has_child()); ///also fails!!!
//
//
@@ -104,46 +104,46 @@
//
// c4 = my_searcher.insert(c, 7);
//
-// BOOST_CHECK(*(c2.parent()) == 31);
-// BOOST_CHECK(*(c2.begin()) == 39);
+// BOOST_CHECK_EQUAL(*(c2.parent()), 31);
+// BOOST_CHECK_EQUAL(*(c2.begin()), 39);
//
-// //BOOST_CHECK(c4.parent() == c1);
+// //BOOST_CHECK_EQUAL(c4.parent(), c1);
//
-// BOOST_CHECK(*c3 == 39);
-// BOOST_CHECK(c4.parent() == c1);
-// BOOST_CHECK(c1.begin() == c4);
+// BOOST_CHECK_EQUAL(*c3, 39);
+// BOOST_CHECK_EQUAL(c4.parent(), c1);
+// BOOST_CHECK_EQUAL(c1.begin(), c4);
//*(mytree.root()) = -5;
//c = my_searcher.root();
//my_searcher.c();
// //*c = 5;
-//// //BOOST_CHECK(*c == 5);
+//// //BOOST_CHECK_EQUAL(*c, 5);
////
// c1 = mytree.insert(c, 1);
-// BOOST_CHECK(*c == 1);
+// BOOST_CHECK_EQUAL(*c, 1);
// c2 = mytree.insert(c1, 2);
-// BOOST_CHECK(*c1 == 1);
-// BOOST_CHECK(*c2 == 2);
+// BOOST_CHECK_EQUAL(*c1, 1);
+// BOOST_CHECK_EQUAL(*c2, 2);
// *c1 = 14; //how can we forbid this? by setting key to int const&
-// BOOST_CHECK(*c1 == 14);
-// BOOST_CHECK(*c2 == 2);
-// BOOST_CHECK(c2.parent() == c1);
-// BOOST_CHECK(c1.parent() == c);
+// BOOST_CHECK_EQUAL(*c1, 14);
+// BOOST_CHECK_EQUAL(*c2, 2);
+// BOOST_CHECK_EQUAL(c2.parent(), c1);
+// BOOST_CHECK_EQUAL(c1.parent(), c);
//
// c3 = c1.end();
// --c3;
-// BOOST_CHECK(*c3 == 2);
+// BOOST_CHECK_EQUAL(*c3, 2);
// ++c3;
// c4 = mytree.insert(c3, 4);
-// BOOST_CHECK(*c4 == 4);
+// BOOST_CHECK_EQUAL(*c4, 4);
// c4 = c4.parent();
// --c4;
-// BOOST_CHECK(*c4 == 2);
+// BOOST_CHECK_EQUAL(*c4, 2);
//
-// //BOOST_CHECK(c4.parent() == c1);
+// //BOOST_CHECK_EQUAL(c4.parent(), c1);
}
Modified: sandbox/SOC/2006/tree/trunk/libs/tree/test/search_ordered_vector_test.cpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/libs/tree/test/search_ordered_vector_test.cpp (original)
+++ sandbox/SOC/2006/tree/trunk/libs/tree/test/search_ordered_vector_test.cpp 2008-10-29 20:08:01 EDT (Wed, 29 Oct 2008)
@@ -30,11 +30,11 @@
// c1 = my_searcher.insert(c1, 8);
//
// c1 = my_searcher.begin();
-// BOOST_CHECK(*c1++ == 6);
-// BOOST_CHECK(*c1++ == 7);
-// BOOST_CHECK(*c1++ == 8);
-// BOOST_CHECK(*c1++ == 18);
-// BOOST_CHECK(c1 == my_searcher.end());
+// BOOST_CHECK_EQUAL(*c1++, 6);
+// BOOST_CHECK_EQUAL(*c1++, 7);
+// BOOST_CHECK_EQUAL(*c1++, 8);
+// BOOST_CHECK_EQUAL(*c1++, 18);
+// BOOST_CHECK_EQUAL(c1, my_searcher.end());
}
//boost::unit_test::test_suite*
Modified: sandbox/SOC/2006/tree/trunk/libs/tree/test/string_search_binary_tree_test.cpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/libs/tree/test/string_search_binary_tree_test.cpp (original)
+++ sandbox/SOC/2006/tree/trunk/libs/tree/test/string_search_binary_tree_test.cpp 2008-10-29 20:08:01 EDT (Wed, 29 Oct 2008)
@@ -40,12 +40,12 @@
//FIXME: const_iterator doesn't work properly yet
searcher_t::iterator ci = my_tree.begin();
- BOOST_CHECK(*ci++ == "anagram");
- BOOST_CHECK(*ci++ == "anodyne");
- BOOST_CHECK(*ci++ == "anteater");
- BOOST_CHECK(*ci++ == "anthology");
- BOOST_CHECK(*ci++ == "anthrax");
- BOOST_CHECK(ci == my_tree.end());
+ BOOST_CHECK_EQUAL(*ci++, "anagram");
+ BOOST_CHECK_EQUAL(*ci++, "anodyne");
+ BOOST_CHECK_EQUAL(*ci++, "anteater");
+ BOOST_CHECK_EQUAL(*ci++, "anthology");
+ BOOST_CHECK_EQUAL(*ci++, "anthrax");
+ BOOST_CHECK_EQUAL(ci, my_tree.end());
}
void test_optimized_string_search_binary_tree()
@@ -68,12 +68,12 @@
//FIXME: const_iterator doesn't work properly yet
searcher_t::iterator ci = my_tree.begin();
- BOOST_CHECK(*ci++ == "anagram");
- BOOST_CHECK(*ci++ == "anodyne");
- BOOST_CHECK(*ci++ == "anteater");
- BOOST_CHECK(*ci++ == "anthology");
- BOOST_CHECK(*ci++ == "anthrax");
- BOOST_CHECK(ci == my_tree.end());
+ BOOST_CHECK_EQUAL(*ci++, "anagram");
+ BOOST_CHECK_EQUAL(*ci++, "anodyne");
+ BOOST_CHECK_EQUAL(*ci++, "anteater");
+ BOOST_CHECK_EQUAL(*ci++, "anthology");
+ BOOST_CHECK_EQUAL(*ci++, "anthrax");
+ BOOST_CHECK_EQUAL(ci, my_tree.end());
}
Modified: sandbox/SOC/2006/tree/trunk/libs/tree/test/test_tree_traversal_data.hpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/libs/tree/test/test_tree_traversal_data.hpp (original)
+++ sandbox/SOC/2006/tree/trunk/libs/tree/test/test_tree_traversal_data.hpp 2008-10-29 20:08:01 EDT (Wed, 29 Oct 2008)
@@ -71,123 +71,123 @@
template <class Tree>
void validate_test_data_tree(Tree const& ret)
{
- BOOST_CHECK(*ret.root().begin() == 8);
- BOOST_CHECK(*ret.root().begin().begin() == 3);
- BOOST_CHECK(*ret.root().begin().begin().begin() == 1); //Leaf
- BOOST_CHECK(*ret.root().begin().end().begin() == 6);
- BOOST_CHECK(*ret.root().begin().end().begin().begin() == 4); //Leaf
- BOOST_CHECK(*ret.root().begin().end().end().begin() == 7); //Leaf
-
- BOOST_CHECK(*ret.root().end().begin() == 10);
- BOOST_CHECK(*ret.root().end().end().begin() == 14);
- BOOST_CHECK(*ret.root().end().end().begin().begin() == 13);
- BOOST_CHECK(*ret.root().end().end().begin().begin().begin() == 11);
- BOOST_CHECK(*ret.root().end().end().begin().begin().end().begin() == 12); //Leaf
+ BOOST_CHECK_EQUAL(*ret.root().begin(), 8);
+ BOOST_CHECK_EQUAL(*ret.root().begin().begin(), 3);
+ BOOST_CHECK_EQUAL(*ret.root().begin().begin().begin(), 1); //Leaf
+ BOOST_CHECK_EQUAL(*ret.root().begin().end().begin(), 6);
+ BOOST_CHECK_EQUAL(*ret.root().begin().end().begin().begin(), 4); //Leaf
+ BOOST_CHECK_EQUAL(*ret.root().begin().end().end().begin(), 7); //Leaf
+
+ BOOST_CHECK_EQUAL(*ret.root().end().begin(), 10);
+ BOOST_CHECK_EQUAL(*ret.root().end().end().begin(), 14);
+ BOOST_CHECK_EQUAL(*ret.root().end().end().begin().begin(), 13);
+ BOOST_CHECK_EQUAL(*ret.root().end().end().begin().begin().begin(), 11);
+ BOOST_CHECK_EQUAL(*ret.root().end().end().begin().begin().end().begin(), 12); //Leaf
}
template <class Tree>
void validate_corresponding_forest_tree(Tree const& t)
{
typename Tree::const_cursor c = t.root().begin();
- BOOST_CHECK(*c == 8);
- BOOST_CHECK(*c.to_begin() == 3);
- BOOST_CHECK(*c.to_begin() == 1);
+ BOOST_CHECK_EQUAL(*c, 8);
+ BOOST_CHECK_EQUAL(*c.to_begin(), 3);
+ BOOST_CHECK_EQUAL(*c.to_begin(), 1);
BOOST_CHECK(c.empty());
BOOST_CHECK(++c == t.root().begin().begin().end());
--c;
c.to_parent();
- BOOST_CHECK(*++c == 6);
- BOOST_CHECK(*c.to_begin() == 4);
+ BOOST_CHECK_EQUAL(*++c, 6);
+ BOOST_CHECK_EQUAL(*c.to_begin(), 4);
c.to_parent();
- BOOST_CHECK(*++c == 7);
+ BOOST_CHECK_EQUAL(*++c, 7);
BOOST_CHECK(++c == t.root().begin().end());
c = t.root().begin();
- BOOST_CHECK(*++c == 10);
- BOOST_CHECK(*++c == 14);
+ BOOST_CHECK_EQUAL(*++c, 10);
+ BOOST_CHECK_EQUAL(*++c, 14);
BOOST_CHECK(++c == t.root().end());
--c;
- BOOST_CHECK(*c.to_begin() == 13);
- BOOST_CHECK(*c.to_begin() == 11);
- BOOST_CHECK(*++c == 12);
+ BOOST_CHECK_EQUAL(*c.to_begin(), 13);
+ BOOST_CHECK_EQUAL(*c.to_begin(), 11);
+ BOOST_CHECK_EQUAL(*++c, 12);
}
template <class Iterator>
void test_traversal(boost::tree::preorder, Iterator a, Iterator b)
{
- BOOST_CHECK(*a++ == 8);
- BOOST_CHECK(*a++ == 3);
- BOOST_CHECK(*a++ == 1);
- BOOST_CHECK(*a++ == 6);
- BOOST_CHECK(*a++ == 4);
- BOOST_CHECK(*a++ == 7);
- BOOST_CHECK(*a++ == 10);
- BOOST_CHECK(*a++ == 14);
- BOOST_CHECK(*a++ == 13);
- BOOST_CHECK(*a++ == 11);
- BOOST_CHECK(*a++ == 12);
+ BOOST_CHECK_EQUAL(*a++, 8);
+ BOOST_CHECK_EQUAL(*a++, 3);
+ BOOST_CHECK_EQUAL(*a++, 1);
+ BOOST_CHECK_EQUAL(*a++, 6);
+ BOOST_CHECK_EQUAL(*a++, 4);
+ BOOST_CHECK_EQUAL(*a++, 7);
+ BOOST_CHECK_EQUAL(*a++, 10);
+ BOOST_CHECK_EQUAL(*a++, 14);
+ BOOST_CHECK_EQUAL(*a++, 13);
+ BOOST_CHECK_EQUAL(*a++, 11);
+ BOOST_CHECK_EQUAL(*a++, 12);
BOOST_CHECK(a == b);
}
template <class Iterator>
void test_reverse_traversal(boost::tree::preorder, Iterator a, Iterator b)
{
- BOOST_CHECK(*--a == 12);
- BOOST_CHECK(*--a == 11);
- BOOST_CHECK(*--a == 13);
- BOOST_CHECK(*--a == 14);
- BOOST_CHECK(*--a == 10);
- BOOST_CHECK(*--a == 7);
- BOOST_CHECK(*--a == 4);
- BOOST_CHECK(*--a == 6);
- BOOST_CHECK(*--a == 1);
- BOOST_CHECK(*--a == 3);
- BOOST_CHECK(*--a == 8);
+ BOOST_CHECK_EQUAL(*--a, 12);
+ BOOST_CHECK_EQUAL(*--a, 11);
+ BOOST_CHECK_EQUAL(*--a, 13);
+ BOOST_CHECK_EQUAL(*--a, 14);
+ BOOST_CHECK_EQUAL(*--a, 10);
+ BOOST_CHECK_EQUAL(*--a, 7);
+ BOOST_CHECK_EQUAL(*--a, 4);
+ BOOST_CHECK_EQUAL(*--a, 6);
+ BOOST_CHECK_EQUAL(*--a, 1);
+ BOOST_CHECK_EQUAL(*--a, 3);
+ BOOST_CHECK_EQUAL(*--a, 8);
BOOST_CHECK(a == b);
}
template <class Iterator>
void test_subtree_traversal(boost::tree::preorder, Iterator a, Iterator b)
{
- BOOST_CHECK(*a++ == 3);
- BOOST_CHECK(*a++ == 1);
- BOOST_CHECK(*a++ == 6);
- BOOST_CHECK(*a++ == 4);
- BOOST_CHECK(*a++ == 7);
+ BOOST_CHECK_EQUAL(*a++, 3);
+ BOOST_CHECK_EQUAL(*a++, 1);
+ BOOST_CHECK_EQUAL(*a++, 6);
+ BOOST_CHECK_EQUAL(*a++, 4);
+ BOOST_CHECK_EQUAL(*a++, 7);
BOOST_CHECK(a == b);
}
template <class Iterator>
void test_traversal(boost::tree::inorder, Iterator a, Iterator b)
{
- BOOST_CHECK(*a++ == 1);
- BOOST_CHECK(*a++ == 3);
- BOOST_CHECK(*a++ == 4);
- BOOST_CHECK(*a++ == 6);
- BOOST_CHECK(*a++ == 7);
- BOOST_CHECK(*a++ == 8);
- BOOST_CHECK(*a++ == 10);
- BOOST_CHECK(*a++ == 11);
- BOOST_CHECK(*a++ == 12);
- BOOST_CHECK(*a++ == 13);
- BOOST_CHECK(*a++ == 14);
+ BOOST_CHECK_EQUAL(*a++, 1);
+ BOOST_CHECK_EQUAL(*a++, 3);
+ BOOST_CHECK_EQUAL(*a++, 4);
+ BOOST_CHECK_EQUAL(*a++, 6);
+ BOOST_CHECK_EQUAL(*a++, 7);
+ BOOST_CHECK_EQUAL(*a++, 8);
+ BOOST_CHECK_EQUAL(*a++, 10);
+ BOOST_CHECK_EQUAL(*a++, 11);
+ BOOST_CHECK_EQUAL(*a++, 12);
+ BOOST_CHECK_EQUAL(*a++, 13);
+ BOOST_CHECK_EQUAL(*a++, 14);
BOOST_CHECK(a == b);
}
template <class Iterator>
void test_reverse_traversal(boost::tree::inorder, Iterator a, Iterator b)
{
- BOOST_CHECK(*--a == 14);
- BOOST_CHECK(*--a == 13);
- BOOST_CHECK(*--a == 12);
- BOOST_CHECK(*--a == 11);
- BOOST_CHECK(*--a == 10);
- BOOST_CHECK(*--a == 8);
- BOOST_CHECK(*--a == 7);
- BOOST_CHECK(*--a == 6);
- BOOST_CHECK(*--a == 4);
- BOOST_CHECK(*--a == 3);
- BOOST_CHECK(*--a == 1);
+ BOOST_CHECK_EQUAL(*--a, 14);
+ BOOST_CHECK_EQUAL(*--a, 13);
+ BOOST_CHECK_EQUAL(*--a, 12);
+ BOOST_CHECK_EQUAL(*--a, 11);
+ BOOST_CHECK_EQUAL(*--a, 10);
+ BOOST_CHECK_EQUAL(*--a, 8);
+ BOOST_CHECK_EQUAL(*--a, 7);
+ BOOST_CHECK_EQUAL(*--a, 6);
+ BOOST_CHECK_EQUAL(*--a, 4);
+ BOOST_CHECK_EQUAL(*--a, 3);
+ BOOST_CHECK_EQUAL(*--a, 1);
BOOST_CHECK(a == b);
}
@@ -195,44 +195,44 @@
template <class Iterator>
void test_traversal(boost::tree::postorder, Iterator a, Iterator b)
{
- BOOST_CHECK(*a++ == 1);
- BOOST_CHECK(*a++ == 4);
- BOOST_CHECK(*a++ == 7);
- BOOST_CHECK(*a++ == 6);
- BOOST_CHECK(*a++ == 3);
- BOOST_CHECK(*a++ == 12);
- BOOST_CHECK(*a++ == 11);
- BOOST_CHECK(*a++ == 13);
- BOOST_CHECK(*a++ == 14);
- BOOST_CHECK(*a++ == 10);
- BOOST_CHECK(*a++ == 8);
+ BOOST_CHECK_EQUAL(*a++, 1);
+ BOOST_CHECK_EQUAL(*a++, 4);
+ BOOST_CHECK_EQUAL(*a++, 7);
+ BOOST_CHECK_EQUAL(*a++, 6);
+ BOOST_CHECK_EQUAL(*a++, 3);
+ BOOST_CHECK_EQUAL(*a++, 12);
+ BOOST_CHECK_EQUAL(*a++, 11);
+ BOOST_CHECK_EQUAL(*a++, 13);
+ BOOST_CHECK_EQUAL(*a++, 14);
+ BOOST_CHECK_EQUAL(*a++, 10);
+ BOOST_CHECK_EQUAL(*a++, 8);
BOOST_CHECK(a == b);
}
template <class Iterator>
void test_reverse_traversal(boost::tree::postorder, Iterator a, Iterator b)
{
- BOOST_CHECK(*--a == 8);
- BOOST_CHECK(*--a == 10);
- BOOST_CHECK(*--a == 14);
- BOOST_CHECK(*--a == 13);
- BOOST_CHECK(*--a == 11);
- BOOST_CHECK(*--a == 12);
- BOOST_CHECK(*--a == 3);
- BOOST_CHECK(*--a == 6);
- BOOST_CHECK(*--a == 7);
- BOOST_CHECK(*--a == 4);
- BOOST_CHECK(*--a == 1);
+ BOOST_CHECK_EQUAL(*--a, 8);
+ BOOST_CHECK_EQUAL(*--a, 10);
+ BOOST_CHECK_EQUAL(*--a, 14);
+ BOOST_CHECK_EQUAL(*--a, 13);
+ BOOST_CHECK_EQUAL(*--a, 11);
+ BOOST_CHECK_EQUAL(*--a, 12);
+ BOOST_CHECK_EQUAL(*--a, 3);
+ BOOST_CHECK_EQUAL(*--a, 6);
+ BOOST_CHECK_EQUAL(*--a, 7);
+ BOOST_CHECK_EQUAL(*--a, 4);
+ BOOST_CHECK_EQUAL(*--a, 1);
BOOST_CHECK(a == b);
}
template <class Iterator>
void test_traversal_from_leaf4(Iterator a, Iterator b)
{
- BOOST_CHECK(*a == 4);
- BOOST_CHECK(*++a == 6);
- BOOST_CHECK(*++a == 3);
- BOOST_CHECK(*++a == 8);
+ BOOST_CHECK_EQUAL(*a, 4);
+ BOOST_CHECK_EQUAL(*++a, 6);
+ BOOST_CHECK_EQUAL(*++a, 3);
+ BOOST_CHECK_EQUAL(*++a, 8);
BOOST_CHECK(++a == b);
} // namespace ascending
Modified: sandbox/SOC/2006/tree/trunk/libs/tree/test/unbalanced_binary_tree_test.cpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/libs/tree/test/unbalanced_binary_tree_test.cpp (original)
+++ sandbox/SOC/2006/tree/trunk/libs/tree/test/unbalanced_binary_tree_test.cpp 2008-10-29 20:08:01 EDT (Wed, 29 Oct 2008)
@@ -30,40 +30,40 @@
c1 = my_tree.insert(c, 8);
- BOOST_CHECK(*c1 == 8);
+ BOOST_CHECK_EQUAL(*c1, 8);
c1 = my_tree.insert(c1, 7);
- BOOST_CHECK(*c1 == 7);
+ BOOST_CHECK_EQUAL(*c1, 7);
++c1;
- BOOST_CHECK(*c1 == 8);
+ BOOST_CHECK_EQUAL(*c1, 8);
++c1;
BOOST_CHECK(c1 == my_tree.end());
c1 = my_tree.insert(my_tree.end(), 10);
- BOOST_CHECK(*c1 == 10);
+ BOOST_CHECK_EQUAL(*c1, 10);
--c1;
- BOOST_CHECK(*c1 == 8);
+ BOOST_CHECK_EQUAL(*c1, 8);
--c1;
- BOOST_CHECK(*c1 == 7);
+ BOOST_CHECK_EQUAL(*c1, 7);
c = my_tree.lower_bound(8);
- BOOST_CHECK(*c == 8);
+ BOOST_CHECK_EQUAL(*c, 8);
++c;
- BOOST_CHECK(*c == 10);
+ BOOST_CHECK_EQUAL(*c, 10);
--c;
- BOOST_CHECK(*c == 8);
+ BOOST_CHECK_EQUAL(*c, 8);
--c;
- BOOST_CHECK(*c == 7);
+ BOOST_CHECK_EQUAL(*c, 7);
++c;
- BOOST_CHECK(*c == 8);
+ BOOST_CHECK_EQUAL(*c, 8);
//c = my_tree.erase(c);
--c;
- BOOST_CHECK(*c == 7);
+ BOOST_CHECK_EQUAL(*c, 7);
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk