Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / tests / Param_Test / var_array.cpp
blob52697acbe299122f2478c950ee2912a7db02453f
2 //=============================================================================
3 /**
4 * @file var_array.cpp
6 * tests fixed size arrays
8 * @author Aniruddha Gokhale
9 */
10 //=============================================================================
13 #include "helper.h"
14 #include "var_array.h"
16 // ************************************************************************
17 // Test_Var_Array
18 // ************************************************************************
20 Test_Var_Array::Test_Var_Array ()
21 : opname_ (CORBA::string_dup ("test_var_array")),
22 out_ (new Param_Test::Var_Array),
23 ret_ (new Param_Test::Var_Array)
27 Test_Var_Array::~Test_Var_Array ()
29 CORBA::string_free (this->opname_);
30 this->opname_ = 0;
33 const char *
34 Test_Var_Array::opname () const
36 return this->opname_;
39 void
40 Test_Var_Array::dii_req_invoke (CORBA::Request *req)
42 req->add_in_arg ("s1") <<= Param_Test::Var_Array_forany (this->in_);
43 req->add_inout_arg ("s2") <<= Param_Test::Var_Array_forany (this->inout_);
44 req->add_out_arg ("s3") <<= Param_Test::Var_Array_forany (this->out_.inout ());
46 req->set_return_type (Param_Test::_tc_Var_Array);
48 req->invoke ();
50 Param_Test::Var_Array_forany forany;
52 req->return_value () >>= forany;
53 this->ret_ = Param_Test::Var_Array_dup (forany.in ());
55 CORBA::NamedValue_ptr o2 =
56 req->arguments ()->item (1);
57 *o2->value () >>= forany;
58 Param_Test::Var_Array_copy (this->inout_, forany.in ());
60 CORBA::NamedValue_ptr o3 =
61 req->arguments ()->item (2);
62 *o3->value () >>= forany;
63 this->out_ = Param_Test::Var_Array_dup (forany.in ());
66 int
67 Test_Var_Array::init_parameters (Param_Test_ptr)
69 Generator *gen = GENERATOR::instance (); // value generator
72 // fill the in_ array
73 for (CORBA::ULong i=0; i < Param_Test::DIM2; i++)
75 this->in_[i] = gen->gen_string ();
78 return 0;
81 int
82 Test_Var_Array::reset_parameters ()
84 // free the out, and return value arrays
85 Param_Test::Var_Array_free (this->out_._retn ());
86 Param_Test::Var_Array_free (this->ret_._retn ());
87 this->out_ = new Param_Test::Var_Array;
88 this->ret_ = new Param_Test::Var_Array;
89 return 0;
92 int
93 Test_Var_Array::run_sii_test (Param_Test_ptr objref)
95 try
97 Param_Test::Var_Array_out out_arr (this->out_.out ());
98 this->ret_ = objref->test_var_array (this->in_,
99 this->inout_,
100 out_arr);
102 return 0;
104 catch (const CORBA::Exception& ex)
106 ex._tao_print_exception ("Test_Var_Array::run_sii_test\n");
108 return -1;
111 CORBA::Boolean
112 Test_Var_Array::check_validity ()
114 if (this->compare (this->in_, this->inout_) &&
115 this->compare (this->in_, this->out_.in ()) &&
116 this->compare (this->in_, this->ret_.in ()))
117 return 1;
118 else
119 return 0;
122 CORBA::Boolean
123 Test_Var_Array::check_validity (CORBA::Request_ptr )
125 return this->check_validity ();
128 CORBA::Boolean
129 Test_Var_Array::compare (const Param_Test::Var_Array_slice *a1,
130 const Param_Test::Var_Array_slice *a2)
132 for (CORBA::ULong i=0; i < Param_Test::DIM2; i++)
134 if (ACE_OS::strcmp (a1[i].in (), a2[i].in ()))
135 return 0;
137 return 1; // success
140 void
141 Test_Var_Array::print_values ()
143 ACE_DEBUG ((LM_DEBUG, "IN array\n"));
144 this->print (this->in_);
145 ACE_DEBUG ((LM_DEBUG, "INOUT array\n"));
146 this->print (this->inout_);
147 ACE_DEBUG ((LM_DEBUG, "OUT array\n"));
148 this->print (this->out_.in ());
149 ACE_DEBUG ((LM_DEBUG, "RET array\n"));
150 this->print (this->ret_.in ());
153 void
154 Test_Var_Array::print (const Param_Test::Var_Array_slice *a)
156 for (CORBA::ULong i = 0; i < Param_Test::DIM2; i++)
158 ACE_DEBUG ((LM_DEBUG, "\t\tElement #%d = %C\n",i, a[i].in ()));