Merge pull request #2222 from jwillemsen/jwi-dllexportwarning
[ACE_TAO.git] / TAO / tests / Sequence_Unit_Tests / Bounded_String.cpp
blob6145fb19dfde96933283a4269d5ae753173290cf
1 /**
2 * @file
4 * @brief Smoke test (basically just compile) the bounded sequences
5 * for strings.
7 * @author Carlos O'Ryan
8 */
9 #include "tao/Bounded_Basic_String_Sequence_T.h"
10 #include "tao/CORBA_String.h"
11 #include "ace/Log_Msg.h"
13 CORBA::ULong const MAXIMUM = 42;
14 typedef TAO::bounded_basic_string_sequence<char, MAXIMUM> s_sequence;
16 int ACE_TMAIN (int, ACE_TCHAR *[])
18 try
20 s_sequence a;
21 s_sequence b(a);
23 s_sequence c(0, s_sequence::allocbuf(), true);
24 a = b;
26 a.length(c.maximum());
27 if (a.release())
29 b.length(a.length());
31 a[0] = const_cast<char const*>("Hello");
32 b[0] = a[0];
34 s_sequence const & d = a;
35 try
37 c[0] = d[0];
38 #if defined (TAO_CHECKED_SEQUENCE_INDEXING) && (TAO_CHECKED_SEQUENCE_INDEXING == 1)
39 return 1;
40 #endif
42 catch (const ::CORBA::BAD_PARAM &)
44 // c has length = 0, so there is an exception when we try
45 // to access element above length.
48 b.replace(0, s_sequence::allocbuf(), true);
50 char const * const * x = d.get_buffer();
51 if (x != 0)
53 s_sequence::freebuf(a.get_buffer(true));
55 x = b.get_buffer();
57 if (d.length())
59 s_sequence::freebuf(s_sequence::allocbuf());
62 s_sequence e(c);
64 CORBA::String_var w(const_cast<char const*>("World"));
65 try
67 e[0] = w;
68 #if defined (TAO_CHECKED_SEQUENCE_INDEXING) && (TAO_CHECKED_SEQUENCE_INDEXING == 1)
69 return 1;
70 #endif
72 catch (const ::CORBA::BAD_PARAM &)
74 // e has length = 0, so there is an exception when we try
75 // to access element above length.
78 catch (const ::CORBA::Exception &)
80 ACE_ERROR ((LM_ERROR, "Caught unexpected exception\n"));
81 return 1;
83 return 0;