diff options
author | wolff1 <wolff1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2007-12-22 16:39:46 +0000 |
---|---|---|
committer | wolff1 <wolff1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2007-12-22 16:39:46 +0000 |
commit | 39e9ef207276cc3c7073fa212ba184b62afe573f (patch) | |
tree | bd4853284e3fff42dc4cec828cd05818e8b7f7f0 | |
parent | 899a895b2a1e5f6856cf2ca932717d4615140f02 (diff) | |
download | ATCD-39e9ef207276cc3c7073fa212ba184b62afe573f.tar.gz |
added TAO_HAS_SEQUENCE_ITERATORS macro and test for value sequence
-rw-r--r-- | TAO/tao/Bounded_Basic_String_Sequence_T.h | 4 | ||||
-rw-r--r-- | TAO/tao/Generic_Sequence_T.h | 16 | ||||
-rw-r--r-- | TAO/tao/Unbounded_Basic_String_Sequence_T.h | 4 | ||||
-rw-r--r-- | TAO/tao/Unbounded_Object_Reference_Sequence_T.h | 6 | ||||
-rw-r--r-- | TAO/tao/Unbounded_Value_Sequence_T.h | 6 | ||||
-rw-r--r-- | TAO/tao/orbconf.h | 4 | ||||
-rw-r--r-- | TAO/tests/Sequence_Iterators/Bounded_String.cpp | 3 | ||||
-rw-r--r-- | TAO/tests/Sequence_Iterators/Sequence_Iterators.mpc | 9 | ||||
-rw-r--r-- | TAO/tests/Sequence_Iterators/StringSeq.cpp | 1 | ||||
-rw-r--r-- | TAO/tests/Sequence_Iterators/Unbounded_Objectref.cpp | 475 | ||||
-rwxr-xr-x | TAO/tests/Sequence_Iterators/run_test.pl | 27 |
11 files changed, 508 insertions, 47 deletions
diff --git a/TAO/tao/Bounded_Basic_String_Sequence_T.h b/TAO/tao/Bounded_Basic_String_Sequence_T.h index 923447e523b..e43c34f539f 100644 --- a/TAO/tao/Bounded_Basic_String_Sequence_T.h +++ b/TAO/tao/Bounded_Basic_String_Sequence_T.h @@ -105,7 +105,7 @@ public: implementation_type::freebuf(buffer); } -#ifdef ACE_HAS_STDCPP_STL_INCLUDES +#if TAO_HAS_SEQUENCE_ITERATORS /// /// Additions to support iterator semantics for TAO unbounded basic @@ -168,7 +168,7 @@ public: return impl_.rend (); } -#endif /* ACE_HAS_STDCPP_STL_INCLUDES */ +#endif /* TAO_HAS_SEQUENCE_ITERATORS */ private: implementation_type impl_; diff --git a/TAO/tao/Generic_Sequence_T.h b/TAO/tao/Generic_Sequence_T.h index 1fd067c4c83..66536fd40a5 100644 --- a/TAO/tao/Generic_Sequence_T.h +++ b/TAO/tao/Generic_Sequence_T.h @@ -68,7 +68,7 @@ namespace TAO namespace details { -#ifdef ACE_HAS_STDCPP_STL_INCLUDES +#if TAO_HAS_SEQUENCE_ITERATORS // Forward declare the iterators template<typename T> @@ -83,7 +83,7 @@ class Generic_Sequence_Reverse_Iterator; template<typename T> class Const_Generic_Sequence_Reverse_Iterator; -#endif /* ACE_HAS_STDCPP_STL_INCLUDES */ +#endif /* TAO_HAS_SEQUENCE_ITERATORS */ template<typename T, class ALLOCATION_TRAITS, @@ -91,14 +91,14 @@ template<typename T, class generic_sequence { -#ifdef ACE_HAS_STDCPP_STL_INCLUDES +#if TAO_HAS_SEQUENCE_ITERATORS friend class Generic_Sequence_Iterator<generic_sequence<T, ALLOCATION_TRAITS, ELEMENT_TRAITS> >; friend class Const_Generic_Sequence_Iterator<generic_sequence<T, ALLOCATION_TRAITS, ELEMENT_TRAITS> >; friend class Generic_Sequence_Reverse_Iterator<generic_sequence<T, ALLOCATION_TRAITS, ELEMENT_TRAITS> >; friend class Const_Generic_Sequence_Reverse_Iterator<generic_sequence<T, ALLOCATION_TRAITS, ELEMENT_TRAITS> >; -#endif /* ACE_HAS_STDCPP_STL_INCLUDES */ +#endif /* TAO_HAS_SEQUENCE_ITERATORS */ public: typedef T value_type; @@ -344,7 +344,7 @@ public: allocation_traits::freebuf(buffer); } -#ifdef ACE_HAS_STDCPP_STL_INCLUDES +#if TAO_HAS_SEQUENCE_ITERATORS /// /// Additions to support iterator semantics for TAO sequences. @@ -416,7 +416,7 @@ public: -1); } -#endif /* ACE_HAS_STDCPP_STL_INCLUDES */ +#endif /* TAO_HAS_SEQUENCE_ITERATORS */ private: /// The maximum number of elements the buffer can contain. @@ -430,7 +430,7 @@ private: mutable CORBA::Boolean release_; }; -#ifdef ACE_HAS_STDCPP_STL_INCLUDES +#if TAO_HAS_SEQUENCE_ITERATORS /** * @class Generic_Sequence_Iterator @@ -1308,7 +1308,7 @@ template<typename SEQUENCE_T> return Const_Generic_Sequence_Reverse_Iterator<SEQUENCE_T> (iter.sequence_, iter.pos_ + n); } -#endif /* ACE_HAS_STDCPP_STL_INCLUDES */ +#endif /* TAO_HAS_SEQUENCE_ITERATORS */ } // namespace details } // namespace TAO diff --git a/TAO/tao/Unbounded_Basic_String_Sequence_T.h b/TAO/tao/Unbounded_Basic_String_Sequence_T.h index 9c0194a86d5..0e361aad73c 100644 --- a/TAO/tao/Unbounded_Basic_String_Sequence_T.h +++ b/TAO/tao/Unbounded_Basic_String_Sequence_T.h @@ -112,7 +112,7 @@ public: implementation_type::freebuf(buffer); } -#ifdef ACE_HAS_STDCPP_STL_INCLUDES +#if TAO_HAS_SEQUENCE_ITERATORS /// /// Additions to support iterator semantics for TAO unbounded basic @@ -175,7 +175,7 @@ public: return impl_.rend (); } -#endif /* ACE_HAS_STDCPP_STL_INCLUDES */ +#endif /* TAO_HAS_SEQUENCE_ITERATORS */ private: implementation_type impl_; diff --git a/TAO/tao/Unbounded_Object_Reference_Sequence_T.h b/TAO/tao/Unbounded_Object_Reference_Sequence_T.h index 3bfc59f384c..33c1ae24433 100644 --- a/TAO/tao/Unbounded_Object_Reference_Sequence_T.h +++ b/TAO/tao/Unbounded_Object_Reference_Sequence_T.h @@ -107,7 +107,7 @@ public: implementation_type::freebuf(buffer); } -#ifdef ACE_HAS_STDCPP_STL_INCLUDES +#if TAO_HAS_SEQUENCE_ITERATORS /// /// Additions to support iterator semantics for TAO unbounded object reference @@ -160,7 +160,7 @@ public: // of the sequence. reverse_iterator rend (void) { - return impl_.end (); + return impl_.rend (); } // Get a const reverse iterator that points to one before the @@ -170,7 +170,7 @@ public: return impl_.rend (); } -#endif /* ACE_HAS_STDCPP_STL_INCLUDES */ +#endif /* TAO_HAS_SEQUENCE_ITERATORS */ private: implementation_type impl_; diff --git a/TAO/tao/Unbounded_Value_Sequence_T.h b/TAO/tao/Unbounded_Value_Sequence_T.h index ab72d60c3c1..3660c77af75 100644 --- a/TAO/tao/Unbounded_Value_Sequence_T.h +++ b/TAO/tao/Unbounded_Value_Sequence_T.h @@ -89,7 +89,7 @@ public: implementation_type::freebuf(buffer); } -#ifdef ACE_HAS_STDCPP_STL_INCLUDES +#if TAO_HAS_SEQUENCE_ITERATORS /// /// Additions to support iterator semantics for TAO unbounded value @@ -142,7 +142,7 @@ public: // of the sequence. reverse_iterator rend (void) { - return impl_.end (); + return impl_.rend (); } // Get a const reverse iterator that points to one before the @@ -152,7 +152,7 @@ public: return impl_.rend (); } -#endif /* ACE_HAS_STDCPP_STL_INCLUDES */ +#endif /* TAO_HAS_SEQUENCE_ITERATORS */ private: implementation_type impl_; diff --git a/TAO/tao/orbconf.h b/TAO/tao/orbconf.h index fb9cace70ac..11ee0de97cd 100644 --- a/TAO/tao/orbconf.h +++ b/TAO/tao/orbconf.h @@ -878,6 +878,10 @@ enum TAO_Policy_Scope # endif #endif +#if !defined (TAO_HAS_SEQUENCE_ITERATORS) +# define TAO_HAS_SEQUENCE_ITERATORS 1 +#endif + TAO_END_VERSIONED_NAMESPACE_DECL #include /**/ "ace/post.h" diff --git a/TAO/tests/Sequence_Iterators/Bounded_String.cpp b/TAO/tests/Sequence_Iterators/Bounded_String.cpp index fe5b5c73b1b..34822993435 100644 --- a/TAO/tests/Sequence_Iterators/Bounded_String.cpp +++ b/TAO/tests/Sequence_Iterators/Bounded_String.cpp @@ -19,7 +19,6 @@ typedef TAO::bounded_basic_string_sequence<char, 4> s_sequence; #define FAIL_RETURN_IF(CONDITION) \ - ACE_DEBUG ((LM_INFO, ACE_TEXT ("in %N:%l\n"))); \ if (CONDITION) \ { \ ACE_DEBUG ((LM_ERROR, ACE_TEXT ("\tFailed at %N:%l\n"))); \ @@ -651,6 +650,8 @@ int test_const_sequence_reverse () return 0; } +//----------------------------------------------------------------------------- + int main(int,char*[]) { int status = 0; diff --git a/TAO/tests/Sequence_Iterators/Sequence_Iterators.mpc b/TAO/tests/Sequence_Iterators/Sequence_Iterators.mpc index 31f3f0e886f..e590fb0f526 100644 --- a/TAO/tests/Sequence_Iterators/Sequence_Iterators.mpc +++ b/TAO/tests/Sequence_Iterators/Sequence_Iterators.mpc @@ -19,6 +19,15 @@ project(Bounded_String) : taoexe { } } +project(Unbounded_Value) : taoexe { + + exename = Unbounded_Value + + Source_Files { + Unbounded_Value.cpp + } +} + project(Unbounded_Objectref) : taoexe { exename = Unbounded_Objectref diff --git a/TAO/tests/Sequence_Iterators/StringSeq.cpp b/TAO/tests/Sequence_Iterators/StringSeq.cpp index e20b3a3c9bf..c041a3e41d5 100644 --- a/TAO/tests/Sequence_Iterators/StringSeq.cpp +++ b/TAO/tests/Sequence_Iterators/StringSeq.cpp @@ -15,7 +15,6 @@ #include <sstream> #define FAIL_RETURN_IF(CONDITION) \ - ACE_DEBUG ((LM_INFO, ACE_TEXT ("in %N:%l\n"))); \ if (CONDITION) \ { \ ACE_DEBUG ((LM_ERROR, ACE_TEXT ("\tFailed at %N:%l\n"))); \ diff --git a/TAO/tests/Sequence_Iterators/Unbounded_Objectref.cpp b/TAO/tests/Sequence_Iterators/Unbounded_Objectref.cpp index 418d2cb2bb9..ed9ff002b0f 100644 --- a/TAO/tests/Sequence_Iterators/Unbounded_Objectref.cpp +++ b/TAO/tests/Sequence_Iterators/Unbounded_Objectref.cpp @@ -1,7 +1,8 @@ /** * @file Unbounded_Objectref.cpp * - * @brief test for STL iterator behaviour of CORBA unbounded value sequence + * @brief test for STL iterator behaviour of CORBA unbounded object reference + * sequence * * $Id$ * @@ -19,7 +20,6 @@ #include "tao/Unbounded_Object_Reference_Sequence_T.h" #define FAIL_RETURN_IF(CONDITION) \ - ACE_DEBUG ((LM_INFO, ACE_TEXT ("in %N:%l\n"))); \ if (CONDITION) \ { \ ACE_DEBUG ((LM_ERROR, ACE_TEXT ("\tFailed at %N:%l\n"))); \ @@ -174,6 +174,462 @@ int test_sequence () return 0; } +//----------------------------------------------------------------------------- + +template <typename ITERATOR_T> +int test_const_sequence () +{ + // setup of an example sequence + tested_sequence setup; + setup.length (4); + + mock_reference* elem0 = mock_reference::allocate (0); + mock_reference* elem1 = mock_reference::allocate (1); + mock_reference* elem2 = mock_reference::allocate (2); + mock_reference* elem3 = mock_reference::allocate (3); + + // setup of an example sequence + setup[0] = mock_reference::_duplicate (elem0); + setup[1] = mock_reference::_duplicate (elem1); + setup[2] = mock_reference::_duplicate (elem2); + setup[3] = mock_reference::_duplicate (elem3); + + const tested_sequence a = setup; + + // test equality operator + FAIL_RETURN_IF (!(a.begin () == a.begin ())); + + // test non-equality operator + FAIL_RETURN_IF (a.end () != a.end ()); + + // test iterator copy constructor + ITERATOR_T a_it (a.begin ()); + FAIL_RETURN_IF (a_it != a.begin ()); + + // test assignment operator + a_it = a.begin (); + FAIL_RETURN_IF (a_it != a.begin ()); + + // test non const dereferencing + mock_reference* value0 = *a_it; + FAIL_RETURN_IF (value0->id () != elem0->id ()); + + // test const dereferencing + const mock_reference* const value1 = *a_it; + FAIL_RETURN_IF (value1->id () != elem0->id ()); + + // test increment operation + a_it++; + FAIL_RETURN_IF (a_it == a.begin()); + FAIL_RETURN_IF ((*a_it)->id () != elem1->id ()); + + // test < operator + FAIL_RETURN_IF (!(a.begin () < a_it)); + FAIL_RETURN_IF (a_it < a.begin ()); + + // test difference type + int a_diff = a_it - a.begin (); + FAIL_RETURN_IF (a_diff != 1); + + // test copy constructor + ITERATOR_T a_it1 (a_it); + FAIL_RETURN_IF (a_it1 != a_it); + + // test preincrement operator + ++a_it1; + FAIL_RETURN_IF ((a_it1 - a_it) != 1); + + // test = and += operator + ITERATOR_T a_it2 = a_it += 3; + FAIL_RETURN_IF (a_it2 != a_it); + FAIL_RETURN_IF ((a_it - a_it1) != 2); + + // test + operator + a_it2 = a_it1 + 3; + FAIL_RETURN_IF ((a_it2 - a_it1) != 3); + + // test post-decrement operation + a_it = a.end (); + a_it--; + FAIL_RETURN_IF (a_it == a.end ()); + FAIL_RETURN_IF ((a.end () - a_it) != 1); + FAIL_RETURN_IF ((*a_it)->id () != elem3->id ()); + + // test pre-decrement operator + a_it = a.end (); + --a_it; + FAIL_RETURN_IF (a_it == a.end ()); + FAIL_RETURN_IF ((a.end () - a_it) != 1); + FAIL_RETURN_IF ((*a_it)->id () != elem3->id ()); + + // test -= operator + a_it -= 3; + FAIL_RETURN_IF ((a_it1 - a_it) != 2); + + // test - operator + a_it2 = a_it1 - 2; + FAIL_RETURN_IF ((a_it1 - a_it2) != 2); + + // test operator[] read + a_it = a.begin (); + FAIL_RETURN_IF ((a_it[0])->id () != a[0]->id ()); + a_it += 2; + FAIL_RETURN_IF ((a_it[0])->id () != a[2]->id ()); + + // test for loop behaviour + tested_sequence b = a; + ITERATOR_T b_it = b.begin (); + + for (a_it = a.begin (); + a_it != a.end (); + a_it++, b_it++) + { + FAIL_RETURN_IF ((*a_it)->id () != (*b_it)->id ()); + } + + tested_sequence test; + test.length (4); + + // Memory is leaked here from + // TAO::details::string_traits_base<char>::default_initializer() + + std::copy (a.begin (), + a.end (), + test.begin ()); + + FAIL_RETURN_IF (test.length () != a.length ()); + + ITERATOR_T copytest_iter = test.begin (); + for (ITERATOR_T copya_iter = a.begin (); + copya_iter != a.end (); + ++copya_iter, ++copytest_iter) + { + FAIL_RETURN_IF ((*copya_iter)->id () != (*copytest_iter)->id ()); + } + + /// Testing - using ostream_iterator + + std::ostringstream ostream; + std::copy (a.begin (), + a.end (), + std::ostream_iterator<tested_sequence::value_type> (ostream, + "\n")); + + FAIL_RETURN_IF ( + ostream.str ().compare ("elem0\nelem1\nelem2\nelem3\n") != 0); + + return 0; +} + +//----------------------------------------------------------------------------- + +template <typename REVERSE_ITERATOR_T> +int test_sequence_reverse () +{ + tested_sequence a; + + // test equality operator + FAIL_RETURN_IF (!(a.begin () == a.begin ())); + + // test non-equality operator + FAIL_RETURN_IF (a.end () != a.end ()); + + // test for correct behaviour for empty sequence + + FAIL_RETURN_IF (a.begin() != a.end ()); + + // setup of an example sequence + a.length (4); + + mock_reference* elem0 = mock_reference::allocate (0); + mock_reference* elem1 = mock_reference::allocate (1); + mock_reference* elem2 = mock_reference::allocate (2); + mock_reference* elem3 = mock_reference::allocate (3); + + // setup of an example sequence + a.length (4); + a[0] = mock_reference::_duplicate (elem0); + a[1] = mock_reference::_duplicate (elem1); + a[2] = mock_reference::_duplicate (elem2); + a[3] = mock_reference::_duplicate (elem3); + + // test iterator copy constructor + REVERSE_ITERATOR_T a_it (a.rbegin ()); + FAIL_RETURN_IF (a_it != a.rbegin ()); + + // test assignment operator + a_it = a.rbegin (); + FAIL_RETURN_IF (a_it != a.rbegin ()); + + // test non const dereferencing + mock_reference* value0 = *a_it; + FAIL_RETURN_IF (value0->id () != elem3->id ()); + + // test const dereferencing + const mock_reference* const value1 = *a_it; + FAIL_RETURN_IF (value1->id () != elem3->id ()); + + // test increment operation + a_it++; + FAIL_RETURN_IF (a_it == a.rbegin()); + FAIL_RETURN_IF ((*a_it)->id () != elem2->id ()); + + // test < operator + FAIL_RETURN_IF (!(a.rbegin () < a_it)); + FAIL_RETURN_IF (a_it < a.rbegin ()); + + // test difference type + int a_diff = a_it - a.rbegin (); + FAIL_RETURN_IF (a_diff != 1); + + // test copy constructor + REVERSE_ITERATOR_T a_it1 (a_it); + FAIL_RETURN_IF (a_it1 != a_it); + + // test preincrement operator + ++a_it1; + FAIL_RETURN_IF ((a_it1 - a_it) != 1); + + // test = and += operator + REVERSE_ITERATOR_T a_it2 = a_it += 3; + FAIL_RETURN_IF (a_it2 != a_it); + FAIL_RETURN_IF ((a_it - a_it1) != 2); + + // test + operator + a_it2 = a_it1 + 3; + FAIL_RETURN_IF ((a_it2 - a_it1) != 3); + + // test post-decrement operation + a_it = a.rend (); + a_it--; + FAIL_RETURN_IF (a_it == a.rend ()); + FAIL_RETURN_IF ((a.rend () - a_it) != 1); + FAIL_RETURN_IF ((*a_it)->id () != elem0->id ()); + + // test pre-decrement operator + a_it = a.rend (); + --a_it; + FAIL_RETURN_IF (a_it == a.rend ()); + FAIL_RETURN_IF ((a.rend () - a_it) != 1); + FAIL_RETURN_IF ((*a_it)->id () != elem0->id ()); + + // test -= operator + a_it -= 3; + FAIL_RETURN_IF ((a_it1 - a_it) != 2); + + // test - operator + a_it2 = a_it1 - 2; + FAIL_RETURN_IF ((a_it1 - a_it2) != 2); + + // test operator[] read + a_it = a.rbegin (); + FAIL_RETURN_IF ((a_it[0])->id () != a[3]->id ()); + a_it += 2; + FAIL_RETURN_IF ((a_it[0])->id () != a[1]->id ()); + + // test for loop behaviour + tested_sequence b = a; + REVERSE_ITERATOR_T b_it = b.rbegin (); + + for (a_it = a.rbegin (); + a_it != a.rend (); + a_it++, b_it++) + { + FAIL_RETURN_IF ((*a_it)->id () != (*b_it)->id ()); + } + + tested_sequence test; + test.length (a.length ()); + + // Memory is leaked here from + // TAO::details::string_traits_base<char>::default_initializer() + + std::copy (a.begin (), + a.end (), + test.begin ()); + + FAIL_RETURN_IF (test.length () != a.length ()); + + REVERSE_ITERATOR_T copytest_iter = test.rbegin (); + for (REVERSE_ITERATOR_T copya_iter = a.rbegin (); + copya_iter != a.rend (); + ++copya_iter, ++copytest_iter) + { + FAIL_RETURN_IF ((*copya_iter)->id () != (*copytest_iter)->id ()); + } + + /// Testing - using ostream_iterator + + std::ostringstream ostream; + std::copy (a.rbegin (), + a.rend (), + std::ostream_iterator<tested_sequence::value_type> (ostream, + "\n")); + + FAIL_RETURN_IF ( + ostream.str ().compare ("elem3\nelem2\nelem1\nelem0\n") != 0); + + return 0; +} + +//----------------------------------------------------------------------------- + +template <typename REVERSE_ITERATOR_T> +int test_const_sequence_reverse () +{ + // setup of an example sequence + tested_sequence setup; + setup.length (4); + + mock_reference* elem0 = mock_reference::allocate (0); + mock_reference* elem1 = mock_reference::allocate (1); + mock_reference* elem2 = mock_reference::allocate (2); + mock_reference* elem3 = mock_reference::allocate (3); + + // setup of an example sequence + setup[0] = mock_reference::_duplicate (elem0); + setup[1] = mock_reference::_duplicate (elem1); + setup[2] = mock_reference::_duplicate (elem2); + setup[3] = mock_reference::_duplicate (elem3); + + const tested_sequence a = setup; + + // test equality operator + FAIL_RETURN_IF (!(a.begin () == a.begin ())); + + // test non-equality operator + FAIL_RETURN_IF (a.end () != a.end ()); + + // test iterator copy constructor + REVERSE_ITERATOR_T a_it (a.rbegin ()); + FAIL_RETURN_IF (a_it != a.rbegin ()); + + // test assignment operator + a_it = a.rbegin (); + FAIL_RETURN_IF (a_it != a.rbegin ()); + + // test non const dereferencing + mock_reference* value0 = *a_it; + FAIL_RETURN_IF (value0->id () != elem3->id ()); + + // test const dereferencing + const mock_reference* const value1 = *a_it; + FAIL_RETURN_IF (value1->id () != elem3->id ()); + + // test increment operation + a_it++; + FAIL_RETURN_IF (a_it == a.rbegin()); + FAIL_RETURN_IF ((*a_it)->id () != elem2->id ()); + + // test < operator + FAIL_RETURN_IF (!(a.rbegin () < a_it)); + FAIL_RETURN_IF (a_it < a.rbegin ()); + + // test difference type + int a_diff = a_it - a.rbegin (); + FAIL_RETURN_IF (a_diff != 1); + + // test copy constructor + REVERSE_ITERATOR_T a_it1 (a_it); + FAIL_RETURN_IF (a_it1 != a_it); + + // test preincrement operator + ++a_it1; + FAIL_RETURN_IF ((a_it1 - a_it) != 1); + + // test = and += operator + REVERSE_ITERATOR_T a_it2 = a_it += 3; + FAIL_RETURN_IF (a_it2 != a_it); + FAIL_RETURN_IF ((a_it - a_it1) != 2); + + // test + operator + a_it2 = a_it1 + 3; + FAIL_RETURN_IF ((a_it2 - a_it1) != 3); + + // test post-decrement operation + a_it = a.rend (); + a_it--; + FAIL_RETURN_IF (a_it == a.rend ()); + FAIL_RETURN_IF ((a.rend () - a_it) != 1); + FAIL_RETURN_IF ((*a_it)->id () != elem0->id ()); + + // test pre-decrement operator + a_it = a.rend (); + --a_it; + FAIL_RETURN_IF (a_it == a.rend ()); + FAIL_RETURN_IF ((a.rend () - a_it) != 1); + FAIL_RETURN_IF ((*a_it)->id () != elem0->id ()); + + // test -= operator + a_it -= 3; + FAIL_RETURN_IF ((a_it1 - a_it) != 2); + + // test - operator + a_it2 = a_it1 - 2; + FAIL_RETURN_IF ((a_it1 - a_it2) != 2); + + // test operator[] read + a_it = a.rbegin (); + FAIL_RETURN_IF ((a_it[0])->id () != a[3]->id ()); + a_it += 2; + FAIL_RETURN_IF ((a_it[0])->id () != a[1]->id ()); + + // test operator[] write + // NOTE: This now changes the sequence a. + // this is not possible for const iterators + // a_it[0] = CORBA::string_dup (elem0_cstr); + // FAIL_RETURN_IF (ACE_OS::strcmp (a[1],elem0_cstr) != 0); + + // reset content of sequence a + //a[1] = CORBA::string_dup (elem1_cstr); + + // test for loop behaviour + tested_sequence b = a; + REVERSE_ITERATOR_T b_it = b.rbegin (); + + for (a_it = a.rbegin (); + a_it != a.rend (); + a_it++, b_it++) + { + FAIL_RETURN_IF ((*a_it)->id () != (*b_it)->id ()); + } + + tested_sequence test; + test.length (a.length ()); + + // Memory is leaked here from + // TAO::details::string_traits_base<char>::default_initializer() + + std::copy (a.begin (), + a.end (), + test.begin ()); + + FAIL_RETURN_IF (test.length () != a.length ()); + + REVERSE_ITERATOR_T copytest_iter = test.rbegin (); + for (REVERSE_ITERATOR_T copya_iter = a.rbegin (); + copya_iter != a.rend (); + ++copya_iter, ++copytest_iter) + { + FAIL_RETURN_IF ((*copya_iter)->id () != (*copytest_iter)->id ()); + } + + /// Testing - using ostream_iterator + + std::ostringstream ostream; + std::copy (a.rbegin (), + a.rend (), + std::ostream_iterator<tested_sequence::value_type> (ostream, + "\n")); + + FAIL_RETURN_IF ( + ostream.str ().compare ("elem3\nelem2\nelem1\nelem0\n") != 0); + + return 0; +} + +//----------------------------------------------------------------------------- + int main(int,char*[]) { int status = 0; @@ -181,5 +637,20 @@ int main(int,char*[]) // Test Generic_Sequence_Iterator. status += test_sequence< tested_sequence::iterator> (); + // Test Const_Generic_Sequence_Iterator with non-const sequence. + status += test_sequence< tested_sequence::const_iterator> (); + + // Test Const_Generic_Sequence_Iterator with const sequence. + status += test_const_sequence< tested_sequence::const_iterator> (); + + // Test Generic_Sequence_Reverse_Iterator. + status += test_sequence_reverse< tested_sequence::reverse_iterator> (); + + // Test Const_Generic_Sequence_Reverse_Iterator with non-const sequence. + status += test_sequence_reverse< tested_sequence::const_reverse_iterator> (); + + // Test Const_Generic_Sequence_Reverse_Iterator with const sequence. + status += test_const_sequence_reverse< tested_sequence::const_reverse_iterator> (); + return status; } diff --git a/TAO/tests/Sequence_Iterators/run_test.pl b/TAO/tests/Sequence_Iterators/run_test.pl index 6dc14ab3f2c..e0c7ed6afcb 100755 --- a/TAO/tests/Sequence_Iterators/run_test.pl +++ b/TAO/tests/Sequence_Iterators/run_test.pl @@ -19,36 +19,13 @@ if ($ARGV[0] =~ /^-h/i || $ARGV[0] =~ /^-\?/i) { my $final_result = 0; -my @tests = qw( -# unbounded_value_sequence_ut -# unbounded_array_sequence_ut -# bounded_value_sequence_ut -# string_sequence_element_ut -# unbounded_string_sequence_ut -# bounded_string_sequence_ut -# testing_allocation_traits_ut -# unbounded_octet_sequence_ut -# unbounded_octet_sequence_no_copy_ut -# object_reference_sequence_element_ut -# unbounded_object_reference_sequence_ut -# unbounded_fwd_object_reference_sequence_ut -# bounded_object_reference_sequence_ut -# bounded_sequence_cdr_ut -# unbounded_sequence_cdr_ut - ); - -my @testsNoBoost = qw( +my @testsToRun = qw( StringSeq Bounded_String + Unbounded_Value Unbounded_Objectref ); -my @testsToRun = qw(); - -push(@testsToRun, @tests) if ($#ARGV < 0 || $ARGV[0] eq '-boost'); -push(@testsToRun, @testsNoBoost) if ($#ARGV < 0 || $ARGV[0] eq '-noboost'); - - foreach my $process (@testsToRun) { my $P = 0; |