diff options
Diffstat (limited to 'TAO/tests/Sequence_Unit_Tests/testing_allocation_traits_ut.cpp')
-rw-r--r-- | TAO/tests/Sequence_Unit_Tests/testing_allocation_traits_ut.cpp | 142 |
1 files changed, 56 insertions, 86 deletions
diff --git a/TAO/tests/Sequence_Unit_Tests/testing_allocation_traits_ut.cpp b/TAO/tests/Sequence_Unit_Tests/testing_allocation_traits_ut.cpp index de4426c4f16..ae7445e53b4 100644 --- a/TAO/tests/Sequence_Unit_Tests/testing_allocation_traits_ut.cpp +++ b/TAO/tests/Sequence_Unit_Tests/testing_allocation_traits_ut.cpp @@ -8,18 +8,15 @@ * @author Carlos O'Ryan */ #include "testing_allocation_traits.hpp" - -#include <boost/test/unit_test.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/weak_ptr.hpp> +#include "test_macros.h" #define CHECK_NO_THROW(statement) \ try { statement; } catch(...) { \ - BOOST_ERROR("unexpected exception raised"); } + return 1; } using namespace TAO_VERSIONED_NAMESPACE_NAME::TAO::details; -using namespace boost::unit_test_framework; + CORBA::ULong const MAXIMUM = 32; @@ -30,7 +27,7 @@ struct Tester typedef bounded_value_allocation_traits<value_type,MAXIMUM,true> bounded; template<class aspect> - void test_allocbuf() + int test_allocbuf() { expected_calls c(aspect::allocbuf_calls); @@ -38,15 +35,16 @@ struct Tester value_type * s = 0; CHECK_NO_THROW(s = aspect::allocbuf(4)); aspect::freebuf(s); - BOOST_CHECK_THROW(s = aspect::allocbuf(4), testing_exception); + CHECK_THROW(s = aspect::allocbuf(4), testing_exception); CHECK_NO_THROW(s = aspect::allocbuf(4)); aspect::freebuf(s); - BOOST_CHECK_MESSAGE(c.expect(3), c); + FAIL_RETURN_IF_NOT(c.expect(3), c); + return 0; } template<class aspect> - void test_freebuf() + int test_freebuf() { expected_calls c(aspect::freebuf_calls); @@ -54,34 +52,38 @@ struct Tester value_type * s = aspect::allocbuf(4); CHECK_NO_THROW(aspect::freebuf(s)); s = aspect::allocbuf(4); - BOOST_CHECK_THROW(aspect::freebuf(s), testing_exception); + CHECK_THROW(aspect::freebuf(s), testing_exception); aspect::freebuf(s); s = aspect::allocbuf(4); CHECK_NO_THROW(aspect::freebuf(s)); - BOOST_CHECK_MESSAGE(c.expect(4), c); + FAIL_RETURN_IF_NOT(c.expect(4), c); + return 0; } - void test_default_buffer_allocation_value() + int test_default_buffer_allocation_value() { expected_calls u(unbounded::default_buffer_allocation_calls); expected_calls b(bounded::default_buffer_allocation_calls); value_type * s = unbounded::default_buffer_allocation(); - BOOST_CHECK_MESSAGE(u.expect(1), u); - BOOST_CHECK_MESSAGE(b.expect(0), b); - BOOST_CHECK_EQUAL(static_cast<value_type*>(0), s); + FAIL_RETURN_IF_NOT(u.expect(1), u); + FAIL_RETURN_IF_NOT(b.expect(0), b); + CHECK_EQUAL(static_cast<value_type*>(0), s); bounded::freebuf(s); s = bounded::default_buffer_allocation(); - BOOST_CHECK_MESSAGE(u.expect(0), u); - BOOST_CHECK_MESSAGE(b.expect(1), b); - BOOST_CHECK(static_cast<value_type*>(0) != s); + FAIL_RETURN_IF_NOT(u.expect(0), u); + FAIL_RETURN_IF_NOT(b.expect(1), b); + // default_buffer_allocation doesn't allocate a buffer for + // bounded sequences (see bug 3042). + CHECK_EQUAL(static_cast<value_type*>(0), s); bounded::freebuf(s); + return 0; } template<class aspect> - void test_default_buffer_allocation() + int test_default_buffer_allocation() { expected_calls c(aspect::default_buffer_allocation_calls); @@ -90,112 +92,80 @@ struct Tester CHECK_NO_THROW( s = aspect::default_buffer_allocation()); aspect::freebuf(s); - BOOST_CHECK_THROW( + CHECK_THROW( s = aspect::default_buffer_allocation(), testing_exception); CHECK_NO_THROW( s = aspect::default_buffer_allocation()); aspect::freebuf(s); - BOOST_CHECK_MESSAGE(c.expect(3), c); - } - - void test_default_buffer_allocation_unbounded() - { - test_default_buffer_allocation<unbounded>(); + FAIL_RETURN_IF_NOT(c.expect(3), c); + return 0; } - void test_default_buffer_allocation_bounded() + int test_default_buffer_allocation_unbounded() { - test_default_buffer_allocation<bounded>(); + return test_default_buffer_allocation<unbounded>(); } - void test_allocbuf_unbounded() + int test_default_buffer_allocation_bounded() { - test_allocbuf<unbounded>(); + return test_default_buffer_allocation<bounded>(); } - void test_allocbuf_bounded() + int test_allocbuf_unbounded() { - test_allocbuf<bounded>(); + return test_allocbuf<unbounded>(); } - void test_freebuf_unbounded() + int test_allocbuf_bounded() { - test_freebuf<unbounded>(); + return test_allocbuf<bounded>(); } - void test_freebuf_bounded() + int test_freebuf_unbounded() { - test_freebuf<bounded>(); + return test_freebuf<unbounded>(); } - void add_all(test_suite * ts) + int test_freebuf_bounded() { - boost::shared_ptr<Tester> shared_this(self_); - - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_default_buffer_allocation_value, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_default_buffer_allocation_unbounded, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_default_buffer_allocation_bounded, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_allocbuf_unbounded, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_allocbuf_bounded, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_freebuf_unbounded, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_freebuf_bounded, - shared_this)); + return test_freebuf<bounded>(); } - static boost::shared_ptr<Tester> allocate() + int test_all() { - boost::shared_ptr<Tester> ptr(new Tester); - ptr->self_ = ptr; - - return ptr; + int status = 0; + status += this->test_default_buffer_allocation_value(); + status += this->test_default_buffer_allocation_unbounded(); + status += this->test_default_buffer_allocation_bounded(); + status += this->test_allocbuf_unbounded(); + status += this->test_allocbuf_bounded(); + status += this->test_freebuf_unbounded(); + status += this->test_freebuf_bounded(); + return status; } - -private: Tester() {} - - boost::weak_ptr<Tester> self_; }; struct Foo { int y; }; -ACE_Proper_Export_Flag test_suite * -init_unit_test_suite(int, char*[]) +int ACE_TMAIN(int,ACE_TCHAR*[]) { - test_suite * ts = - BOOST_TEST_SUITE("testing allocation traits unit test"); - + int status = 0; { - boost::shared_ptr<Tester<int> > tester( - Tester<int>::allocate()); - tester->add_all(ts); + Tester<int> tester; + status += tester.test_all (); } { - boost::shared_ptr<Tester<Foo> > tester( - Tester<Foo>::allocate()); - tester->add_all(ts); + Tester<Foo> tester; + status += tester.test_all (); } { - boost::shared_ptr<Tester<char*> > tester( - Tester<char*>::allocate()); - tester->add_all(ts); + Tester<char*> tester; + status += tester.test_all (); } - return ts; + return status; } - |