Merge pull request #2222 from jwillemsen/jwi-dllexportwarning
[ACE_TAO.git] / TAO / tests / Sequence_Unit_Tests / Unbounded_String.cpp
blobe3f3262878b72ff41969a6fb46749585e23744cc
1 /**
2 * @file
4 * @brief Smoke test (basically just compile) the unbounded sequences
5 * for strings.
7 * @author Carlos O'Ryan
8 */
9 #include "tao/Unbounded_Basic_String_Sequence_T.h"
10 #include "tao/CORBA_String.h"
11 #include "ace/Log_Msg.h"
13 typedef TAO::unbounded_basic_string_sequence<char> s_sequence;
15 int ACE_TMAIN (int, ACE_TCHAR *[])
17 try
19 s_sequence a;
20 s_sequence b(23);
22 s_sequence c(32, 0, s_sequence::allocbuf(32), true);
23 a = b;
25 a.length(c.maximum());
26 if (a.release())
28 b.length(a.length());
30 a[0] = const_cast<char const*>("Hello");
31 b[0] = a[0];
33 s_sequence const & d = a;
34 try
36 c[0] = d[0];
37 #if defined (TAO_CHECKED_SEQUENCE_INDEXING) && (TAO_CHECKED_SEQUENCE_INDEXING == 1)
38 return 1;
39 #endif
41 catch (const ::CORBA::BAD_PARAM &)
43 // c has length = 0, so there is an exception when we try
44 // to access element above length.
47 b.replace(64, 0, s_sequence::allocbuf(64), true);
49 char const * const * x = d.get_buffer();
50 if (x != 0)
52 s_sequence::freebuf(a.get_buffer(true));
54 x = b.get_buffer();
56 if (d.length())
58 s_sequence::freebuf(s_sequence::allocbuf(64));
61 s_sequence e(c);
63 CORBA::String_var w(const_cast<char const*>("World"));
64 try
66 e[0] = w;
67 #if defined (TAO_CHECKED_SEQUENCE_INDEXING) && (TAO_CHECKED_SEQUENCE_INDEXING == 1)
68 return 1;
69 #endif
71 catch (const ::CORBA::BAD_PARAM &)
73 // e has length = 0, so there is an exception when we try
74 // to access element above length.
77 catch (const ::CORBA::Exception &)
79 ACE_ERROR ((LM_ERROR, "Caught unexpected exception\n"));
80 return 1;
83 return 0;