|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r50396 - in sandbox/SOC/2006/tree/trunk: boost/tree libs/tree/test
From: ockham_at_[hidden]
Date: 2008-12-29 08:40:05
Author: bernhard.reiter
Date: 2008-12-29 08:40:04 EST (Mon, 29 Dec 2008)
New Revision: 50396
URL: http://svn.boost.org/trac/boost/changeset/50396
Log:
More fake_binary_tree/test related fixes.
Start factoring out insert_cursor_test.
Added:
sandbox/SOC/2006/tree/trunk/libs/tree/test/insert_cursor_test.cpp
- copied, changed from r50395, /sandbox/SOC/2006/tree/trunk/libs/tree/test/cursor_algorithm_test.cpp
Text files modified:
sandbox/SOC/2006/tree/trunk/boost/tree/ascending_cursor.hpp | 2
sandbox/SOC/2006/tree/trunk/libs/tree/test/Jamfile.v2 | 1
sandbox/SOC/2006/tree/trunk/libs/tree/test/cursor_algorithm_test.cpp | 102 +++++++++++++++++++++++----------
sandbox/SOC/2006/tree/trunk/libs/tree/test/fake_binary_tree.hpp | 104 +++++++++++++++++++--------------
sandbox/SOC/2006/tree/trunk/libs/tree/test/insert_cursor_test.cpp | 108 ++++++++++------------------------
sandbox/SOC/2006/tree/trunk/libs/tree/test/iterator_algorithm_test.cpp | 122 ++++++++++++++++++++--------------------
6 files changed, 226 insertions(+), 213 deletions(-)
Modified: sandbox/SOC/2006/tree/trunk/boost/tree/ascending_cursor.hpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/boost/tree/ascending_cursor.hpp (original)
+++ sandbox/SOC/2006/tree/trunk/boost/tree/ascending_cursor.hpp 2008-12-29 08:40:04 EST (Mon, 29 Dec 2008)
@@ -134,7 +134,7 @@
void advance(typename ascending_cursor::cursor_facade_::difference_type n)
{
- m_s.top() += n;
+ m_s.top() += n;
}
typename ascending_cursor::cursor_facade_::difference_type
Modified: sandbox/SOC/2006/tree/trunk/libs/tree/test/Jamfile.v2
==============================================================================
--- sandbox/SOC/2006/tree/trunk/libs/tree/test/Jamfile.v2 (original)
+++ sandbox/SOC/2006/tree/trunk/libs/tree/test/Jamfile.v2 2008-12-29 08:40:04 EST (Mon, 29 Dec 2008)
@@ -27,6 +27,7 @@
[ run binary_tree_search_test.cpp ]
# [ run key_search_binary_tree_test.cpp ]
# [ run rank_search_binary_tree_test.cpp ]
+ [ run insert_cursor_test.cpp ]
[ run algorithm_concepts_test.cpp ]
[ run cursor_algorithm_test.cpp ]
[ run iterator_algorithm_test.cpp ]
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-12-29 08:40:04 EST (Mon, 29 Dec 2008)
@@ -4,18 +4,10 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-#include <boost/tree/binary_tree.hpp>
-#include <boost/tree/iterator.hpp>
#include <boost/tree/algorithm.hpp>
-#include <boost/tree/insert_cursor.hpp>
-
#include <boost/lambda/bind.hpp>
-#include <list>
-#include <algorithm>
-#include <iterator>
-
#define BOOST_TEST_MODULE cursor_algorithm test
#include <boost/test/included/unit_test.hpp>
#include <boost/test/test_case_template.hpp>
@@ -27,47 +19,76 @@
using namespace boost::tree;
-BOOST_FIXTURE_TEST_SUITE(cursor_algorithms, fake_binary_tree_fixture<int>)
+BOOST_FIXTURE_TEST_SUITE(cursor_algorithms_test, fake_binary_tree_with_list_fixture<int>)
-BOOST_AUTO_TEST_CASE_TEMPLATE( test_foreach, Order, orders)
+BOOST_AUTO_TEST_CASE_TEMPLATE( test_foreach_descending, Order, orders)
{
- fake_binary_tree<int> mt = generate_fake_binary_tree();
- std::list<int> l;
boost::tree::for_each(
Order(),
- mbt1.root(),
+ fbt1.descending_root(),
boost::lambda::bind(&std::list<int>::push_back, &l, boost::lambda::_1)
);
test_traversal(Order(), l.begin(), l.end());
}
-BOOST_AUTO_TEST_SUITE_END()
+BOOST_AUTO_TEST_CASE_TEMPLATE( test_foreach_ascending, Order, orders)
+{
+ boost::tree::for_each(
+ Order(),
+ fbt1.ascending_root(),
+ boost::lambda::bind(&std::list<int>::push_back, &l, boost::lambda::_1)
+ );
+ test_traversal(Order(), l.begin(), l.end());
+}
-BOOST_FIXTURE_TEST_SUITE(cursor_algorithms_test, fake_binary_tree_with_list_fixture<int>)
+BOOST_AUTO_TEST_CASE( test_foreach_subtree3_descending )
+{
+ boost::tree::for_each(
+ preorder(),
+ fbt1.descending_root().begin(),
+ boost::lambda::bind(&std::list<int>::push_back, &l, boost::lambda::_1)
+ );
+ test_subtree_traversal(preorder(), l.begin(), l.end(), 1);
+ BOOST_CHECK_EQUAL(l.size(), 5);
+}
-BOOST_AUTO_TEST_CASE( test_foreach_subtree3 )
+BOOST_AUTO_TEST_CASE( test_foreach_subtree3_ascending )
{
boost::tree::for_each(
preorder(),
- mbt1.root().begin(),
+ fbt1.ascending_root().begin(),
boost::lambda::bind(&std::list<int>::push_back, &l, boost::lambda::_1)
);
test_subtree_traversal(preorder(), l.begin(), l.end(), 1);
BOOST_CHECK_EQUAL(l.size(), 5);
}
-BOOST_AUTO_TEST_CASE_TEMPLATE( test_copy, Order, orders)
+BOOST_AUTO_TEST_CASE_TEMPLATE( test_copy_descending, Order, orders)
{
- boost::tree::copy(Order(), mbt1.root(), o);
+ boost::tree::copy(Order(), fbt1.descending_root(), o);
test_traversal(Order(), l.begin(), l.end());
}
-BOOST_AUTO_TEST_CASE_TEMPLATE( test_copy_trees, Order, orders)
+BOOST_AUTO_TEST_CASE_TEMPLATE( test_copy_ascending, Order, orders)
{
- BOOST_CHECK(mbt1 != mbt2);
- boost::tree::copy(Order(), mbt1.root(), mbt2.root());
- BOOST_CHECK(mbt1 == mbt2);
- validate_test_dataset1_tree(mbt2.root());
+ boost::tree::copy(Order(), fbt1.ascending_root(), o);
+ test_traversal(Order(), l.begin(), l.end());
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE( test_copy_trees_descending, Order, orders)
+{
+ BOOST_CHECK(fbt1 != fbt2);
+ boost::tree::copy(Order(), fbt1.descending_root(), fbt2.descending_root());
+ BOOST_CHECK(fbt1 == fbt2);
+ validate_test_dataset1_tree(fbt2.descending_root());
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE( test_copy_trees_ascending, Order, orders)
+{
+ BOOST_CHECK(fbt1 != fbt2);
+ boost::tree::copy(Order(), fbt1.ascending_root(), fbt2.ascending_root());
+ BOOST_CHECK(fbt1 == fbt2);
+ validate_test_dataset1_tree(fbt2.ascending_root());
}
//BOOST_AUTO_TEST_CASE_TEMPLATE ( test_desc_copy_using_insert_cursor, Order, orders )
@@ -92,22 +113,41 @@
// BOOST_CHECK_EQUAL(size(bt2.root()), size(bt.root()));
//}
-BOOST_AUTO_TEST_CASE_TEMPLATE( test_transform, Order, orders)
+BOOST_AUTO_TEST_CASE_TEMPLATE( test_transform_descending, Order, orders)
{
// First copy test_tree to test_tree2, by adding 1 to each element,
// then copy test_tree2 to test_list, by subtracting 1 - so
// test_list should hold test_tree's original elements in ORDER.
- boost::tree::transform(Order(), mbt1.root(), mbt2.root(), std::bind2nd(std::plus<int>(),1));
- boost::tree::transform(Order(), mbt2.root(), o, std::bind2nd(std::minus<int>(),1));
+ boost::tree::transform(Order(), fbt1.descending_root(), fbt2.descending_root(), std::bind2nd(std::plus<int>(),1));
+ boost::tree::transform(Order(), fbt2.descending_root(), o, std::bind2nd(std::minus<int>(),1));
test_traversal(Order(), l.begin(), l.end());
}
-BOOST_AUTO_TEST_CASE_TEMPLATE( test_transform_trees, Order, orders)
+BOOST_AUTO_TEST_CASE_TEMPLATE( test_transform_ascending, Order, orders)
{
- BOOST_CHECK(mbt1 != mbt2);
- boost::tree::transform(Order(), mbt1.root(), mbt2.root()
+ // First copy test_tree to test_tree2, by adding 1 to each element,
+ // then copy test_tree2 to test_list, by subtracting 1 - so
+ // test_list should hold test_tree's original elements in ORDER.
+ boost::tree::transform(Order(), fbt1.ascending_root(), fbt2.ascending_root(), std::bind2nd(std::plus<int>(),1));
+ boost::tree::transform(Order(), fbt2.ascending_root(), o, std::bind2nd(std::minus<int>(),1));
+ test_traversal(Order(), l.begin(), l.end());
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE( test_transform_trees_descending, Order, orders)
+{
+ BOOST_CHECK(fbt1 != fbt2);
+ boost::tree::transform(Order(), fbt1.descending_root(), fbt2.descending_root()
, std::bind2nd(std::minus<int>(),1));
- validate_test_dataset1_minus_1_tree(mbt2.root());
+ validate_test_dataset1_minus_1_tree(fbt2.descending_root());
}
+BOOST_AUTO_TEST_CASE_TEMPLATE( test_transform_trees_ascending, Order, orders)
+{
+ BOOST_CHECK(fbt1 != fbt2);
+ boost::tree::transform(Order(), fbt1.ascending_root(), fbt2.ascending_root()
+ , std::bind2nd(std::minus<int>(),1));
+ validate_test_dataset1_minus_1_tree(fbt2.ascending_root());
+}
+
+
BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
Modified: sandbox/SOC/2006/tree/trunk/libs/tree/test/fake_binary_tree.hpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/libs/tree/test/fake_binary_tree.hpp (original)
+++ sandbox/SOC/2006/tree/trunk/libs/tree/test/fake_binary_tree.hpp 2008-12-29 08:40:04 EST (Mon, 29 Dec 2008)
@@ -14,20 +14,31 @@
#include "helpers.hpp"
template <class T>
-struct fake_binary_tree_cursor;
+struct fake_descending_binary_cursor;
+
+template <class T>
+struct fake_ascending_binary_cursor;
/// See http://en.wikipedia.org/wiki/Binary_Tree#Methods_for_storing_binary_trees
template <class T>
struct fake_binary_tree {
- typedef fake_binary_tree_cursor<T> cursor;
- typedef fake_binary_tree_cursor<T const> const_cursor;
+ typedef fake_descending_binary_cursor<T> descending_cursor;
+ typedef fake_descending_binary_cursor<T const> const_descending_cursor;
+
+ typedef fake_ascending_binary_cursor<T> ascending_cursor;
+ typedef fake_ascending_binary_cursor<T const> const_ascending_cursor;
fake_binary_tree(typename std::vector<T>::size_type s) : m_data(s)
{ }
- cursor root()
+ descending_cursor descending_root()
+ {
+ return descending_cursor(*this, 0);
+ }
+
+ ascending_cursor ascending_root()
{
- return cursor(*this, 0);
+ return ascending_cursor(*this, 0);
}
typedef std::vector<T> children_type;
@@ -52,9 +63,9 @@
return !(x == y);
}
-// Make this use cursor_adaptor. Yes, even if that means relying on it.
+// Make this use cursor_facade. Yes, even if that means relying on it.
template <class T>
-struct fake_binary_tree_cursor {
+struct fake_descending_binary_cursor {
typedef boost::forward_traversal_tag vertical_traversal;
typedef boost::bidirectional_traversal_tag horizontal_traversal;
typedef horizontal_traversal iterator_category;
@@ -65,21 +76,21 @@
typedef typename fake_binary_tree<T>::size_type size_type;
- typedef fake_binary_tree_cursor<T> cursor;
- typedef fake_binary_tree_cursor<T const> const_cursor;
-
-
- //typedef typename fake_binary_tree<T>::children_type::value_type cur;
- //cur c;
+ typedef fake_descending_binary_cursor<T> cursor;
+ typedef fake_descending_binary_cursor<T const> const_cursor;
+
fake_binary_tree<T>& m_tree;
typename fake_binary_tree<T>::size_type m_pos;
- explicit fake_binary_tree_cursor(fake_binary_tree<T>& t, size_type p = 0) : m_tree(t), m_pos(p) {}
- //fake_binary_tree_cursor(fake_binary_tree_cursor const& mtc) : c(mtc.c), bgn(false) {}
+ explicit fake_descending_binary_cursor(fake_binary_tree<T>& t, size_type p = 0)
+ : m_tree(t), m_pos(p) {}
+
+ fake_descending_binary_cursor(fake_descending_binary_cursor<T> const& other)
+ : m_tree(other.m_tree), m_pos(other.m_pos) {}
T const& operator*() const
{
- return m_tree.m_data[m_pos];
+ return m_tree.m_data[(m_pos-1)/2];
}
T& operator*()
@@ -87,41 +98,41 @@
return m_tree.m_data[(m_pos-1)/2];
}
- fake_binary_tree_cursor& to_begin()
+ fake_descending_binary_cursor& to_begin()
{
m_pos <<= 1;
++m_pos;
return *this;
}
- fake_binary_tree_cursor begin()
+ fake_descending_binary_cursor begin()
{
- fake_binary_tree_cursor tmp(*this);
+ fake_descending_binary_cursor tmp(*this);
tmp.to_begin();
return tmp;
}
- fake_binary_tree_cursor& to_end()
+ fake_descending_binary_cursor& to_end()
{
++m_pos;
m_pos <<= 1;
return *this;
}
- fake_binary_tree_cursor end()
+ fake_descending_binary_cursor end()
{
- fake_binary_tree_cursor tmp(*this);
+ fake_descending_binary_cursor tmp(*this);
tmp.to_end();
return tmp;
}
- fake_binary_tree_cursor& operator++()
+ fake_descending_binary_cursor& operator++()
{
++m_pos;
return *this;
}
- fake_binary_tree_cursor& operator--()
+ fake_descending_binary_cursor& operator--()
{
--m_pos;
return *this;
@@ -143,31 +154,34 @@
};
template <class T>
-bool operator==(fake_binary_tree_cursor<T> const& x, fake_binary_tree_cursor<T> const& y)
+bool operator==(fake_descending_binary_cursor<T> const& x, fake_descending_binary_cursor<T> const& y)
{
return (x.m_tree == y.m_tree) && (x.m_pos == y.m_pos);
}
template <class T>
-bool operator!=(fake_binary_tree_cursor<T> const& x, fake_binary_tree_cursor<T> const& y)
+bool operator!=(fake_descending_binary_cursor<T> const& x, fake_descending_binary_cursor<T> const& y)
{
return !(x==y);
}
template <class T>
-struct fake_ascending_binary_tree_cursor;
+struct fake_ascending_binary_cursor;
template <class T>
-struct fake_ascending_binary_tree_cursor
-: public boost::tree::cursor_adaptor<fake_ascending_binary_tree_cursor<T>
- , fake_binary_tree_cursor<T> >
+struct fake_ascending_binary_cursor
+: public boost::tree::cursor_adaptor<fake_ascending_binary_cursor<T>
+ , fake_descending_binary_cursor<T>
+ , boost::use_default
+ , boost::use_default
+ , boost::bidirectional_traversal_tag >
{
- typedef fake_ascending_binary_tree_cursor<T> cursor;
- typedef fake_ascending_binary_tree_cursor<T const> const_cursor;
+ typedef fake_ascending_binary_cursor<T> cursor;
+ typedef fake_ascending_binary_cursor<T const> const_cursor;
- fake_ascending_binary_tree_cursor(fake_binary_tree<T>& t
+ fake_ascending_binary_cursor(fake_binary_tree<T>& t
, typename fake_binary_tree<T>::size_type p)
- : fake_ascending_binary_tree_cursor::cursor_adaptor_(fake_binary_tree_cursor<T>(t, p)) {}
+ : fake_ascending_binary_cursor::cursor_adaptor_(fake_descending_binary_cursor<T>(t, p)) {}
private:
friend class boost::iterator_core_access;
@@ -181,22 +195,22 @@
};
//template <class T>
-//struct fake_ascending_binary_tree_cursor
-//: public fake_binary_tree_cursor<T> {
-// fake_ascending_binary_tree_cursor(fake_binary_tree<T>& t
+//struct fake_ascending_binary_cursor
+//: public fake_descending_binary_cursor<T> {
+// fake_ascending_binary_cursor(fake_binary_tree<T>& t
// , typename fake_binary_tree<T>::size_type p)
-// : fake_binary_tree_cursor<T>(t, p) {}
+// : fake_descending_binary_cursor<T>(t, p) {}
//
-// fake_ascending_binary_tree_cursor& to_parent()
+// fake_ascending_binary_cursor& to_parent()
// {
-// --fake_binary_tree_cursor<T>::m_pos;
-// fake_binary_tree_cursor<T>::m_pos >>= 1;
+// --fake_descending_binary_cursor<T>::m_pos;
+// fake_descending_binary_cursor<T>::m_pos >>= 1;
// return *this;
// }
//
-// fake_ascending_binary_tree_cursor parent()
+// fake_ascending_binary_cursor parent()
// {
-// fake_ascending_binary_tree_cursor tmp(*this);
+// fake_ascending_binary_cursor tmp(*this);
// tmp.to_parent();
// return tmp;
// }
@@ -223,7 +237,7 @@
template <class T = int>
struct fake_binary_tree_fixture {
- fake_binary_tree_fixture() : mbt1(generate_fake_binary_tree()), mbt2(57) {}
+ fake_binary_tree_fixture() : fbt1(generate_fake_binary_tree()), fbt2(57) {}
template <class Cursor>
static void validate_test_dataset1_tree(Cursor cur)
@@ -258,7 +272,7 @@
BOOST_CHECK_EQUAL(*cur.end().end().begin().begin().end().begin(), 11); //Leaf
}
- fake_binary_tree<T> mbt1, mbt2;
+ fake_binary_tree<T> fbt1, fbt2;
};
template <class T = int>
Copied: sandbox/SOC/2006/tree/trunk/libs/tree/test/insert_cursor_test.cpp (from r50395, /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/insert_cursor_test.cpp 2008-12-29 08:40:04 EST (Mon, 29 Dec 2008)
@@ -10,11 +10,11 @@
#include <boost/tree/insert_cursor.hpp>
-#include <boost/lambda/bind.hpp>
+//#include <boost/lambda/bind.hpp>
-#include <list>
-#include <algorithm>
-#include <iterator>
+//#include <list>
+//#include <algorithm>
+//#include <iterator>
#define BOOST_TEST_MODULE cursor_algorithm test
#include <boost/test/included/unit_test.hpp>
@@ -27,87 +27,45 @@
using namespace boost::tree;
-BOOST_FIXTURE_TEST_SUITE(cursor_algorithms, fake_binary_tree_fixture<int>)
+BOOST_FIXTURE_TEST_SUITE(insert_cursor_test, test_binary_tree_fixture<int>)
-BOOST_AUTO_TEST_CASE_TEMPLATE( test_foreach, Order, orders)
+template <class Cursor>
+void fill_subtree_with_data(Cursor cur)
{
- fake_binary_tree<int> mt = generate_fake_binary_tree();
- std::list<int> l;
- boost::tree::for_each(
- Order(),
- mbt1.root(),
- boost::lambda::bind(&std::list<int>::push_back, &l, boost::lambda::_1)
- );
- test_traversal(Order(), l.begin(), l.end());
+ *cur.begin() = 8;
+ *cur.begin().begin() = 3;
+ *cur.begin().begin().begin() = 1; //Leaf
+ *cur.begin().end().begin() = 6;
+ *cur.begin().end().begin().begin() = 4; //Leaf
+ *cur.begin().end().end().begin() = 7; //Leaf
+ *cur.end().begin() = 10;
+ *cur.end().end().begin() = 14;
+ *cur.end().end().begin().begin() = 13;
+ *cur.end().end().begin().begin().begin() = 11;
+ *cur.end().end().begin().begin().end().begin() = 12; //Leaf
}
-BOOST_AUTO_TEST_SUITE_END()
-
-BOOST_FIXTURE_TEST_SUITE(cursor_algorithms_test, fake_binary_tree_with_list_fixture<int>)
-
-BOOST_AUTO_TEST_CASE( test_foreach_subtree3 )
+BOOST_AUTO_TEST_CASE_TEMPLATE ( test_desc_copy_using_insert_cursor, Order, orders )
{
- boost::tree::for_each(
- preorder(),
- mbt1.root().begin(),
- boost::lambda::bind(&std::list<int>::push_back, &l, boost::lambda::_1)
- );
- test_subtree_traversal(preorder(), l.begin(), l.end(), 1);
- BOOST_CHECK_EQUAL(l.size(), 5);
-}
+ bt2.clear();
-BOOST_AUTO_TEST_CASE_TEMPLATE( test_copy, Order, orders)
-{
- boost::tree::copy(Order(), mbt1.root(), o);
- test_traversal(Order(), l.begin(), l.end());
-}
+ boost::tree::copy(Order(), bt.root(), tree_inserter(bt2, bt2.root())
+ , boost::forward_traversal_tag());
+// fill_subtree_with_data(tree_inserter(bt2, bt2.root()));
-BOOST_AUTO_TEST_CASE_TEMPLATE( test_copy_trees, Order, orders)
-{
- BOOST_CHECK(mbt1 != mbt2);
- boost::tree::copy(Order(), mbt1.root(), mbt2.root());
- BOOST_CHECK(mbt1 == mbt2);
- validate_test_dataset1_tree(mbt2.root());
+ validate_test_dataset1_tree(bt2.root());
+ BOOST_CHECK_EQUAL(size(bt2.root()), size(bt.root()));
}
-//BOOST_AUTO_TEST_CASE_TEMPLATE ( test_desc_copy_using_insert_cursor, Order, orders )
-//{
-// bt2.clear();
-//
-// boost::tree::copy(Order(), bt.root(), tree_inserter(bt2, bt2.root())
-// , boost::forward_traversal_tag());
-//
-// validate_test_dataset1_tree(bt2.root());
-// BOOST_CHECK_EQUAL(size(bt2.root()), size(bt.root()));
-//}
-//
-//BOOST_AUTO_TEST_CASE_TEMPLATE ( test_asc_copy_using_insert_cursor, Order, orders )
-//{
-// bt2.clear();
-//
-// boost::tree::copy(Order(), bt.root(), tree_inserter(bt2, bt2.root())
-// , boost::bidirectional_traversal_tag());
-//
-// validate_test_dataset1_tree(bt2.root());
-// BOOST_CHECK_EQUAL(size(bt2.root()), size(bt.root()));
-//}
+BOOST_AUTO_TEST_CASE_TEMPLATE ( test_asc_copy_using_insert_cursor, Order, orders )
+{
+ bt2.clear();
+
+ boost::tree::copy(Order(), bt.root(), tree_inserter(bt2, bt2.root())
+ , boost::bidirectional_traversal_tag());
-BOOST_AUTO_TEST_CASE_TEMPLATE( test_transform, Order, orders)
-{
- // First copy test_tree to test_tree2, by adding 1 to each element,
- // then copy test_tree2 to test_list, by subtracting 1 - so
- // test_list should hold test_tree's original elements in ORDER.
- boost::tree::transform(Order(), mbt1.root(), mbt2.root(), std::bind2nd(std::plus<int>(),1));
- boost::tree::transform(Order(), mbt2.root(), o, std::bind2nd(std::minus<int>(),1));
- test_traversal(Order(), l.begin(), l.end());
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE( test_transform_trees, Order, orders)
-{
- BOOST_CHECK(mbt1 != mbt2);
- boost::tree::transform(Order(), mbt1.root(), mbt2.root()
- , std::bind2nd(std::minus<int>(),1));
- validate_test_dataset1_minus_1_tree(mbt2.root());
+ validate_test_dataset1_tree(bt2.root());
+ BOOST_CHECK_EQUAL(size(bt2.root()), size(bt.root()));
}
BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
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-12-29 08:40:04 EST (Mon, 29 Dec 2008)
@@ -27,101 +27,101 @@
BOOST_AUTO_TEST_CASE_TEMPLATE( test_iterator_algorithms, Order, orders )
{
- fake_ascending_binary_tree_cursor<int> ambtc1(mbt1, 0);
+ fake_ascending_binary_cursor<int> afbtc1(fbt1, 0);
- test_traversal(Order(), begin(Order(), ambtc1)
- , end(Order(), ambtc1));
+ test_traversal(Order(), begin(Order(), afbtc1)
+ , end(Order(), afbtc1));
- test_reverse_traversal(Order(), end(Order(), ambtc1)
- , begin(Order(), ambtc1));
+ test_reverse_traversal(Order(), end(Order(), afbtc1)
+ , begin(Order(), afbtc1));
- BOOST_CHECK_EQUAL(std::distance(begin(Order(), ambtc1)
- , end(Order(), ambtc1)), 11);
+ BOOST_CHECK_EQUAL(std::distance(begin(Order(), afbtc1)
+ , end(Order(), afbtc1)), 11);
// TODO: Also check with binary_tree-specialized inorder begin()!
// Now the iterators based on stack-based cursors (that don't use cursor.to_parent())
// FIXME
-// test_traversal(Order(), begin(Order(), make_ascending_cursor(mbt1.root()))
-// , end(Order(), make_ascending_cursor(mbt1.root())));
-// test_reverse_traversal(Order(), end(Order(), make_ascending_cursor(mbt1.root()))
-// , begin(Order(), make_ascending_cursor(mbt1.root())));
+// test_traversal(Order(), begin(Order(), make_ascending_cursor(fbt1.descending_root()))
+// , end(Order(), make_ascending_cursor(fbt1.descending_root())));
+// test_reverse_traversal(Order(), end(Order(), make_ascending_cursor(fbt1.descending_root()))
+// , begin(Order(), make_ascending_cursor(fbt1.descending_root())));
// BOOST_CHECK_EQUAL(std::distance(
-// begin(Order(), make_ascending_cursor(mbt1.root()))
-// , end(Order(), make_ascending_cursor(mbt1.root()))), 11);
+// begin(Order(), make_ascending_cursor(fbt1.descending_root()))
+// , end(Order(), make_ascending_cursor(fbt1.descending_root()))), 11);
}
BOOST_AUTO_TEST_CASE( test_subtree3_iterator_algorithms )
{
- fake_ascending_binary_tree_cursor<int> ambtc1(mbt1, 0);
+ fake_ascending_binary_cursor<int> afbtc1(fbt1, 0);
- test_subtree_traversal(preorder(), begin(preorder(), ambtc1.begin())
- , end(preorder(), ambtc1.begin()), 1);
- BOOST_CHECK_EQUAL(std::distance(begin(preorder(), ambtc1.begin())
- , end(preorder(), ambtc1.begin())), 5);
-
- test_subtree_traversal(inorder(), begin(inorder(), ambtc1.begin())
- , end(inorder(), ambtc1.begin()), 0);
- BOOST_CHECK_EQUAL(std::distance(begin(inorder(), ambtc1.begin())
- , end(inorder(), ambtc1.begin())), 5);
-
- test_subtree_traversal(postorder(), begin(postorder(), ambtc1.begin())
- , end(postorder(), ambtc1.begin()), 0);
- BOOST_CHECK_EQUAL(std::distance(begin(postorder(), ambtc1.begin())
- , end(postorder(), ambtc1.begin())), 5);
+ test_subtree_traversal(preorder(), begin(preorder(), afbtc1.begin())
+ , end(preorder(), afbtc1.begin()), 1);
+ BOOST_CHECK_EQUAL(std::distance(begin(preorder(), afbtc1.begin())
+ , end(preorder(), afbtc1.begin())), 5);
+
+ test_subtree_traversal(inorder(), begin(inorder(), afbtc1.begin())
+ , end(inorder(), afbtc1.begin()), 0);
+ BOOST_CHECK_EQUAL(std::distance(begin(inorder(), afbtc1.begin())
+ , end(inorder(), afbtc1.begin())), 5);
+
+ test_subtree_traversal(postorder(), begin(postorder(), afbtc1.begin())
+ , end(postorder(), afbtc1.begin()), 0);
+ BOOST_CHECK_EQUAL(std::distance(begin(postorder(), afbtc1.begin())
+ , end(postorder(), afbtc1.begin())), 5);
}
BOOST_AUTO_TEST_CASE( test_subtree6_iterator_algorithms )
{
- fake_ascending_binary_tree_cursor<int> ambtc1(mbt1, 0);
+ fake_ascending_binary_cursor<int> afbtc1(fbt1, 0);
- test_subtree_traversal(preorder(), begin(preorder(), ambtc1.begin().end())
- , end(preorder(), ambtc1.begin().end()), 3);
- BOOST_CHECK_EQUAL(std::distance(begin(preorder(), ambtc1.begin().end())
- , end(preorder(), ambtc1.begin().end())), 3);
-
- test_subtree_traversal(inorder(), begin(inorder(), ambtc1.begin().end())
- , end(inorder(), ambtc1.begin().end()), 2);
- BOOST_CHECK_EQUAL(std::distance(begin(inorder(), ambtc1.begin().end())
- , end(inorder(), ambtc1.begin().end())), 3);
-
- test_subtree_traversal(postorder(), begin(postorder(), ambtc1.begin().end())
- , end(postorder(), ambtc1.begin().end()), 1);
- BOOST_CHECK_EQUAL(std::distance(begin(postorder(), ambtc1.begin().end())
- , end(postorder(), ambtc1.begin().end())), 3);
+ test_subtree_traversal(preorder(), begin(preorder(), afbtc1.begin().end())
+ , end(preorder(), afbtc1.begin().end()), 3);
+ BOOST_CHECK_EQUAL(std::distance(begin(preorder(), afbtc1.begin().end())
+ , end(preorder(), afbtc1.begin().end())), 3);
+
+ test_subtree_traversal(inorder(), begin(inorder(), afbtc1.begin().end())
+ , end(inorder(), afbtc1.begin().end()), 2);
+ BOOST_CHECK_EQUAL(std::distance(begin(inorder(), afbtc1.begin().end())
+ , end(inorder(), afbtc1.begin().end())), 3);
+
+ test_subtree_traversal(postorder(), begin(postorder(), afbtc1.begin().end())
+ , end(postorder(), afbtc1.begin().end()), 1);
+ BOOST_CHECK_EQUAL(std::distance(begin(postorder(), afbtc1.begin().end())
+ , end(postorder(), afbtc1.begin().end())), 3);
}
BOOST_AUTO_TEST_CASE( test_subtree10_iterator_algorithms )
{
- fake_ascending_binary_tree_cursor<int> ambtc1(mbt1, 0);
+ fake_ascending_binary_cursor<int> afbtc1(fbt1, 0);
- test_subtree_traversal(preorder(), begin(preorder(), ambtc1.end())
- , end(preorder(), ambtc1.end()), 6);
- BOOST_CHECK_EQUAL(std::distance(begin(preorder(), ambtc1.end())
- , end(preorder(), ambtc1.end())), 5);
-
- test_subtree_traversal(inorder(), begin(inorder(), ambtc1.end())
- , end(inorder(), ambtc1.end()), 6);
- BOOST_CHECK_EQUAL(std::distance(begin(inorder(), ambtc1.end())
- , end(inorder(), ambtc1.end())), 5);
-
- test_subtree_traversal(postorder(), begin(postorder(), ambtc1.end())
- , end(postorder(), ambtc1.end()), 5);
- BOOST_CHECK_EQUAL(std::distance(begin(postorder(), ambtc1.end())
- , end(postorder(), ambtc1.end())), 5);
+ test_subtree_traversal(preorder(), begin(preorder(), afbtc1.end())
+ , end(preorder(), afbtc1.end()), 6);
+ BOOST_CHECK_EQUAL(std::distance(begin(preorder(), afbtc1.end())
+ , end(preorder(), afbtc1.end())), 5);
+
+ test_subtree_traversal(inorder(), begin(inorder(), afbtc1.end())
+ , end(inorder(), afbtc1.end()), 6);
+ BOOST_CHECK_EQUAL(std::distance(begin(inorder(), afbtc1.end())
+ , end(inorder(), afbtc1.end())), 5);
+
+ test_subtree_traversal(postorder(), begin(postorder(), afbtc1.end())
+ , end(postorder(), afbtc1.end()), 5);
+ BOOST_CHECK_EQUAL(std::distance(begin(postorder(), afbtc1.end())
+ , end(postorder(), afbtc1.end())), 5);
}
BOOST_AUTO_TEST_CASE( test_ascending_iterator_algorithms )
{
- typedef fake_ascending_binary_tree_cursor<int> cursor;
- cursor c(mbt1, 0);
+ typedef fake_ascending_binary_cursor<int> cursor;
+ cursor c(fbt1, 0);
typedef boost::tree::root_tracking_cursor<cursor> rtc;
typedef boost::tree::iterator<ascending, rtc> ai;
c.to_begin().to_end().to_begin().to_begin();
BOOST_CHECK_EQUAL(*c, 4);
- test_traversal_from_leaf4(ai(rtc(c)), ai(rtc(cursor(mbt1,0))));
+ test_traversal_from_leaf4(ai(rtc(c)), ai(rtc(cursor(fbt1,0))));
}
BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
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