diff options
author | Alan Conway <aconway@apache.org> | 2008-06-04 19:26:44 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2008-06-04 19:26:44 +0000 |
commit | 9cc979c8c75fc85935f2905e4e6f67cc6b48a64b (patch) | |
tree | 4606c06c225de3fc721d0434bf6626e73feba91b | |
parent | 27b687803cfe614c6fcf641b5301e28ef492d0df (diff) | |
download | qpid-python-9cc979c8c75fc85935f2905e4e6f67cc6b48a64b.tar.gz |
Remove unused classes IList and ISList.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@663351 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | cpp/src/Makefile.am | 2 | ||||
-rw-r--r-- | cpp/src/qpid/IList.h | 200 | ||||
-rw-r--r-- | cpp/src/qpid/ISList.h | 178 | ||||
-rw-r--r-- | cpp/src/tests/IList.cpp | 172 | ||||
-rw-r--r-- | cpp/src/tests/ISList.cpp | 216 | ||||
-rw-r--r-- | cpp/src/tests/Makefile.am | 1 |
6 files changed, 0 insertions, 769 deletions
diff --git a/cpp/src/Makefile.am b/cpp/src/Makefile.am index 53b828a709..e0fd44f0c7 100644 --- a/cpp/src/Makefile.am +++ b/cpp/src/Makefile.am @@ -229,8 +229,6 @@ libqpidcommon_la_SOURCES = \ qpid/log/Options.cpp \ qpid/log/Selector.cpp \ qpid/log/Statement.cpp \ - qpid/IList.h \ - qpid/ISList.h \ qpid/pointer_to_other.h libqpidbroker_la_LIBADD = libqpidcommon.la -luuid diff --git a/cpp/src/qpid/IList.h b/cpp/src/qpid/IList.h deleted file mode 100644 index 6a5299862c..0000000000 --- a/cpp/src/qpid/IList.h +++ /dev/null @@ -1,200 +0,0 @@ -#ifndef QPID_ILIST_H -#define QPID_ILIST_H - -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -#include "ISList.h" - -namespace qpid { - -template <class> class IList; - -/** Base class for values (nodes) in an IList. - *@param raw or smart-pointer type to use for the "next" pointer. - * Using a smart pointer like shared_ptr or intrusive_ptr - * will automate memory management. - */ -template <class Pointer> class IListNode { - public: - typedef Pointer pointer; - typedef typename Pointee<Pointer>::type NodeType; - typedef typename pointer_to_other<Pointer, const NodeType>::type const_pointer; - - pointer prev, next; - - protected: - IListNode() : prev() {} - IListNode(const IListNode&) {} // Don't copy next/prev pointers - - pointer getNext() { return next; } - const_pointer getNext() const { return next; } - pointer getPrev() { return prev; } - const_pointer getPrev() const { return prev; } - - private: - friend class IList<NodeType>; -}; - - -/** - * Intrusive doubly-linked list. - * - * Provides bidirectional iterator and constant time insertion - * at front and back. - * - * The list itself performs no memory management. Use a smart pointer - * as the pointer type (e.g. intrusive_ptr, shared_ptr) for automated - * memory management. - * - * Unlike standard containers insert(), push_front() and push_back() - * take const pointer& rather than const value_type&. - * - * Iterators can be converted to the pointer type. - * - * Noncopyable - intrusively linked nodes cannot be shared between - * lists. Does provide swap() - * - * @param Node value type for the list, must derive from ISListNode<>. - */ -template<class Node> class IList { - template <class> class Iterator; - public: - typedef Node value_type; - typedef typename Node::pointer pointer; - typedef typename Node::const_pointer const_pointer; - typedef value_type& reference; - typedef const value_type& const_reference; - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef Iterator<value_type> iterator; - typedef Iterator<const value_type> const_iterator; - - IList() : begin_(), last_() {} - - iterator begin() { return begin_; } - const_iterator begin() const { return begin_; } - iterator end() { return 0; } - const_iterator end() const { return 0; } - - bool empty() const { return begin() == end(); } - - size_type size() const { - int s = 0; - for (const_iterator i=begin(); i != end(); ++i) - ++s; - return s; - } - - void swap(IList &x) { swap(begin_, x.begin_); swap(last_, x.last_); } - - iterator insert(iterator i, const pointer& p) { - if (empty()) { - begin_ = last_ = p; - insert(0, p, 0); - } - else if (i) { - insert(i->prev, p, i); - if (i == begin_) --begin_; - } - else { - insert(last_, p, 0) ; - last_ = p; - } - return p; - } - - void erase(iterator i) { - if (begin_ == last_) - begin_ = last_ = 0; - else { - if (i == begin_) ++begin_; - else i->prev->next = i->next; - if (i == last_) --last_; - else i->next->prev = i->prev; - } - i->prev = i->next = pointer(0); - } - - void erase(iterator i, iterator j) { while(i != j) erase(i); } - void clear() { while (!empty()) { erase(begin()); } } - - reference front() { return *begin(); } - const_reference front() const { return *begin(); } - void push_front(const pointer& p) { insert(begin(), p); } - void pop_front() { erase(begin()); } - - /** Iterator to the last element in the list. */ - iterator last() { return last_; } - const_iterator last() const { return last_; } - - reference back() { return *last(); } - const_reference back() const { return *last(); } - void push_back(const pointer& p) { insert(end(), p); } - void pop_back() { erase(last()); } - - private: - void insert(pointer a, pointer b, pointer c) { - b->prev = a; - if (a) a->next = b; - b->next = c; - if (c) c->prev = b; - } - - template <class T> - class Iterator : public boost::iterator_facade< - Iterator<T>, T, boost::bidirectional_traversal_tag> - { - public: - Iterator() : ptr() {}; - - template <class U> Iterator( - const Iterator<U>& i, - typename boost::enable_if_convertible<U*, T*>::type* = 0 - ) : ptr(i.ptr) {} - - operator pointer() { return ptr; } - operator const_pointer() const { return ptr; } - - - pointer ptr; - - - private: - friend class boost::iterator_core_access; - - Iterator(const_pointer p) : ptr(const_cast<pointer>(p)) {}; - - T& dereference() const { return *ptr; } - void increment() { ptr = ptr->next; } - void decrement() { ptr = ptr->prev; } - bool equal(const Iterator& x) const { return ptr == x.ptr; } - - - friend class IList<Node>; - }; - - iterator begin_, last_; -}; - -} // namespace qpid - -#endif /*!QPID_ILIST_H*/ diff --git a/cpp/src/qpid/ISList.h b/cpp/src/qpid/ISList.h deleted file mode 100644 index b0004c9561..0000000000 --- a/cpp/src/qpid/ISList.h +++ /dev/null @@ -1,178 +0,0 @@ -#ifndef QPID_ISLIST_H -#define QPID_ISLIST_H - -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -#include <boost/iterator/iterator_adaptor.hpp> -#include <boost/noncopyable.hpp> -#include "pointer_to_other.h" - -namespace qpid { - -template <class Pointer> struct Pointee { - typedef typename Pointer::element_type type; -}; - -template <class T> struct Pointee<T*> { - typedef T type; -}; - -template <class> class ISList; -template <class> class IList; - -/** Base class for values (nodes) in an ISList. - *@param raw or smart-pointer type to use for the "next" pointer. - * Using a smart pointer like shared_ptr or intrusive_ptr - * will automate memory management. - */ -template <class Pointer> class ISListNode { - public: - typedef Pointer pointer; - typedef typename Pointee<Pointer>::type NodeType; - typedef typename pointer_to_other<Pointer, const NodeType>::type const_pointer; - - pointer getNext() { return next; } - pointer * getNextPtr() { return & next; } - const_pointer getNext() const { return next; } - - protected: - ISListNode() : next() {} - ISListNode(const ISListNode&) {} // Don't copy the next pointer. - - - private: - pointer next; - friend class ISList<NodeType>; -}; - - -/** - * Intrusive singly-linked list. - * - * Provides forward iterator, constant time insertion and constant - * time pop_front (but not pop_back) so makes a good queue - * implementation. - * - * Unlike standard containers insert(), push_front() and push_back() - * take const pointer& rather than const value_type&. - * - * Iterators can be converted to pointers. - * - * Noncopyable - intrusively linked nodes cannot be shared. - * - * @param Node value type for the list, must derive from ISListNode<T>. - */ -template <class Node> class ISList : private boost::noncopyable { - template <class> class Iterator; - public: - typedef Node value_type; - typedef typename Node::pointer pointer; - typedef typename Node::const_pointer const_pointer; - typedef value_type& reference; - typedef const value_type& const_reference; - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef Iterator<value_type> iterator; - typedef Iterator<const value_type> const_iterator; - - ISList() : first(pointer()), end_(&first) {} - - iterator begin() { return iterator(&first); } - const_iterator begin() const { return const_iterator(&first); } - iterator end() { return end_; } - const_iterator end() const { return end_; } - - bool empty() const { return begin() == end(); } - - size_type size() const { - int s = 0; - for (const_iterator i=begin(); i != end(); ++i) - ++s; - return s; - } - - void swap(ISList &x) { swap(first, x.first); swap(end_, x.end_); } - - /** Unlike standard containers, insert takes a const pointer&, not a - * const value_type&. The value is not copied, only linked into the list. - */ - iterator insert(iterator i, const pointer& p) { - p->next = *(i.pptr); - *(i.pptr) = p; - if (i==end_) ++end_; - return i; - } - - void erase(iterator i) { - if (&i->next == end_.pptr) - end_ = i; - *(i.pptr) = (**(i.pptr)).next; - } - - void erase(iterator i, iterator j) { while(i != j) erase(i); } - void clear() { while (!empty()) { erase(begin()); } } - - reference front() { return *begin(); } - const_reference front() const { return *begin(); } - void pop_front() { erase(begin()); } - void push_front(pointer x) { insert(begin(), x); } - - void push_back(pointer x) { insert(end(), x); } - - private: - template <class T> - class Iterator : public boost::iterator_facade < - Iterator<T>, T, boost::forward_traversal_tag> - { - public: - Iterator() {}; - - template <class U> Iterator( - const Iterator<U>& i, - typename boost::enable_if_convertible<U*, T*>::type* = 0 - ) : pptr(i.pptr) {} - - operator pointer() { return *pptr; } - operator const_pointer() const { return *pptr; } - pointer* pptr; - - private: - friend class boost::iterator_core_access; - - Iterator(const pointer* pp) : pptr(const_cast<pointer*>(pp)) {}; - - T& dereference() const { return **pptr; } - void increment() { pptr = (**pptr).getNextPtr(); } - bool equal(const Iterator& x) const { return pptr == x.pptr; } - - - friend class ISList<Node>; - }; - - private: - pointer first; - iterator end_; -}; - -} // namespace qpid - -#endif /*!QPID_ISLIST_H*/ diff --git a/cpp/src/tests/IList.cpp b/cpp/src/tests/IList.cpp deleted file mode 100644 index a906e872e3..0000000000 --- a/cpp/src/tests/IList.cpp +++ /dev/null @@ -1,172 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -#include "qpid/IList.h" -#include "unit_test.h" -#include "test_tools.h" -#include <boost/assign/list_of.hpp> -#include <vector> - -QPID_AUTO_TEST_SUITE(IListTestSuite) - -using namespace qpid; -using namespace std; -using boost::assign::list_of; - -// Comparison, op== and << for ILists in qpid namespace for template lookup. - -template <class T, class S> bool operator==(const IList<T>& a, const S& b) { return seqEqual(a, b); } -template <class T> ostream& operator<<(std::ostream& o, const IList<T>& l) { return seqPrint(o, l); } -template <class T> -ostream& operator<<(ostream& o, typename IList<T>::iterator i) { - return i? o << "(nil)" : o << *i; -} - -struct IListFixture { - struct Node : public IListNode<Node*> { - char value; - Node(char c) { value=c; } - bool operator==(const Node& n) const { return value == n.value; } - }; - typedef IList<Node> List; - Node a, b, c, d, e; - IListFixture() :a('a'),b('b'),c('c'),d('d'),e('e') {} -}; - -ostream& operator<<(ostream& o, const IListFixture::Node& n) { return o << n.value; } - -QPID_AUTO_TEST_CASE(IList_default_ctor) { - IListFixture fix; - IListFixture::List l; - BOOST_CHECK(l.empty()); - BOOST_CHECK(l.begin() == l.end()); - BOOST_CHECK_EQUAL(0u, l.size()); -} - -QPID_AUTO_TEST_CASE(IList_push_front) { - IListFixture fix; - IListFixture::List l; - l.push_front(&(fix.a)); - BOOST_CHECK_EQUAL(1u, l.size()); - BOOST_CHECK_EQUAL(l, list_of(fix.a)); - l.push_front(&(fix.b)); - BOOST_CHECK_EQUAL(2u, l.size()); - BOOST_CHECK_EQUAL(l, list_of(fix.b)(fix.a)); -} - -QPID_AUTO_TEST_CASE(IList_push_back) { - IListFixture fix; - IListFixture::List l; - l.push_back(&(fix.a)); - BOOST_CHECK_EQUAL(1u, l.size()); - BOOST_CHECK_EQUAL(l, list_of(fix.a)); - l.push_back(&(fix.b)); - BOOST_CHECK_EQUAL(2u, l.size()); - BOOST_CHECK_EQUAL(l, list_of(fix.a)(fix.b)); -} - -QPID_AUTO_TEST_CASE(IList_insert) { - IListFixture fix; - IListFixture::List l; - IListFixture::List::iterator i(l.begin()); - i = l.insert(i, &(fix.a)); - BOOST_CHECK_EQUAL(l, list_of(fix.a)); - BOOST_CHECK(i == l.begin()); - - i = l.insert(i, &(fix.b)); - BOOST_CHECK_EQUAL(l, list_of(fix.b)(fix.a)); - BOOST_CHECK(i == l.begin()); - - i++; - BOOST_CHECK_EQUAL(*i, fix.a); - i = l.insert(i, &(fix.c)); - BOOST_CHECK_EQUAL(l, list_of(fix.b)(fix.c)(fix.a)); - BOOST_CHECK_EQUAL(*i, fix.c); - - i = l.insert(i, &(fix.d)); - BOOST_CHECK_EQUAL(l, list_of(fix.b)(fix.d)(fix.c)(fix.a)); - BOOST_CHECK_EQUAL(*i, fix.d); -} - -QPID_AUTO_TEST_CASE(IList_iterator_test) { - IListFixture fix; - IListFixture::List l; - l.push_back(&(fix.a)); - l.push_back(&(fix.b)); - - IListFixture::List::iterator i = l.begin(); - BOOST_CHECK_EQUAL(*i, fix.a); - BOOST_CHECK_EQUAL(static_cast<IListFixture::Node*>(i), &(fix.a)); - IListFixture::List::const_iterator ci = i; - BOOST_CHECK_EQUAL(static_cast<const IListFixture::Node*>(ci), &(fix.a)); - - i++; - BOOST_CHECK_EQUAL(*i, fix.b); - BOOST_CHECK_EQUAL(static_cast<IListFixture::Node*>(i), &(fix.b)); - i++; - BOOST_CHECK(i == l.end()); -} - -QPID_AUTO_TEST_CASE(IList_pop_front) { - IListFixture fix; - IListFixture::List l; - l.push_back(&(fix.a)); - l.push_back(&(fix.b)); - BOOST_CHECK_EQUAL(l, list_of(fix.a)(fix.b)); - l.pop_front(); - BOOST_CHECK_EQUAL(l, list_of(fix.b)); - l.pop_front(); - BOOST_CHECK(l.empty()); -} - -QPID_AUTO_TEST_CASE(IList_pop_back) { - IListFixture fix; - IListFixture::List l; - l.push_back(&(fix.a)); - l.push_back(&(fix.b)); - l.pop_back(); - BOOST_CHECK_EQUAL(l, list_of(fix.a)); - l.pop_back(); - BOOST_CHECK(l.empty()); -} - -QPID_AUTO_TEST_CASE(IList_erase) { - IListFixture fix; - IListFixture::List l; - l.push_back(&(fix.a)); - l.push_back(&(fix.b)); - l.push_back(&(fix.c)); - - IListFixture::List::iterator i=l.begin(); - i++; - l.erase(i); - BOOST_CHECK_EQUAL(l, list_of(fix.a)(fix.c)); - - i=l.begin(); - i++; - l.erase(i); - BOOST_CHECK_EQUAL(l, list_of(fix.a)); - - l.erase(l.begin()); - BOOST_CHECK(l.empty()); -} - -QPID_AUTO_TEST_SUITE_END() - diff --git a/cpp/src/tests/ISList.cpp b/cpp/src/tests/ISList.cpp deleted file mode 100644 index ae16895803..0000000000 --- a/cpp/src/tests/ISList.cpp +++ /dev/null @@ -1,216 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -#include "qpid/ISList.h" -#include "qpid/RefCounted.h" -#include "unit_test.h" -#include "test_tools.h" -#include <boost/assign/list_of.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/intrusive_ptr.hpp> -#include <vector> - -QPID_AUTO_TEST_SUITE(ISListTestSuite) - -using namespace qpid; -using namespace std; -using boost::assign::list_of; -using boost::intrusive_ptr; - -// Comparison, op== and << for ILists in qpid namespace for template lookup. - -template <class T, class S> bool operator==(const ISList<T>& a, const S& b) { return seqEqual(a, b); } -template <class T> ostream& operator<<(std::ostream& o, const ISList<T>& l) { return seqPrint(o, l); } -template <class T> -ostream& operator<<(ostream& o, typename ISList<T>::iterator i) { - return i? o << "(nil)" : o << *i; -} - -struct NodeBase { - static int instances; - char value; - - NodeBase(char c) { value=c; ++instances; } - NodeBase(const NodeBase& n) { value=n.value; ++instances; } - ~NodeBase() { --instances; } - bool operator==(const NodeBase& n) const { return value == n.value; } -}; - -int NodeBase::instances = 0; - -ostream& operator<<(ostream& o, const NodeBase& n) { return o << n.value; } - -struct Fixture { - struct Node : public NodeBase, public ISListNode<Node*> { - Node(char c) : NodeBase(c) {} - }; - typedef ISList<Node> List; - Node a, b, c, d, e; - List l; - Fixture() :a('a'),b('b'),c('c'),d('d'),e('e') {} -}; - -QPID_AUTO_TEST_CASE(default_ctor) { - Fixture fix; - BOOST_CHECK(fix.l.empty()); - BOOST_CHECK(fix.l.begin() == fix.l.end()); - BOOST_CHECK_EQUAL(0u, fix.l.size()); -} - -QPID_AUTO_TEST_CASE(push_front) { - Fixture fix; - fix.l.push_front(&(fix.a)); - BOOST_CHECK_EQUAL(1u, fix.l.size()); - BOOST_CHECK_EQUAL(fix.l, list_of(fix.a)); - fix.l.push_front(&(fix.b)); - BOOST_CHECK_EQUAL(2u, fix.l.size()); - BOOST_CHECK_EQUAL(fix.l, list_of(fix.b)(fix.a)); -} - -QPID_AUTO_TEST_CASE(push_back) { - Fixture fix; - fix.l.push_back(&(fix.a)); - BOOST_CHECK_EQUAL(1u, fix.l.size()); - BOOST_CHECK_EQUAL(fix.l, list_of(fix.a)); - fix.l.push_back(&(fix.b)); - BOOST_CHECK_EQUAL(2u, fix.l.size()); - BOOST_CHECK_EQUAL(fix.l, list_of(fix.a)(fix.b)); -} - -QPID_AUTO_TEST_CASE(insert) { - Fixture fix; - Fixture::List::iterator i(fix.l.begin()); - i = fix.l.insert(i, &(fix.a)); - BOOST_CHECK_EQUAL(fix.l, list_of(fix.a)); - BOOST_CHECK(i == fix.l.begin()); - - i = fix.l.insert(i, &(fix.b)); - BOOST_CHECK_EQUAL(fix.l, list_of(fix.b)(fix.a)); - BOOST_CHECK(i == fix.l.begin()); - - i++; - BOOST_CHECK_EQUAL(*i, fix.a); - i = fix.l.insert(i, &(fix.c)); - BOOST_CHECK_EQUAL(fix.l, list_of(fix.b)(fix.c)(fix.a)); - BOOST_CHECK_EQUAL(*i, fix.c); - - i = fix.l.insert(i, &(fix.d)); - BOOST_CHECK_EQUAL(fix.l, list_of(fix.b)(fix.d)(fix.c)(fix.a)); - BOOST_CHECK_EQUAL(*i, fix.d); -} - -QPID_AUTO_TEST_CASE(iterator_test) { - Fixture fix; - fix.l.push_back(&(fix.a)); - fix.l.push_back(&(fix.b)); - - Fixture::List::iterator i = fix.l.begin(); - BOOST_CHECK_EQUAL(*i, fix.a); - BOOST_CHECK_EQUAL(static_cast<Fixture::Node*>(i), &(fix.a)); - Fixture::List::const_iterator ci = i; - BOOST_CHECK_EQUAL(static_cast<const Fixture::Node*>(ci), &(fix.a)); - - i++; - BOOST_CHECK_EQUAL(*i, fix.b); - BOOST_CHECK_EQUAL(static_cast<Fixture::Node*>(i), &(fix.b)); - i++; - BOOST_CHECK(i == fix.l.end()); -} - -QPID_AUTO_TEST_CASE(pop_front) { - Fixture fix; - fix.l.push_back(&(fix.a)); - fix.l.push_back(&(fix.b)); - fix.l.pop_front(); - BOOST_CHECK_EQUAL(fix.l, list_of(fix.b)); - fix.l.pop_front(); - BOOST_CHECK(fix.l.empty()); -} - -QPID_AUTO_TEST_CASE(erase) { - Fixture fix; - fix.l.push_back(&(fix.a)); - fix.l.push_back(&(fix.b)); - fix.l.push_back(&(fix.c)); - - Fixture::List::iterator i=fix.l.begin(); - i++; - fix.l.erase(i); - BOOST_CHECK_EQUAL(fix.l, list_of(fix.a)(fix.c)); - - i=fix.l.begin(); - i++; - fix.l.erase(i); - BOOST_CHECK_EQUAL(fix.l, list_of(fix.a)); - - fix.l.erase(fix.l.begin()); - BOOST_CHECK(fix.l.empty()); -} - - -// ================ Test smart pointer types. - -template <class Node> void smart_pointer_test() { - typedef typename Node::pointer pointer; - typedef ISList<Node> List; - List l; - - BOOST_CHECK_EQUAL(0, NodeBase::instances); - l.push_back(pointer(new Node())); - l.push_back(pointer(new Node())); - BOOST_CHECK_EQUAL(2, NodeBase::instances); // maintains a reference. - - pointer p = l.begin(); - l.pop_front(); - BOOST_CHECK_EQUAL(2, NodeBase::instances); // transfers ownership. - p = pointer(); - BOOST_CHECK_EQUAL(1, NodeBase::instances); - - l.clear(); - BOOST_CHECK_EQUAL(0, NodeBase::instances); - { // Dtor cleans up - List ll; - ll.push_back(pointer(new Node())); - BOOST_CHECK_EQUAL(1, NodeBase::instances); - } - BOOST_CHECK_EQUAL(0, NodeBase::instances); -} - -struct IntrusiveNode : public NodeBase, public RefCounted, - public ISListNode<intrusive_ptr<IntrusiveNode> > -{ - IntrusiveNode() : NodeBase(0) {} -}; - - -QPID_AUTO_TEST_CASE(intrusive_ptr_test) { - smart_pointer_test<IntrusiveNode>(); -} - - -struct SharedNode : public NodeBase, public ISListNode<boost::shared_ptr<SharedNode> > { - SharedNode() : NodeBase(0) {} -}; - -QPID_AUTO_TEST_CASE(shared_ptr_test) { - smart_pointer_test<SharedNode>(); -} - -QPID_AUTO_TEST_SUITE_END() diff --git a/cpp/src/tests/Makefile.am b/cpp/src/tests/Makefile.am index b53176ebd1..2a47ef45fd 100644 --- a/cpp/src/tests/Makefile.am +++ b/cpp/src/tests/Makefile.am @@ -39,7 +39,6 @@ unit_test_SOURCES= unit_test.cpp unit_test.h \ Shlib.cpp FieldValue.cpp FieldTable.cpp Array.cpp \ InlineAllocator.cpp \ InlineVector.cpp \ - ISList.cpp IList.cpp \ ClientSessionTest.cpp \ SequenceSet.cpp \ StringUtils.cpp \ |