diff options
Diffstat (limited to 'TAO/tests/Sequence_Unit_Tests/unbounded_fwd_object_reference_sequence_ut.cpp')
-rw-r--r-- | TAO/tests/Sequence_Unit_Tests/unbounded_fwd_object_reference_sequence_ut.cpp | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/TAO/tests/Sequence_Unit_Tests/unbounded_fwd_object_reference_sequence_ut.cpp b/TAO/tests/Sequence_Unit_Tests/unbounded_fwd_object_reference_sequence_ut.cpp new file mode 100644 index 00000000000..e8f829b732d --- /dev/null +++ b/TAO/tests/Sequence_Unit_Tests/unbounded_fwd_object_reference_sequence_ut.cpp @@ -0,0 +1,86 @@ +/** + * @file + * + * @brief Unit test for unbounded sequences of forward declared object + * references. + * + * $Id$ + * + * @author Johnny Willemsen <jwillemsen@remedy.nl> + */ +#include "testing_object_reference_traits.hpp" +#include "testing_allocation_traits.hpp" +#include "testing_range_checking.hpp" + +#include "fwd_mock_reference.hpp" + +#include "tao/Unbounded_Object_Reference_Sequence_T.h" + +#include <boost/test/unit_test.hpp> +#include <boost/shared_ptr.hpp> +#include <boost/weak_ptr.hpp> + +using namespace boost::unit_test_framework; +using namespace TAO_VERSIONED_NAMESPACE_NAME::TAO; + +struct Tester +{ + typedef unbounded_object_reference_sequence<fwd_mock_reference, fwd_mock_reference_var> tested_sequence; + typedef tested_sequence::value_type value_type; + typedef tested_sequence::const_value_type const_value_type; + + typedef tested_sequence::element_traits tested_element_traits; + typedef tested_sequence::allocation_traits tested_allocation_traits; + typedef TAO::details::range_checking<value_type,true> range; + + void test_default_constructor() + { + 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); + { + tested_sequence x; + + BOOST_CHECK_EQUAL(CORBA::ULong(0), x.maximum()); + BOOST_CHECK_EQUAL(CORBA::ULong(0), x.length()); + BOOST_CHECK_EQUAL(true, x.release()); + } + BOOST_CHECK_MESSAGE(a.expect(0), a); + BOOST_CHECK_MESSAGE(f.expect(1), f); + BOOST_CHECK_MESSAGE(i.expect(0), i); + } + + void add_all(test_suite * ts) + { + boost::shared_ptr<Tester> shared_this(self_); + ts->add(BOOST_CLASS_TEST_CASE( + &Tester::test_default_constructor, + shared_this)); + } + + static boost::shared_ptr<Tester> allocate() + { + boost::shared_ptr<Tester> ptr(new Tester); + ptr->self_ = ptr; + + return ptr; + } + +private: + Tester() {} + + boost::weak_ptr<Tester> self_; +}; + +ACE_Proper_Export_Flag test_suite * +init_unit_test_suite(int, char*[]) +{ + test_suite * ts = + BOOST_TEST_SUITE("unbounded object reference sequence unit test"); + + boost::shared_ptr<Tester> tester(Tester::allocate()); + tester->add_all(ts); + + return ts; +} + |