2 //=============================================================================
4 * @file ub_struct_seq.cpp
6 * tests unbounded struct sequences
8 * @author Aniruddha Gokhale
10 //=============================================================================
14 #include "ub_struct_seq.h"
16 // ************************************************************************
17 // Test_Struct_Sequence
18 // ************************************************************************
20 Test_Unbounded_Struct_Sequence::Test_Unbounded_Struct_Sequence (
22 : opname_ (CORBA::string_dup ("test_struct_sequence"))
26 Test_Unbounded_Struct_Sequence::~Test_Unbounded_Struct_Sequence (
29 CORBA::string_free (this->opname_
);
31 // the other data members will be freed as they are "_var"s and objects
32 // (rather than pointers to objects)
36 Test_Unbounded_Struct_Sequence::opname () const
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
58 this->in_
[i
] = gen
->gen_fixed_struct ();
59 this->inout_
[i
] = gen
->gen_fixed_struct ();
66 Test_Unbounded_Struct_Sequence::reset_parameters ()
68 this->inout_
.clear ();
76 Test_Unbounded_Struct_Sequence::run_sii_test (
77 Alt_Mapping_ptr objref
)
81 this->ret_
= objref
->test_struct_sequence (this->in_
,
87 catch (const CORBA::Exception
& ex
)
89 ex
._tao_print_exception ("Test_Struct_Sequence::run_sii_test\n");
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_
));
103 Test_Unbounded_Struct_Sequence::print_values ()
105 ACE_DEBUG ((LM_DEBUG
,
106 "*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\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"
116 this->print_sequence (this->out_
);
117 ACE_DEBUG ((LM_DEBUG
,
118 "*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n"
120 this->print_sequence (this->ret_
);
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 ();
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
];
153 || !ACE::is_equal (vs1
.f
, vs2
.f
)
155 || !ACE::is_equal (vs1
.d
, vs2
.d
))
159 return true; // success
163 Test_Unbounded_Struct_Sequence::print_sequence (
164 const Alt_Mapping::StructSeq
&s
)
166 ACE_DEBUG ((LM_DEBUG
,
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
,
187 vs
.l
, vs
.c
, vs
.s
, vs
.o
, vs
.f
, vs
.b
, vs
.d
));