1 #include "tao/StringSeqC.h"
4 ACE_TMAIN (int, ACE_TCHAR
*[])
6 char const *str
= "Some string";
10 for (CORBA::ULong i
= 0; i
< seq
.length (); ++i
)
15 // Save a pointer to the whole buffer.
16 char const * const *wholebuf
= seq
.get_buffer ();
18 // This call should reinitialize the the 100th element
19 // (the fact that the shrunk elements are reinitialized is TAO
20 // specific but we test for it).
22 // No reallocation should happen for the buffer.
23 ACE_TEST_ASSERT (seq
.get_buffer () == wholebuf
);
24 // And set the length to the same value
26 ACE_TEST_ASSERT (seq
.get_buffer () == wholebuf
);
27 // We cannot be sure that the pointer to the reinitialized 100th
28 // element is different from the old one since memory manager can
29 // return the same pointer that we've just released but it must
30 // not be 0 and it must be an empty string.
31 ACE_TEST_ASSERT (wholebuf
[99] != 0);
32 ACE_TEST_ASSERT (ACE_OS::strcmp (wholebuf
[99], "") == 0);
34 // Extend the sequence to the original size.
36 // No reallocation should happen for the buffer.
37 ACE_TEST_ASSERT (seq
.get_buffer () == wholebuf
);
38 // And now we can test absolutely legally that the 100th
39 // element was reinitialized as CORBA spec requires.
40 ACE_TEST_ASSERT (seq
[99].in () != 0);
41 ACE_TEST_ASSERT (ACE_OS::strcmp (seq
[99].in (), "") == 0);
43 // Reallocation should happen for the buffer.
44 ACE_TEST_ASSERT (seq
.get_buffer () != wholebuf
);
45 ACE_TEST_ASSERT (seq
[100].in () != 0);
46 ACE_TEST_ASSERT (ACE_OS::strcmp (seq
[100].in (), "") == 0);