ACE+TAO-6_5_17
[ACE_TAO.git] / TAO / tests / Param_Test / fixed_array.cpp
blob45f86f6f59d5c11d0de4b7afcf35f24a829918b1
2 //=============================================================================
3 /**
4 * @file fixed_array.cpp
6 * tests fixed size arrays
8 * @author Aniruddha Gokhale
9 */
10 //=============================================================================
13 #include "helper.h"
14 #include "fixed_array.h"
16 // ************************************************************************
17 // Test_Fixed_Array
18 // ************************************************************************
20 Test_Fixed_Array::Test_Fixed_Array (void)
21 : opname_ (CORBA::string_dup ("test_fixed_array")),
22 ret_ (new Param_Test::Fixed_Array)
26 Test_Fixed_Array::~Test_Fixed_Array (void)
28 CORBA::string_free (this->opname_);
29 this->opname_ = 0;
32 const char *
33 Test_Fixed_Array::opname (void) const
35 return this->opname_;
38 void
39 Test_Fixed_Array::dii_req_invoke (CORBA::Request *req)
41 req->add_in_arg ("s1") <<= Param_Test::Fixed_Array_forany (this->in_);
42 req->add_inout_arg ("s2") <<= Param_Test::Fixed_Array_forany (this->inout_);
43 req->add_out_arg ("s3") <<= Param_Test::Fixed_Array_forany (this->out_);
44 req->set_return_type (Param_Test::_tc_Fixed_Array);
46 req->invoke ();
48 Param_Test::Fixed_Array_forany forany;
49 req->return_value () >>= forany;
50 Param_Test::Fixed_Array_copy (this->ret_, forany.in ());
52 CORBA::NamedValue_ptr arg2 =
53 req->arguments ()->item (1);
54 *arg2->value () >>= forany;
55 Param_Test::Fixed_Array_copy (this->inout_, forany.in ());
57 CORBA::NamedValue_ptr arg3 =
58 req->arguments ()->item (2);
59 Param_Test::Fixed_Array_forany out_any (this->out_);
60 *arg3->value () >>= forany;
61 Param_Test::Fixed_Array_copy (this->out_, forany.in ());
64 int
65 Test_Fixed_Array::init_parameters (Param_Test_ptr /*objref*/
66 /*env*/)
68 Generator *gen = GENERATOR::instance (); // value generator
70 //ACE_UNUSED_ARG (objref);
72 for (CORBA::ULong i=0; i < Param_Test::DIM1; i++)
74 this->in_ [i] = gen->gen_long ();
77 return 0;
80 int
81 Test_Fixed_Array::reset_parameters (void)
84 for (CORBA::ULong i=0; i < Param_Test::DIM1; i++)
86 this->inout_ [i] = 0;
87 this->out_ [i] = 0;
89 // free the return value array
90 Param_Test::Fixed_Array_free (this->ret_._retn ());
91 // needed for repeated DII calls
92 this->ret_ = new Param_Test::Fixed_Array;
93 return 0;
96 int
97 Test_Fixed_Array::run_sii_test (Param_Test_ptr objref)
99 try
101 this->ret_ = objref->test_fixed_array (this->in_,
102 this->inout_,
103 this->out_);
105 return 0;
107 catch (const CORBA::Exception& ex)
109 ex._tao_print_exception ("Test_Fixed_Array::run_sii_test\n");
112 return -1;
115 CORBA::Boolean
116 Test_Fixed_Array::check_validity (void)
118 if (this->compare (this->in_, this->inout_) &&
119 this->compare (this->in_, this->out_) &&
120 this->compare (this->in_, this->ret_.in ()))
121 return 1;
122 else
123 return 0;
126 CORBA::Boolean
127 Test_Fixed_Array::check_validity (CORBA::Request_ptr /*req*/)
129 //ACE_UNUSED_ARG (req);
130 return this->check_validity ();
133 CORBA::Boolean
134 Test_Fixed_Array::compare (const Param_Test::Fixed_Array_slice *a1,
135 const Param_Test::Fixed_Array_slice *a2)
137 for (CORBA::ULong i=0; i < Param_Test::DIM1; i++)
139 if (a1[i] != a2[i])
140 return 0;
142 return 1; // success
145 void
146 Test_Fixed_Array::print_values (void)
148 ACE_DEBUG ((LM_DEBUG, "IN array\n"));
149 this->print (this->in_);
150 ACE_DEBUG ((LM_DEBUG, "INOUT array\n"));
151 this->print (this->inout_);
152 ACE_DEBUG ((LM_DEBUG, "OUT array\n"));
153 this->print (this->out_);
154 ACE_DEBUG ((LM_DEBUG, "RET array\n"));
155 this->print (this->ret_.in ());
158 void
159 Test_Fixed_Array::print (const Param_Test::Fixed_Array_slice *a)
161 for (CORBA::ULong i = 0; i < Param_Test::DIM1; i++)
163 ACE_DEBUG ((LM_DEBUG, "\t\tElement #%d = %d\n",i, a[i]));