summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcoryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2004-09-23 00:34:09 +0000
committercoryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2004-09-23 00:34:09 +0000
commitb2ec06f183555051ffca4eff2ac17aa8866b7281 (patch)
treeabc63aa2dfebd038c75d19783120260a27771716
parent3365983bcb8be576305b1f2465c6c99b4a1990a3 (diff)
downloadATCD-b2ec06f183555051ffca4eff2ac17aa8866b7281.tar.gz
Wed Sep 22 20:25:12 2004 Carlos O'Ryan <coryan@atdesk.com>
-rw-r--r--TAO/ChangeLog26
-rw-r--r--TAO/tests/Sequence_Unit_Tests/Sequence_Unit_Tests.mpc8
-rwxr-xr-xTAO/tests/Sequence_Unit_Tests/run_test.pl2
-rw-r--r--TAO/tests/Sequence_Unit_Tests/string_sequence_element.hpp116
-rw-r--r--TAO/tests/Sequence_Unit_Tests/string_sequence_element_ut.cpp384
-rw-r--r--TAO/tests/Sequence_Unit_Tests/string_traits_base.hpp1
-rw-r--r--TAO/tests/Sequence_Unit_Tests/unbounded_string_sequence.hpp8
-rw-r--r--TAO/tests/Sequence_Unit_Tests/unbounded_string_sequence_ut.cpp96
8 files changed, 617 insertions, 24 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog
index c723737e2fb..d5d29df02f2 100644
--- a/TAO/ChangeLog
+++ b/TAO/ChangeLog
@@ -1,3 +1,29 @@
+Wed Sep 22 20:25:12 2004 Carlos O'Ryan <coryan@atdesk.com>
+
+ * tests/Sequence_Unit_Tests/string_sequence_element.hpp:
+ Implement the type returned by the non-const operator[] in
+ string sequences. A lot of the evilness of string sequences is
+ encapsulated here.
+
+ * tests/Sequence_Unit_Tests/run_test.pl:
+ * tests/Sequence_Unit_Tests/Sequence_Unit_Tests.mpc:
+ * tests/Sequence_Unit_Tests/string_sequence_element_ut.cpp:
+ Unit test for the previous class.
+
+ * tests/Sequence_Unit_Tests/string_traits_base.hpp:
+ Add missing #include for the string manager types.
+
+ * tests/Sequence_Unit_Tests/unbounded_string_sequence.hpp:
+ Implement the non-const operator[] to return a
+ string_sequence_element<charT>.
+
+ * tests/Sequence_Unit_Tests/run_test.pl:
+ * tests/Sequence_Unit_Tests/unbounded_string_sequence_ut.cpp:
+ Add more tests for copy constructors.
+ Test the non-cost operator[] for sequences.
+ Move the add_all() function to the end, easier to add tests that
+ way.
+
Tue Sep 21 22:11:10 2004 Carlos O'Ryan <coryan@atdesk.com>
* tests/Sequence_Unit_Tests/unbounded_string_sequence.hpp:
diff --git a/TAO/tests/Sequence_Unit_Tests/Sequence_Unit_Tests.mpc b/TAO/tests/Sequence_Unit_Tests/Sequence_Unit_Tests.mpc
index 875a71500c5..e97b94f1447 100644
--- a/TAO/tests/Sequence_Unit_Tests/Sequence_Unit_Tests.mpc
+++ b/TAO/tests/Sequence_Unit_Tests/Sequence_Unit_Tests.mpc
@@ -13,8 +13,14 @@ project(*Bounded_Simple_Types) : taoexe {
}
}
+project(*String_Sequence_Element): taoexe, boost_unit_test {
+ Source_Files {
+ string_sequence_element_ut.cpp
+ }
+}
+
project(*Unbounded_String_Sequence): taoexe, boost_unit_test {
- Source_Files {
+ Source_Files {
unbounded_string_sequence_ut.cpp
}
}
diff --git a/TAO/tests/Sequence_Unit_Tests/run_test.pl b/TAO/tests/Sequence_Unit_Tests/run_test.pl
index 5baaa6899cd..ec036b2c7fa 100755
--- a/TAO/tests/Sequence_Unit_Tests/run_test.pl
+++ b/TAO/tests/Sequence_Unit_Tests/run_test.pl
@@ -13,6 +13,8 @@ my $final_result = 0;
foreach my $process (qw(unbounded_value_sequence_ut
bounded_value_sequence_ut
+ string_sequence_element_ut
+ unbounded_string_sequence_ut
Unbounded_Simple_Types
Bounded_Simple_Types)) {
diff --git a/TAO/tests/Sequence_Unit_Tests/string_sequence_element.hpp b/TAO/tests/Sequence_Unit_Tests/string_sequence_element.hpp
new file mode 100644
index 00000000000..793ca5df9e4
--- /dev/null
+++ b/TAO/tests/Sequence_Unit_Tests/string_sequence_element.hpp
@@ -0,0 +1,116 @@
+#ifndef guard_string_sequence_element_hpp
+#define guard_string_sequence_element_hpp
+/**
+ * @file
+ *
+ * @brief Implement the type returned by operator[] in string
+ * sequences.
+ *
+ * $Id$
+ *
+ * @author Carlos O'Ryan
+ */
+
+#include "string_traits.hpp"
+
+namespace TAO
+{
+namespace details
+{
+
+template<typename charT>
+class string_sequence_element
+{
+public:
+ typedef charT character_type;
+ typedef charT * value_type;
+ typedef charT const * const_value_type;
+ typedef details::string_traits<charT,true> string_traits;
+ typedef typename string_traits::string_var string_var;
+ typedef typename string_traits::string_mgr string_mgr;
+
+ string_sequence_element(
+ value_type & e, CORBA::Boolean release)
+ : element_(&e)
+ , release_(release)
+ {
+ }
+
+ string_sequence_element(
+ string_sequence_element const & rhs)
+ : element_(rhs.element_)
+ , release_(rhs.release_)
+ {
+ }
+
+ ~string_sequence_element()
+ {
+ }
+
+ string_sequence_element & operator=(charT const * rhs)
+ {
+ if (release())
+ {
+ value_type tmp = string_traits::duplicate(rhs);
+ string_traits::release(*element_);
+ *element_ = tmp;
+ return *this;
+ }
+ string_traits::not_released_from_const(*element_, rhs);
+ return *this;
+ }
+
+ string_sequence_element & operator=(charT * rhs)
+ {
+ if (release())
+ {
+ string_traits::release(*element_);
+ }
+ *element_ = rhs;
+ return *this;
+ }
+
+ string_sequence_element & operator=(string_sequence_element const & rhs)
+ {
+ return operator=(const_value_type(rhs));
+ }
+
+ string_sequence_element & operator=(string_var const & rhs)
+ {
+ return operator=(rhs.in());
+ }
+
+ string_sequence_element & operator=(string_mgr const & rhs)
+ {
+ return operator=(rhs.in());
+ }
+
+ inline operator const_value_type() const
+ {
+ return *element_;
+ }
+
+ void swap(string_sequence_element & rhs)
+ {
+ std::swap(element_, rhs.element_);
+ std::swap(release_, rhs.release_);
+ }
+
+ CORBA::Boolean release() const
+ {
+ return release_;
+ }
+
+private:
+ // This function is not implemented
+ string_sequence_element();
+
+private:
+ value_type * element_;
+ CORBA::Boolean release_;
+};
+
+} // namespace details
+} // namespace CORBA
+
+#endif // guard_string_sequence_element_hpp
diff --git a/TAO/tests/Sequence_Unit_Tests/string_sequence_element_ut.cpp b/TAO/tests/Sequence_Unit_Tests/string_sequence_element_ut.cpp
new file mode 100644
index 00000000000..2607313cd2e
--- /dev/null
+++ b/TAO/tests/Sequence_Unit_Tests/string_sequence_element_ut.cpp
@@ -0,0 +1,384 @@
+/**
+ * @file
+ *
+ * @brief Unit test for string_sequence_element, this is the type
+ * returned by operator[] from a string sequence.
+ *
+ * $Id$
+ *
+ * @author Carlos O'Ryan
+ */
+#include "testing_string_traits.hpp"
+#include "string_sequence_element.hpp"
+
+#include "ace/OS_NS_string.h"
+
+#include <sstream>
+#include <stdexcept>
+#include <iostream>
+
+#include <boost/test/unit_test.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/enable_shared_from_this.hpp>
+
+using namespace TAO::details;
+
+using namespace boost::unit_test_framework;
+
+template<typename charT>
+struct helper {};
+
+template<>
+struct helper<char>
+{
+ static char const * empty() {
+ return "";
+ }
+ static char const * sample0() {
+ return "Hello";
+ }
+ static char const * sample1() {
+ return "World";
+ }
+ static bool equal(char const * lhs, char const * rhs) {
+ return ACE_OS::strcmp(lhs, rhs) == 0;
+ }
+};
+
+template<>
+struct helper<CORBA::WChar>
+{
+ static CORBA::WChar const * empty() {
+ return L"";
+ }
+ static CORBA::WChar const * sample0() {
+ return L"Hello";
+ }
+ static CORBA::WChar const * sample1() {
+ return L"World";
+ }
+ static bool equal(CORBA::WChar const * lhs, CORBA::WChar const * rhs) {
+ return ACE_OS::strcmp(lhs, rhs) == 0;
+ }
+};
+
+template<class charT>
+struct Tester : public boost::enable_shared_from_this<Tester<charT> >
+{
+ typedef string_traits<charT,true> tested_element_traits;
+ typedef string_sequence_element<charT> tested_element;
+ typedef charT * string_type;
+ typedef typename tested_element_traits::string_var string_var;
+ typedef typename tested_element_traits::string_mgr string_mgr;
+
+ void test_assignment_from_const_string()
+ {
+ expected_calls d(tested_element_traits::duplicate_calls);
+ expected_calls r(tested_element_traits::release_calls);
+
+ {
+ string_type xe = 0;
+ tested_element x(xe, true);
+ BOOST_CHECK_MESSAGE(d.expect(0), d);
+ BOOST_CHECK_MESSAGE(r.expect(0), r);
+ x = helper<charT>::sample0();
+
+ BOOST_CHECK_MESSAGE(d.expect(1), d);
+ BOOST_CHECK_MESSAGE(r.expect(1), r);
+
+ BOOST_CHECK_MESSAGE(
+ helper<charT>::equal(helper<charT>::sample0(), xe),
+ "Mismatch after assignment from const. expected="
+ << helper<charT>::sample0()
+ << ", got=" << x);
+ tested_element_traits::release(xe);
+ BOOST_CHECK_MESSAGE(r.expect(1), r);
+ }
+ BOOST_CHECK_MESSAGE(d.expect(0), d);
+ BOOST_CHECK_MESSAGE(r.expect(0), r);
+ }
+
+ void test_assignment_from_element()
+ {
+ expected_calls d(tested_element_traits::duplicate_calls);
+ expected_calls r(tested_element_traits::release_calls);
+ {
+ string_type xe = 0;
+
+ tested_element x(xe, true);
+ x = helper<charT>::sample0();
+
+ string_type ye = 0;
+
+ tested_element y(xe, true);
+ y = helper<charT>::sample1();
+
+ d.reset(); r.reset();
+
+ x = y;
+
+ BOOST_CHECK_MESSAGE(d.expect(1), d);
+ BOOST_CHECK_MESSAGE(r.expect(1), r);
+
+ BOOST_CHECK_MESSAGE(
+ helper<charT>::equal(helper<charT>::sample1(), x),
+ "Mismatch after assignment from element. expected="
+ << helper<charT>::sample1()
+ << ", got=" << x);
+
+ tested_element_traits::release(xe);
+ tested_element_traits::release(ye);
+ BOOST_CHECK_MESSAGE(r.expect(2), r);
+ }
+ BOOST_CHECK_MESSAGE(d.expect(0), d);
+ BOOST_CHECK_MESSAGE(r.expect(0), r);
+ }
+
+ void test_self_assignment()
+ {
+ expected_calls d(tested_element_traits::duplicate_calls);
+ expected_calls r(tested_element_traits::release_calls);
+ {
+ string_type xe = 0;
+
+ tested_element x(xe, true);
+ x = helper<charT>::sample0();
+
+ d.reset(); r.reset();
+
+ x = x;
+
+ BOOST_CHECK_MESSAGE(d.expect(1), d);
+ BOOST_CHECK_MESSAGE(r.expect(1), r);
+
+ BOOST_CHECK_MESSAGE(
+ helper<charT>::equal(helper<charT>::sample0(), x),
+ "Mismatch after self assignment. expected="
+ << helper<charT>::sample1()
+ << ", got=" << x);
+
+ tested_element_traits::release(xe);
+ BOOST_CHECK_MESSAGE(r.expect(1), r);
+ }
+ BOOST_CHECK_MESSAGE(d.expect(0), d);
+ BOOST_CHECK_MESSAGE(r.expect(0), r);
+ }
+
+ void test_assignment_from_non_const_string()
+ {
+ expected_calls d(tested_element_traits::duplicate_calls);
+ expected_calls r(tested_element_traits::release_calls);
+
+ {
+ string_type xe = 0;
+ tested_element x(xe, true);
+
+ string_type y =
+ tested_element_traits::duplicate(helper<charT>::sample0());
+ BOOST_CHECK_MESSAGE(d.expect(1), d);
+ BOOST_CHECK_MESSAGE(r.expect(0), r);
+
+ x = y;
+
+ BOOST_CHECK_MESSAGE(d.expect(0), d);
+ BOOST_CHECK_MESSAGE(r.expect(1), r);
+
+ BOOST_CHECK_MESSAGE(
+ helper<charT>::equal(helper<charT>::sample0(), xe),
+ "Mismatch after assignment from non-const. expected="
+ << helper<charT>::sample0()
+ << ", got=" << x);
+ tested_element_traits::release(xe);
+ BOOST_CHECK_MESSAGE(r.expect(1), r);
+ }
+ BOOST_CHECK_MESSAGE(d.expect(0), d);
+ BOOST_CHECK_MESSAGE(r.expect(0), r);
+ }
+
+ void test_copy_constructor()
+ {
+ expected_calls d(tested_element_traits::duplicate_calls);
+ expected_calls r(tested_element_traits::release_calls);
+
+ {
+ string_type xe =
+ tested_element_traits::duplicate(helper<charT>::sample0());
+ tested_element x(xe, true);
+
+ d.reset(); r.reset();
+
+ tested_element y(x);
+
+ BOOST_CHECK_MESSAGE(d.expect(0), d);
+ BOOST_CHECK_MESSAGE(r.expect(0), r);
+
+ BOOST_CHECK_MESSAGE(
+ helper<charT>::equal(helper<charT>::sample0(), y),
+ "Mismatch after copy constructor. expected="
+ << helper<charT>::sample0()
+ << ", got=" << y);
+
+ tested_element_traits::release(xe);
+ BOOST_CHECK_MESSAGE(r.expect(1), r);
+ }
+ BOOST_CHECK_MESSAGE(d.expect(0), d);
+ BOOST_CHECK_MESSAGE(r.expect(0), r);
+ }
+
+ void test_assignment_from_copy()
+ {
+ expected_calls d(tested_element_traits::duplicate_calls);
+ expected_calls r(tested_element_traits::release_calls);
+
+ {
+ string_type xe =
+ tested_element_traits::duplicate(helper<charT>::sample0());
+ tested_element x(xe, true);
+
+ d.reset(); r.reset();
+
+ tested_element y(x);
+
+ BOOST_CHECK_MESSAGE(d.expect(0), d);
+ BOOST_CHECK_MESSAGE(r.expect(0), r);
+
+ x = y;
+
+ BOOST_CHECK_MESSAGE(d.expect(1), d);
+ BOOST_CHECK_MESSAGE(r.expect(1), r);
+
+ BOOST_CHECK_MESSAGE(
+ helper<charT>::equal(helper<charT>::sample0(), xe),
+ "Mismatch after assignment. expected="
+ << helper<charT>::sample0()
+ << ", got=" << xe);
+
+ BOOST_CHECK_MESSAGE(
+ helper<charT>::equal(helper<charT>::sample0(), y),
+ "Mismatch after assignment. expected="
+ << helper<charT>::sample0()
+ << ", got=" << y);
+
+ tested_element_traits::release(xe);
+ BOOST_CHECK_MESSAGE(r.expect(1), r);
+ }
+ BOOST_CHECK_MESSAGE(d.expect(0), d);
+ BOOST_CHECK_MESSAGE(r.expect(0), r);
+ }
+
+ void test_assignment_from_var()
+ {
+ expected_calls d(tested_element_traits::duplicate_calls);
+ expected_calls r(tested_element_traits::release_calls);
+
+ {
+ string_type xe = 0;
+ tested_element x(xe, true);
+
+ string_var y(helper<charT>::sample0());
+
+ BOOST_CHECK_MESSAGE(d.expect(0), d);
+ BOOST_CHECK_MESSAGE(r.expect(0), r);
+
+ x = y;
+
+ BOOST_CHECK_MESSAGE(d.expect(1), d);
+ BOOST_CHECK_MESSAGE(r.expect(1), r);
+
+ BOOST_CHECK_MESSAGE(
+ helper<charT>::equal(helper<charT>::sample0(), xe),
+ "Mismatch after assignment from var. expected="
+ << helper<charT>::sample0()
+ << ", got=" << x);
+
+ tested_element_traits::release(xe);
+ BOOST_CHECK_MESSAGE(r.expect(1), r);
+ }
+ BOOST_CHECK_MESSAGE(d.expect(0), d);
+ BOOST_CHECK_MESSAGE(r.expect(0), r);
+ }
+
+ void test_assignment_from_mgr()
+ {
+ expected_calls d(tested_element_traits::duplicate_calls);
+ expected_calls r(tested_element_traits::release_calls);
+
+ {
+ string_type xe = 0;
+ tested_element x(xe, true);
+
+ string_mgr y;
+ y = helper<charT>::sample0();
+
+ BOOST_CHECK_MESSAGE(d.expect(0), d);
+ BOOST_CHECK_MESSAGE(r.expect(0), r);
+
+ x = y;
+
+ BOOST_CHECK_MESSAGE(d.expect(1), d);
+ BOOST_CHECK_MESSAGE(r.expect(1), r);
+
+ BOOST_CHECK_MESSAGE(
+ helper<charT>::equal(helper<charT>::sample0(), xe),
+ "Mismatch after assignment from mgr. expected="
+ << helper<charT>::sample0()
+ << ", got=" << x);
+
+ tested_element_traits::release(xe);
+ BOOST_CHECK_MESSAGE(r.expect(1), r);
+ }
+ BOOST_CHECK_MESSAGE(d.expect(0), d);
+ BOOST_CHECK_MESSAGE(r.expect(0), r);
+ }
+
+ void add_all(test_suite * ts)
+ {
+ ts->add(BOOST_CLASS_TEST_CASE(
+ &Tester::test_assignment_from_const_string,
+ shared_from_this()));
+ ts->add(BOOST_CLASS_TEST_CASE(
+ &Tester::test_assignment_from_element,
+ shared_from_this()));
+ ts->add(BOOST_CLASS_TEST_CASE(
+ &Tester::test_self_assignment,
+ shared_from_this()));
+ ts->add(BOOST_CLASS_TEST_CASE(
+ &Tester::test_assignment_from_non_const_string,
+ shared_from_this()));
+ ts->add(BOOST_CLASS_TEST_CASE(
+ &Tester::test_copy_constructor,
+ shared_from_this()));
+ ts->add(BOOST_CLASS_TEST_CASE(
+ &Tester::test_assignment_from_copy,
+ shared_from_this()));
+ ts->add(BOOST_CLASS_TEST_CASE(
+ &Tester::test_assignment_from_var,
+ shared_from_this()));
+ ts->add(BOOST_CLASS_TEST_CASE(
+ &Tester::test_assignment_from_mgr,
+ shared_from_this()));
+ }
+};
+
+test_suite *
+init_unit_test_suite(int, char*[])
+{
+ std::auto_ptr<test_suite> ts(
+ BOOST_TEST_SUITE("string sequence element unit test"));
+
+ boost::shared_ptr<Tester<char> > char_tester(
+ new Tester<char>);
+ char_tester->add_all(ts.get());
+
+ boost::shared_ptr<Tester<CORBA::WChar> > wchar_tester(
+ new Tester<CORBA::WChar>);
+ wchar_tester->add_all(ts.get());
+
+ return ts.release();
+}
+
+#if 0
+// This is just to convince MPC that I do not need a main() to have a
+// program.
+int main() {}
+#endif
diff --git a/TAO/tests/Sequence_Unit_Tests/string_traits_base.hpp b/TAO/tests/Sequence_Unit_Tests/string_traits_base.hpp
index 6c2cc41cfd8..7d1a14dbb29 100644
--- a/TAO/tests/Sequence_Unit_Tests/string_traits_base.hpp
+++ b/TAO/tests/Sequence_Unit_Tests/string_traits_base.hpp
@@ -12,6 +12,7 @@
*/
#include "tao/CORBA_String.h"
+#include "tao/Managed_Types.h"
namespace TAO
{
diff --git a/TAO/tests/Sequence_Unit_Tests/unbounded_string_sequence.hpp b/TAO/tests/Sequence_Unit_Tests/unbounded_string_sequence.hpp
index 8784b48cbb2..fbc7297ad64 100644
--- a/TAO/tests/Sequence_Unit_Tests/unbounded_string_sequence.hpp
+++ b/TAO/tests/Sequence_Unit_Tests/unbounded_string_sequence.hpp
@@ -13,6 +13,7 @@
#include "allocation_traits.hpp"
#include "string_traits.hpp"
#include "generic_sequence.hpp"
+#include "string_sequence_element.hpp"
namespace TAO
{
@@ -23,6 +24,7 @@ public:
typedef char * value_type;
typedef details::unbounded_allocation_traits<char*,true> allocation_traits;
typedef details::string_traits<char,true> element_traits;
+ typedef details::string_sequence_element<char> element_type;
typedef details::generic_sequence<char*, allocation_traits, element_traits> implementation_type;
@@ -58,10 +60,10 @@ public:
inline char const * operator[](CORBA::ULong i) const {
return impl_[i];
}
-#if 0
- inline value_type & operator[](CORBA::ULong i) {
- return impl_[i];
+ inline element_type operator[](CORBA::ULong i) {
+ return element_type(impl_[i], release());
}
+#if 0
inline void replace(
CORBA::ULong maximum,
CORBA::ULong length,
diff --git a/TAO/tests/Sequence_Unit_Tests/unbounded_string_sequence_ut.cpp b/TAO/tests/Sequence_Unit_Tests/unbounded_string_sequence_ut.cpp
index 3210a4ad5e9..78fce1590d9 100644
--- a/TAO/tests/Sequence_Unit_Tests/unbounded_string_sequence_ut.cpp
+++ b/TAO/tests/Sequence_Unit_Tests/unbounded_string_sequence_ut.cpp
@@ -30,25 +30,6 @@ struct Tester
typedef TAO::unbounded_string_sequence tested_sequence;
- void add_all(test_suite * ts)
- {
- ts->add(BOOST_CLASS_TEST_CASE(
- &Tester::test_default_constructor, shared_from_this()));
- ts->add(BOOST_CLASS_TEST_CASE(
- &Tester::test_ulong_constructor, shared_from_this()));
- ts->add(BOOST_CLASS_TEST_CASE(
- &Tester::test_copy_constructor, shared_from_this()));
- ts->add(BOOST_CLASS_TEST_CASE(
- &Tester::test_set_length_less_than_maximum,
- shared_from_this()));
- ts->add(BOOST_CLASS_TEST_CASE(
- &Tester::test_set_length_more_than_maximum,
- shared_from_this()));
- ts->add(BOOST_CLASS_TEST_CASE(
- &Tester::test_index_accessor,
- shared_from_this()));
- }
-
/**
* @brief Make sure the default constructor works as expected.
*/
@@ -84,7 +65,33 @@ struct Tester
BOOST_CHECK_MESSAGE(i.expect(0), i);
}
- void test_copy_constructor()
+ void test_copy_constructor_from_default()
+ {
+ expected_calls a(tested_allocation_traits::allocbuf_calls);
+ expected_calls f(tested_allocation_traits::freebuf_calls);
+ expected_calls i(tested_element_traits::default_initializer_calls);
+ expected_calls d(tested_element_traits::duplicate_calls);
+ {
+ tested_sequence x;
+ BOOST_CHECK_MESSAGE(a.expect(0), a);
+ BOOST_CHECK_MESSAGE(i.expect(0), i);
+
+ BOOST_CHECK_EQUAL(CORBA::ULong(0), x.maximum());
+ BOOST_CHECK_EQUAL(CORBA::ULong(0), x.length());
+ BOOST_CHECK_EQUAL(true, x.release());
+
+ tested_sequence y(x);
+ BOOST_CHECK_MESSAGE(a.expect(1), a);
+ BOOST_CHECK_MESSAGE(i.expect(0), i);
+
+ BOOST_CHECK_EQUAL(CORBA::ULong(0), y.maximum());
+ BOOST_CHECK_EQUAL(CORBA::ULong(0), y.length());
+ BOOST_CHECK_EQUAL(true, y.release());
+ }
+ BOOST_CHECK_MESSAGE(f.expect(2), f);
+ }
+
+ void test_copy_constructor_from_ulong()
{
expected_calls a(tested_allocation_traits::allocbuf_calls);
expected_calls f(tested_allocation_traits::freebuf_calls);
@@ -165,6 +172,55 @@ struct Tester
BOOST_CHECK_MESSAGE(std::strcmp(t, "") == 0,
"Unexpected string value " << t);
}
+
+ void test_index_modifier()
+ {
+ tested_sequence x(16);
+ x.length(8);
+
+ tested_sequence const & y = x;
+
+ char const * text = "text";
+ expected_calls d(tested_element_traits::duplicate_calls);
+ x[4] = text;
+ BOOST_CHECK_MESSAGE(d.expect(1), d);
+
+ char const * t = y[4];
+
+ BOOST_CHECK_MESSAGE(std::strcmp(text, x[4]) == 0,
+ "Mismatched values expected=" << text
+ << ", got=" << x[4]);
+ BOOST_CHECK_MESSAGE(std::strcmp(text, y[4]) == 0,
+ "Mismatched values expected=" << text
+ << ", got=" << y[4]);
+ BOOST_CHECK(text != t);
+ }
+
+ void add_all(test_suite * ts)
+ {
+ ts->add(BOOST_CLASS_TEST_CASE(
+ &Tester::test_default_constructor,
+ shared_from_this()));
+ ts->add(BOOST_CLASS_TEST_CASE(
+ &Tester::test_ulong_constructor,
+ shared_from_this()));
+ ts->add(BOOST_CLASS_TEST_CASE(
+ &Tester::test_copy_constructor_from_default,
+ shared_from_this()));
+ ts->add(BOOST_CLASS_TEST_CASE(
+ &Tester::test_copy_constructor_from_ulong,
+ shared_from_this()));
+ ts->add(BOOST_CLASS_TEST_CASE(
+ &Tester::test_set_length_less_than_maximum,
+ shared_from_this()));
+ ts->add(BOOST_CLASS_TEST_CASE(
+ &Tester::test_set_length_more_than_maximum,
+ shared_from_this()));
+ ts->add(BOOST_CLASS_TEST_CASE(
+ &Tester::test_index_accessor,
+ shared_from_this()));
+ }
+
};
test_suite *