Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r50778 - in sandbox/SOC/2006/tree/trunk: boost/tree libs/tree/test
From: ockham_at_[hidden]
Date: 2009-01-25 18:18:09


Author: bernhard.reiter
Date: 2009-01-25 18:18:08 EST (Sun, 25 Jan 2009)
New Revision: 50778
URL: http://svn.boost.org/trac/boost/changeset/50778

Log:
Clean up binary_search_test, rename to lower_bound_test
Added:
   sandbox/SOC/2006/tree/trunk/libs/tree/test/lower_bound_test.cpp
      - copied, changed from r50717, /sandbox/SOC/2006/tree/trunk/libs/tree/test/binary_tree_search_test.cpp
Removed:
   sandbox/SOC/2006/tree/trunk/libs/tree/test/binary_tree_search_test.cpp
Text files modified:
   sandbox/SOC/2006/tree/trunk/boost/tree/algorithm.hpp | 4 +-
   sandbox/SOC/2006/tree/trunk/boost/tree/inorder_algorithms.hpp | 2
   sandbox/SOC/2006/tree/trunk/libs/tree/test/fake_binary_tree.hpp | 14 +++++++----
   sandbox/SOC/2006/tree/trunk/libs/tree/test/lower_bound_test.cpp | 48 +++++++++------------------------------
   4 files changed, 23 insertions(+), 45 deletions(-)

Modified: sandbox/SOC/2006/tree/trunk/boost/tree/algorithm.hpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/boost/tree/algorithm.hpp (original)
+++ sandbox/SOC/2006/tree/trunk/boost/tree/algorithm.hpp 2009-01-25 18:18:08 EST (Sun, 25 Jan 2009)
@@ -89,8 +89,8 @@
 template <class Cursor>
 BOOST_CONCEPT_REQUIRES(
     ((DescendingCursor<Cursor>))
- ((AscendingCursor<Cursor>)),
- (typename Cursor::size_type)) // return type
+// ((AscendingCursor<Cursor>))
+ ,(typename Cursor::size_type)) // return type
 index(Cursor const& cur)
 {
     return std::distance(cur.parent().begin(), cur);

Modified: sandbox/SOC/2006/tree/trunk/boost/tree/inorder_algorithms.hpp
==============================================================================
--- sandbox/SOC/2006/tree/trunk/boost/tree/inorder_algorithms.hpp (original)
+++ sandbox/SOC/2006/tree/trunk/boost/tree/inorder_algorithms.hpp 2009-01-25 18:18:08 EST (Sun, 25 Jan 2009)
@@ -130,7 +130,7 @@
     MultiwayCursor y = x;
     while (!x.empty()) {
         x = std::lower_bound(x.begin(), x.end(), val);
- if (index(x) == 0)
+ if (x.index() == 0)
             y = x;
     }
     return y;

Deleted: 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 2009-01-25 18:18:08 EST (Sun, 25 Jan 2009)
+++ (empty file)
@@ -1,73 +0,0 @@
-// Copyright (c) 2006-2009, 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)
-
-
-#include <boost/tree/binary_tree.hpp>
-
-#include <boost/tree/iterator.hpp>
-#include <boost/tree/algorithm.hpp>
-
-#define BOOST_TEST_MODULE binary_tree test
-//#define BOOST_TEST_DYN_LINK
-#include <boost/test/included/unit_test.hpp>
-#include <boost/test/parameterized_test.hpp>
-
-#include <list>
-#include <algorithm>
-#include <iterator>
-
-#include "helpers.hpp"
-#include "fake_binary_tree.hpp"
-#include "test_tree_traversal_data.hpp"
-
-using namespace boost::tree;
-
-BOOST_FIXTURE_TEST_SUITE(binary_tree_search_test, test_binary_tree_fixture<int>)
-
-//template <class Cursor>
-//void search_single_element(Cursor r, int v)
-//{
-// Cursor c, d;
-// c = lower_bound(r, v);
-// d = upper_bound(r, v);
-//
-// BOOST_CHECK_EQUAL(*c, v);
-// //BOOST_CHECK_EQUAL(next(inorder(), c) , d);
-//}
-
-// Use mock cursor for tests, especially position!
-
-BOOST_AUTO_TEST_CASE( lower_bound_test )
-{
- binary_tree<int>::cursor c, d;
-
- c = lower_bound(bt.root(), 4); // (Left) Leaf
- c = lower_bound(bt.root(), 7); // (Right) Leaf
- c = lower_bound(bt.root(), 6); // Non-Leaf
- c = lower_bound(bt.root(), 8); // root().begin()
-
- c = lower_bound(bt.root(), 5); // Not in tree
- d = lower_bound(bt.root(), 5);
- BOOST_CHECK_EQUAL(*c, 6);
- BOOST_CHECK_EQUAL(*d, 6);
-
- //*c = 4;
-
- c = lower_bound(bt.root(), 5); // Not in tree
- BOOST_CHECK_EQUAL(*c, 6);
-
- c = lower_bound(bt.root(), 4); // Twice in tree
- //d = upper_bound(bt.root(), 4);
- BOOST_CHECK_EQUAL(*c, 4);
- BOOST_CHECK_EQUAL(*d, 6);
- //BOOST_CHECK_EQUAL(*c.parent(), 4);
- //BOOST_CHECK(next(inorder(), c, 2) == d);
-
- //*c.to_parent() = 6;
- //validate_test_dataset1_tree(bt.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 2009-01-25 18:18:08 EST (Sun, 25 Jan 2009)
@@ -125,19 +125,23 @@
 
     typedef typename fake_descending_binary_cursor<T>::cursor_facade_::size_type size_type;
 
+ fake_descending_binary_cursor()
+ : m_tree(0), m_pos(0) {}
+
     explicit fake_descending_binary_cursor(fake_binary_tree<T>& t, size_type p = 0)
- : m_tree(t), m_pos(p) {}
+ : 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) {}
 
     fake_descending_binary_cursor<T>& operator=(fake_descending_binary_cursor<T> const& other)
     {
+ m_tree = other.m_tree;
         m_pos = other.m_pos;
         return *this;
     }
 
- fake_binary_tree<T>& m_tree;
+ fake_binary_tree<T>* m_tree;
     typename fake_binary_tree<T>::size_type m_pos;
 
 private:
@@ -151,7 +155,7 @@
     typename fake_descending_binary_cursor<T>::cursor_facade_::reference
     dereference() const
     {
- return m_tree.m_data[(m_pos-1)/2];
+ return m_tree->m_data[(m_pos-1)/2];
     }
 
     bool equal(fake_descending_binary_cursor<T> const& other) const
@@ -184,11 +188,11 @@
     
     bool const empty_() const
     {
- if (m_pos >= m_tree.m_data.size())
+ if (m_pos >= m_tree->m_data.size())
             return true;
         if (m_pos == 0)
             return false;
- return (m_tree.m_data[m_pos] == def_val);
+ return (m_tree->m_data[m_pos] == def_val);
     }
 
     size_type const idx() const

Copied: sandbox/SOC/2006/tree/trunk/libs/tree/test/lower_bound_test.cpp (from r50717, /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/lower_bound_test.cpp 2009-01-25 18:18:08 EST (Sun, 25 Jan 2009)
@@ -25,49 +25,23 @@
 
 using namespace boost::tree;
 
-BOOST_FIXTURE_TEST_SUITE(binary_tree_search_test, test_binary_tree_fixture<int>)
-
-//template <class Cursor>
-//void search_single_element(Cursor r, int v)
-//{
-// Cursor c, d;
-// c = lower_bound(r, v);
-// d = upper_bound(r, v);
-//
-// BOOST_CHECK_EQUAL(*c, v);
-// //BOOST_CHECK_EQUAL(next(inorder(), c) , d);
-//}
-
-// Use mock cursor for tests, especially position!
+BOOST_FIXTURE_TEST_SUITE(binary_tree_search_test, fake_binary_tree_fixture<int>)
 
 BOOST_AUTO_TEST_CASE( lower_bound_test )
 {
- binary_tree<int>::cursor c, d;
+ fake_binary_tree<int>::cursor c(fbt1, 0), d(fbt1, 0);
 
- c = lower_bound(bt.root(), 4); // (Left) Leaf
- c = lower_bound(bt.root(), 7); // (Right) Leaf
- c = lower_bound(bt.root(), 6); // Non-Leaf
- c = lower_bound(bt.root(), 8); // root().begin()
-
- c = lower_bound(bt.root(), 5); // Not in tree
- d = lower_bound(bt.root(), 5);
- BOOST_CHECK_EQUAL(*c, 6);
- BOOST_CHECK_EQUAL(*d, 6);
-
- //*c = 4;
-
- c = lower_bound(bt.root(), 5); // Not in tree
+ c = lower_bound(fbt1.root(), 4); // (Left) Leaf
+ BOOST_CHECK_EQUAL(*c, 4);
+ c = lower_bound(fbt1.root(), 7); // (Right) Leaf
+ BOOST_CHECK_EQUAL(*c, 7);
+ c = lower_bound(fbt1.root(), 6); // Non-Leaf
     BOOST_CHECK_EQUAL(*c, 6);
+ c = lower_bound(fbt1.root(), 8); // root().begin()
+ BOOST_CHECK_EQUAL(*c, 8);
 
- c = lower_bound(bt.root(), 4); // Twice in tree
- //d = upper_bound(bt.root(), 4);
- BOOST_CHECK_EQUAL(*c, 4);
- BOOST_CHECK_EQUAL(*d, 6);
- //BOOST_CHECK_EQUAL(*c.parent(), 4);
- //BOOST_CHECK(next(inorder(), c, 2) == d);
-
- //*c.to_parent() = 6;
- //validate_test_dataset1_tree(bt.root());
+ c = lower_bound(fbt1.root(), 5); // Not in tree
+ BOOST_CHECK_EQUAL(*c, 6);
 }
 
 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