Use =default for skeleton copy constructor
[ACE_TAO.git] / TAO / tests / Alt_Mapping / ub_struct_seq.cpp
blob3b3c0c7e8ba2d902cc9bef99563396793261e3d0
2 //=============================================================================
3 /**
4 * @file ub_struct_seq.cpp
6 * tests unbounded struct sequences
8 * @author Aniruddha Gokhale
9 */
10 //=============================================================================
13 #include "helper.h"
14 #include "ub_struct_seq.h"
16 // ************************************************************************
17 // Test_Struct_Sequence
18 // ************************************************************************
20 Test_Unbounded_Struct_Sequence::Test_Unbounded_Struct_Sequence (
21 void)
22 : opname_ (CORBA::string_dup ("test_struct_sequence"))
26 Test_Unbounded_Struct_Sequence::~Test_Unbounded_Struct_Sequence (
27 void)
29 CORBA::string_free (this->opname_);
30 this->opname_ = 0;
31 // the other data members will be freed as they are "_var"s and objects
32 // (rather than pointers to objects)
35 const char *
36 Test_Unbounded_Struct_Sequence::opname () const
38 return this->opname_;
41 int
42 Test_Unbounded_Struct_Sequence::init_parameters (Alt_Mapping_ptr)
44 Generator *gen = GENERATOR::instance (); // value generator
46 // Get some sequence length (not more than 10).
47 CORBA::ULong len = (CORBA::ULong) (gen->gen_long () % 10) + 1;
49 // set the length of the sequence
50 this->in_.resize (len);
51 this->inout_.resize (len);
53 // Now set each individual element.
54 for (CORBA::ULong i = 0; i < this->in_.size (); i++)
56 // Generate some arbitrary struct to be filled into the ith location in
57 // the sequence.
58 this->in_[i] = gen->gen_fixed_struct ();
59 this->inout_[i] = gen->gen_fixed_struct ();
62 return 0;
65 int
66 Test_Unbounded_Struct_Sequence::reset_parameters ()
68 this->inout_.clear ();
69 this->out_.clear ();
70 this->ret_.clear ();
72 return 0;
75 int
76 Test_Unbounded_Struct_Sequence::run_sii_test (
77 Alt_Mapping_ptr objref)
79 try
81 this->ret_ = objref->test_struct_sequence (this->in_,
82 this->inout_,
83 this->out_);
85 return 0;
87 catch (const CORBA::Exception& ex)
89 ex._tao_print_exception ("Test_Struct_Sequence::run_sii_test\n");
91 return -1;
94 CORBA::Boolean
95 Test_Unbounded_Struct_Sequence::check_validity ()
97 return (this->compare (this->in_, this->inout_)
98 && this->compare (this->in_, this->out_)
99 && this->compare (this->in_, this->ret_));
102 void
103 Test_Unbounded_Struct_Sequence::print_values ()
105 ACE_DEBUG ((LM_DEBUG,
106 "*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n"
107 "IN sequence\n"));
108 this->print_sequence (this->in_);
109 ACE_DEBUG ((LM_DEBUG,
110 "*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n"
111 "INOUT sequence\n"));
112 this->print_sequence (this->inout_);
113 ACE_DEBUG ((LM_DEBUG,
114 "*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n"
115 "OUT sequence\n"));
116 this->print_sequence (this->out_);
117 ACE_DEBUG ((LM_DEBUG,
118 "*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n"
119 "RET sequence\n"));
120 this->print_sequence (this->ret_);
123 CORBA::Boolean
124 Test_Unbounded_Struct_Sequence::compare (
125 const Alt_Mapping::StructSeq &s1,
126 const Alt_Mapping::StructSeq &s2)
128 ACE_CDR::ULong s1v = s1.capacity ();
129 ACE_CDR::ULong s2v = s2.capacity ();
131 if (s1v != s2v)
133 return false;
136 s1v = s1.size ();
137 s2v = s2.size ();
139 if (s1v != s2v)
141 return false;
144 for (CORBA::ULong i=0; i < s1.size (); i++)
146 const Alt_Mapping::Fixed_Struct& vs1 = s1[i];
147 const Alt_Mapping::Fixed_Struct& vs2 = s2[i];
149 if (vs1.l != vs2.l
150 || vs1.c != vs2.c
151 || vs1.s != vs2.s
152 || vs1.o != vs2.o
153 || !ACE::is_equal (vs1.f, vs2.f)
154 || vs1.b != vs2.b
155 || !ACE::is_equal (vs1.d, vs2.d))
156 return false;
159 return true; // success
162 void
163 Test_Unbounded_Struct_Sequence::print_sequence (
164 const Alt_Mapping::StructSeq &s)
166 ACE_DEBUG ((LM_DEBUG,
167 "maximum = %d\n"
168 "length = %d\n",
169 s.capacity (),
170 s.size ()));
171 ACE_DEBUG ((LM_DEBUG, "Elements -\n"));
173 for (CORBA::ULong i = 0; i < s.size (); i++)
175 const Alt_Mapping::Fixed_Struct& vs = s[i];
177 ACE_DEBUG ((LM_DEBUG,
178 "Element #%d\n"
179 "\tl = %d\n"
180 "\tc = %c\n"
181 "\ts = %d\n"
182 "\to = %x\n"
183 "\tf = %f\n"
184 "\tb = %d\n"
185 "\td = %f\n",
187 vs.l, vs.c, vs.s, vs.o, vs.f, vs.b, vs.d));