|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r50400 - sandbox/SOC/2006/tree/trunk/libs/tree/test
From: ockham_at_[hidden]
Date: 2008-12-29 11:13:38
Author: bernhard.reiter
Date: 2008-12-29 11:13:37 EST (Mon, 29 Dec 2008)
New Revision: 50400
URL: http://svn.boost.org/trac/boost/changeset/50400
Log:
Ascending cursor stub.
Added:
sandbox/SOC/2006/tree/trunk/libs/tree/test/ascending_cursor_test.cpp
- copied, changed from r50399, /sandbox/SOC/2006/tree/trunk/libs/tree/test/cursor_algorithm_test.cpp
Text files modified:
sandbox/SOC/2006/tree/trunk/libs/tree/test/Jamfile.v2 | 1
sandbox/SOC/2006/tree/trunk/libs/tree/test/ascending_cursor_test.cpp | 137 ++-------------------------------------
sandbox/SOC/2006/tree/trunk/libs/tree/test/insert_cursor_test.cpp | 2
sandbox/SOC/2006/tree/trunk/libs/tree/test/iterator_algorithm_test.cpp | 119 ++++++++++++++--------------------
4 files changed, 61 insertions(+), 198 deletions(-)
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 11:13:37 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 ascending_cursor_test.cpp ]
[ run insert_cursor_test.cpp ]
[ run algorithm_concepts_test.cpp ]
[ run cursor_algorithm_test.cpp ]
Copied: sandbox/SOC/2006/tree/trunk/libs/tree/test/ascending_cursor_test.cpp (from r50399, /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/ascending_cursor_test.cpp 2008-12-29 11:13:37 EST (Mon, 29 Dec 2008)
@@ -19,135 +19,18 @@
using namespace boost::tree;
-BOOST_FIXTURE_TEST_SUITE(cursor_algorithms_test, fake_binary_tree_with_list_fixture<int>)
+BOOST_FIXTURE_TEST_SUITE( ascending_cursor_test, fake_binary_tree_with_list_fixture<int> )
-BOOST_AUTO_TEST_CASE_TEMPLATE( test_foreach_descending, Order, orders)
+BOOST_AUTO_TEST_CASE( test_ascending_cursor )
{
- boost::tree::for_each(
- Order(),
- fbt1.descending_root(),
- boost::lambda::bind(&std::list<int>::push_back, &l, boost::lambda::_1)
- );
- test_traversal(Order(), l.begin(), l.end());
+// FIXME: Test differently, ie not relying on cursor-iterator adaptation.
+// 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(fbt1.descending_root()))
+// , end(Order(), make_ascending_cursor(fbt1.descending_root()))), 11);
}
-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_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_ascending )
-{
- boost::tree::for_each(
- preorder(),
- 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_descending, Order, orders)
-{
- boost::tree::copy(Order(), fbt1.descending_root(), o);
- test_traversal(Order(), l.begin(), l.end());
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE( test_copy_ascending, Order, orders)
-{
- 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 )
-//{
-// 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_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(), 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_ascending, 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(), 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(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/insert_cursor_test.cpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/libs/tree/test/insert_cursor_test.cpp (original)
+++ sandbox/SOC/2006/tree/trunk/libs/tree/test/insert_cursor_test.cpp 2008-12-29 11:13:37 EST (Mon, 29 Dec 2008)
@@ -49,7 +49,7 @@
boost::tree::copy(Order(), bt.root(), tree_inserter(bt2, bt2.root())
, boost::forward_traversal_tag());
-// fill_subtree_with_data(tree_inserter(bt2, bt2.root()));
+// fill_subtree_with_data(tree_inserter(bt2, bt2.root())); //FIXME
validate_test_dataset1_tree(bt2.root());
BOOST_CHECK_EQUAL(size(bt2.root()), size(bt.root()));
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 11:13:37 EST (Mon, 29 Dec 2008)
@@ -27,95 +27,74 @@
BOOST_AUTO_TEST_CASE_TEMPLATE( test_iterator_algorithms, Order, orders )
{
- fake_ascending_binary_cursor<int> afbtc1(fbt1, 0);
+ test_traversal(Order(), begin(Order(), fbt1.ascending_root())
+ , end(Order(), fbt1.ascending_root()));
- test_traversal(Order(), begin(Order(), afbtc1)
- , end(Order(), afbtc1));
-
- test_reverse_traversal(Order(), end(Order(), afbtc1)
- , begin(Order(), afbtc1));
+ test_reverse_traversal(Order(), end(Order(), fbt1.ascending_root())
+ , begin(Order(), fbt1.ascending_root()));
- 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(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(fbt1.descending_root()))
-// , end(Order(), make_ascending_cursor(fbt1.descending_root()))), 11);
+ BOOST_CHECK_EQUAL(std::distance(begin(Order(), fbt1.ascending_root())
+ , end(Order(), fbt1.ascending_root())), 11);
}
BOOST_AUTO_TEST_CASE( test_subtree3_iterator_algorithms )
{
- fake_ascending_binary_cursor<int> afbtc1(fbt1, 0);
-
- 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);
+ test_subtree_traversal(preorder(), begin(preorder(), fbt1.ascending_root().begin())
+ , end(preorder(), fbt1.ascending_root().begin()), 1);
+ BOOST_CHECK_EQUAL(std::distance(begin(preorder(), fbt1.ascending_root().begin())
+ , end(preorder(), fbt1.ascending_root().begin())), 5);
+
+ test_subtree_traversal(inorder(), begin(inorder(), fbt1.ascending_root().begin())
+ , end(inorder(), fbt1.ascending_root().begin()), 0);
+ BOOST_CHECK_EQUAL(std::distance(begin(inorder(), fbt1.ascending_root().begin())
+ , end(inorder(), fbt1.ascending_root().begin())), 5);
+
+ test_subtree_traversal(postorder(), begin(postorder(), fbt1.ascending_root().begin())
+ , end(postorder(), fbt1.ascending_root().begin()), 0);
+ BOOST_CHECK_EQUAL(std::distance(begin(postorder(), fbt1.ascending_root().begin())
+ , end(postorder(), fbt1.ascending_root().begin())), 5);
}
BOOST_AUTO_TEST_CASE( test_subtree6_iterator_algorithms )
{
- fake_ascending_binary_cursor<int> afbtc1(fbt1, 0);
-
- 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);
+ test_subtree_traversal(preorder(), begin(preorder(), fbt1.ascending_root().begin().end())
+ , end(preorder(), fbt1.ascending_root().begin().end()), 3);
+ BOOST_CHECK_EQUAL(std::distance(begin(preorder(), fbt1.ascending_root().begin().end())
+ , end(preorder(), fbt1.ascending_root().begin().end())), 3);
+
+ test_subtree_traversal(inorder(), begin(inorder(), fbt1.ascending_root().begin().end())
+ , end(inorder(), fbt1.ascending_root().begin().end()), 2);
+ BOOST_CHECK_EQUAL(std::distance(begin(inorder(), fbt1.ascending_root().begin().end())
+ , end(inorder(), fbt1.ascending_root().begin().end())), 3);
+
+ test_subtree_traversal(postorder(), begin(postorder(), fbt1.ascending_root().begin().end())
+ , end(postorder(), fbt1.ascending_root().begin().end()), 1);
+ BOOST_CHECK_EQUAL(std::distance(begin(postorder(), fbt1.ascending_root().begin().end())
+ , end(postorder(), fbt1.ascending_root().begin().end())), 3);
}
BOOST_AUTO_TEST_CASE( test_subtree10_iterator_algorithms )
{
- fake_ascending_binary_cursor<int> afbtc1(fbt1, 0);
-
- 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);
+ test_subtree_traversal(preorder(), begin(preorder(), fbt1.ascending_root().end())
+ , end(preorder(), fbt1.ascending_root().end()), 6);
+ BOOST_CHECK_EQUAL(std::distance(begin(preorder(), fbt1.ascending_root().end())
+ , end(preorder(), fbt1.ascending_root().end())), 5);
+
+ test_subtree_traversal(inorder(), begin(inorder(), fbt1.ascending_root().end())
+ , end(inorder(), fbt1.ascending_root().end()), 6);
+ BOOST_CHECK_EQUAL(std::distance(begin(inorder(), fbt1.ascending_root().end())
+ , end(inorder(), fbt1.ascending_root().end())), 5);
+
+ test_subtree_traversal(postorder(), begin(postorder(), fbt1.ascending_root().end())
+ , end(postorder(), fbt1.ascending_root().end()), 5);
+ BOOST_CHECK_EQUAL(std::distance(begin(postorder(), fbt1.ascending_root().end())
+ , end(postorder(), fbt1.ascending_root().end())), 5);
}
BOOST_AUTO_TEST_CASE( test_ascending_iterator_algorithms )
{
typedef fake_ascending_binary_cursor<int> cursor;
- cursor c(fbt1, 0);
+ cursor c = fbt1.ascending_root();
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-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