4 * @brief Unit test for bounded sequences of object references.
6 * @author Carlos O'Ryan
8 #include "testing_object_reference_traits.hpp"
9 #include "tao/Object_Reference_Traits_T.h"
10 #include "testing_allocation_traits.hpp"
11 #include "testing_range_checking.hpp"
13 #include "mock_reference.hpp"
15 #include "ace/OS_NS_string.h"
16 #include "tao/Bounded_Object_Reference_Sequence_T.h"
17 #include "tao/Bounded_Value_Sequence_T.h"
18 #include "tao/Bounded_Basic_String_Sequence_T.h"
19 #include "tao/Bounded_BD_String_Sequence_T.h"
20 #include "tao/Bounded_Array_Sequence_T.h"
21 #include "tao/Bounded_Sequence_CDR_T.h"
24 #include "test_macros.h"
27 using namespace TAO_VERSIONED_NAMESPACE_NAME::TAO
;
29 CORBA::ULong
const TMAX
= 64;
31 typedef bounded_object_reference_sequence
<mock_reference
, mock_reference_var
,TMAX
> tested_sequence
;
33 CORBA::Boolean
operator<< (TAO_OutputCDR
&strm
, const tested_sequence
&sequence
)
35 return TAO::marshal_sequence(strm
, sequence
);
38 CORBA::Boolean
operator>> (TAO_InputCDR
&strm
, tested_sequence
&sequence
)
40 return TAO::demarshal_sequence(strm
, sequence
);
45 typedef tested_sequence::value_type value_type
;
46 typedef tested_sequence::const_value_type const_value_type
;
48 typedef tested_sequence::element_traits tested_element_traits
;
49 typedef tested_sequence::allocation_traits tested_allocation_traits
;
50 typedef TAO::details::range_checking
<value_type
,true> range
;
52 value_type
* alloc_and_init_buffer()
54 value_type
* buf
= tested_sequence::allocbuf();
55 buf
[0] = mock_reference::allocate(1);
56 buf
[1] = mock_reference::allocate(4);
57 buf
[2] = mock_reference::allocate(9);
58 buf
[3] = mock_reference::allocate(16);
63 int check_values(tested_sequence
const & a
)
65 CHECK_EQUAL( 1, a
[0]->id());
66 CHECK_EQUAL( 4, a
[1]->id());
67 CHECK_EQUAL( 9, a
[2]->id());
68 CHECK_EQUAL(16, a
[3]->id());
74 value_type
* buffer
= alloc_and_init_buffer();
76 expected_calls
s(mock_reference::marshal_calls
);
79 a
.replace(4, buffer
, false);
81 CHECK_EQUAL(CORBA::ULong(64), a
.maximum());
82 CHECK_EQUAL(CORBA::ULong(4), a
.length());
83 CHECK_EQUAL(buffer
, a
.get_buffer());
84 CHECK_EQUAL(false, a
.release());
89 FAIL_RETURN_IF_NOT(s
.expect(4), s
);
91 tested_sequence::freebuf(buffer
);
96 int ACE_TMAIN(int,ACE_TCHAR
*[])
104 status
+= mytester
.test_stream();
106 catch (const ::CORBA::Exception
&ex
)
108 ex
._tao_print_exception("ERROR : unexpected CORBA exception caugth :");