diff options
23 files changed, 1472 insertions, 14 deletions
diff --git a/TAO/tests/Param_Test/Makefile b/TAO/tests/Param_Test/Makefile index 8f63f229dae..5fc6de591eb 100644 --- a/TAO/tests/Param_Test/Makefile +++ b/TAO/tests/Param_Test/Makefile @@ -35,7 +35,9 @@ CLI_FILES = param_testCli \ bd_long_seq \ bd_short_seq \ bd_str_seq \ + bd_wstr_seq \ bd_string \ + bd_wstring \ bd_struct_seq \ fixed_array \ fixed_struct \ @@ -50,7 +52,9 @@ CLI_FILES = param_testCli \ ub_objref_seq \ ub_short_seq \ ub_str_seq \ + ub_wstr_seq \ ub_string \ + ub_wstring \ ub_struct_seq \ var_array \ var_struct \ diff --git a/TAO/tests/Param_Test/README b/TAO/tests/Param_Test/README index 7096162031c..db140be410c 100644 --- a/TAO/tests/Param_Test/README +++ b/TAO/tests/Param_Test/README @@ -52,10 +52,14 @@ To run the client, type short for shorts ulonglong for unsigned long long ubstring for unbounded string + ubwstring for unbounded wide string bdstring for bounded string + bswstring for bounded wide string fixed_struct for fixed sized structs ub_strseq for sequences of strings + ub_wstrseq for sequences of wide strings bd_strseq for bounded sequences of strings + bd_wstrseq for bounded sequences of wide strings var_struct for variable structs nested_struct for nested structs objref_struct for object references inside structures diff --git a/TAO/tests/Param_Test/bd_string.cpp b/TAO/tests/Param_Test/bd_string.cpp index 2a273c7523a..bb10627bafc 100644 --- a/TAO/tests/Param_Test/bd_string.cpp +++ b/TAO/tests/Param_Test/bd_string.cpp @@ -105,10 +105,10 @@ Test_Bounded_String::run_sii_test (Param_Test_ptr objref, { CORBA::String_out str_out (this->out_); - this->ret_ = objref->test_unbounded_string (this->in_, - this->inout_, - str_out, - ACE_TRY_ENV); + this->ret_ = objref->test_bounded_string (this->in_, + this->inout_, + str_out, + ACE_TRY_ENV); ACE_TRY_CHECK; return 0; @@ -116,7 +116,7 @@ Test_Bounded_String::run_sii_test (Param_Test_ptr objref, ACE_CATCHANY { ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - "Test_Bounded_String_Sequence::run_sii_test\n"); + "Test_Bounded_String::run_sii_test\n"); } ACE_ENDTRY; diff --git a/TAO/tests/Param_Test/bd_string.h b/TAO/tests/Param_Test/bd_string.h index 7b12701fdb3..faf9bfd0fad 100644 --- a/TAO/tests/Param_Test/bd_string.h +++ b/TAO/tests/Param_Test/bd_string.h @@ -22,7 +22,7 @@ #include "param_testCli.h" // =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* -// test unbounded strings +// tests bounded strings // =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* class Test_Bounded_String { diff --git a/TAO/tests/Param_Test/bd_wstr_seq.cpp b/TAO/tests/Param_Test/bd_wstr_seq.cpp new file mode 100644 index 00000000000..bbde321c6d9 --- /dev/null +++ b/TAO/tests/Param_Test/bd_wstr_seq.cpp @@ -0,0 +1,209 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/Param_Test +// +// = FILENAME +// bd_wstr_seq.cpp +// +// = DESCRIPTION +// tests bounded wide string sequences +// +// = AUTHORS +// Jeff Parsons +// +// ============================================================================ + +#include "helper.h" +#include "bd_wstr_seq.h" + +// ************************************************************************ +// Test_Bounded_WString_Sequence +// ************************************************************************ + +Test_Bounded_WString_Sequence::Test_Bounded_WString_Sequence (void) + : opname_ (CORBA::string_dup ("test_bounded_wstrseq")), + in_ (new Param_Test::Bounded_WStrSeq), + inout_ (new Param_Test::Bounded_WStrSeq), + out_ (new Param_Test::Bounded_WStrSeq), + ret_ (new Param_Test::Bounded_WStrSeq) +{ +} + +Test_Bounded_WString_Sequence::~Test_Bounded_WString_Sequence (void) +{ + CORBA::string_free (this->opname_); + this->opname_ = 0; +} + +const char * +Test_Bounded_WString_Sequence::opname (void) const +{ + return this->opname_; +} + +void +Test_Bounded_WString_Sequence::dii_req_invoke (CORBA::Request *req, + CORBA::Environment &ACE_TRY_ENV) +{ + req->invoke (ACE_TRY_ENV); +} + +int +Test_Bounded_WString_Sequence::init_parameters (Param_Test_ptr , + CORBA::Environment &) +{ + Generator *gen = GENERATOR::instance (); // value generator + + const CORBA::WChar *choiceList[3]; + CORBA::ULong i = 0; + + for (i = 0; i < 3; i++) + { + choiceList[i] = gen->gen_wstring (); + } + + CORBA::ULong len = this->in_->maximum (); + + // set the length of the sequence + this->in_->length (len); + this->inout_->length (len); + // now set each individual element + for (i = 0; i < this->in_->length (); i++) + { + this->in_[i] = choiceList[i%3]; + this->inout_[i] = choiceList[(i+1)%3]; // different from in_ + } + return 0; +} + +int +Test_Bounded_WString_Sequence::reset_parameters (void) +{ + this->inout_ = new Param_Test::Bounded_WStrSeq; // delete the previous ones + this->out_ = new Param_Test::Bounded_WStrSeq; + this->ret_ = new Param_Test::Bounded_WStrSeq; + return 0; +} + +int +Test_Bounded_WString_Sequence::run_sii_test (Param_Test_ptr objref, + CORBA::Environment &ACE_TRY_ENV) +{ + ACE_TRY + { + Param_Test::Bounded_WStrSeq_out out (this->out_.out ()); + + this->ret_ = objref->test_bounded_wstrseq (this->in_.in (), + this->inout_.inout (), + out, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + return 0; + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Test_Bounded_WString_Sequence::run_sii_test\n"); + + } + ACE_ENDTRY; + return -1; +} + +int +Test_Bounded_WString_Sequence::add_args (CORBA::NVList_ptr param_list, + CORBA::NVList_ptr retval, + CORBA::Environment &ACE_TRY_ENV) +{ + ACE_TRY + { + CORBA::Any in_arg (Param_Test::_tc_Bounded_WStrSeq, + (void *) &this->in_.in (), + 0); + + CORBA::Any inout_arg (Param_Test::_tc_Bounded_WStrSeq, + &this->inout_.inout (), + 0); + + CORBA::Any out_arg (Param_Test::_tc_Bounded_WStrSeq, + &this->out_.inout (), // .out () causes crash + 0); + + // add parameters + param_list->add_value ("ws1", + in_arg, + CORBA::ARG_IN, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + param_list->add_value ("ws2", + inout_arg, + CORBA::ARG_INOUT, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + param_list->add_value ("ws3", + out_arg, + CORBA::ARG_OUT, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + // add return value type + CORBA::NamedValue *item = retval->item (0, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + item->value ()->replace (Param_Test::_tc_Bounded_WStrSeq, + &this->ret_.inout (), // see above + 0, // does not own + ACE_TRY_ENV); + ACE_TRY_CHECK; + + return 0; + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Test_Bounded_WString_Sequence::add_args\n"); + + } + ACE_ENDTRY; + return -1; +} + +CORBA::Boolean +Test_Bounded_WString_Sequence::check_validity (void) +{ + CORBA::Boolean flag = 0; + if ((this->in_->length () == this->inout_->length ()) && + (this->in_->length () == this->out_->length ()) && + (this->in_->length () == this->ret_->length ())) + { + flag = 1; // assume all are equal + // lengths are same. Now compare the contents + for (CORBA::ULong i=0; i < this->in_->length () && flag; i++) + { + if (ACE_OS::strcmp (this->in_[i], this->inout_[i]) || + ACE_OS::strcmp (this->in_[i], this->out_[i]) || + ACE_OS::strcmp (this->in_[i], this->ret_[i])) + // not equal + flag = 0; + } + } + return flag; +} + +CORBA::Boolean +Test_Bounded_WString_Sequence::check_validity (CORBA::Request_ptr) +{ + return this->check_validity (); +} + +void +Test_Bounded_WString_Sequence::print_values (void) +{ +} diff --git a/TAO/tests/Param_Test/bd_wstr_seq.h b/TAO/tests/Param_Test/bd_wstr_seq.h new file mode 100644 index 00000000000..43c0f4f5e9b --- /dev/null +++ b/TAO/tests/Param_Test/bd_wstr_seq.h @@ -0,0 +1,86 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/Param_Test +// +// = FILENAME +// bd_wstr_seq.h +// +// = DESCRIPTION +// Tests bounded sequences of wide strings +// +// = AUTHORS +// Jeff Parsons +// +// ============================================================================ + +#ifndef PARAM_TEST_BOUNDED_WSTRING_SEQUENCE_H +#define PARAM_TEST_BOUNDED_WSTRING_SEQUENCE_H + +#include "param_testCli.h" + +// =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* +// test typedefed sequences (in our case, sequences of wstrings) +// =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* + +class Test_Bounded_WString_Sequence +{ +public: + Test_Bounded_WString_Sequence (void); + // ctor + + ~Test_Bounded_WString_Sequence (void); + // dtor + + int run_sii_test (Param_Test_ptr objref, + CORBA::Environment &env); + // run the SII test + + int add_args (CORBA::NVList_ptr nvlist, + CORBA::NVList_ptr retval, + CORBA::Environment &env); + // add args to NVList for DII + + const char *opname (void) const; + // return operation name + + int init_parameters (Param_Test_ptr objref, + CORBA::Environment &env); + // set values for parameters + + int reset_parameters (void); + // reset values for CORBA + + CORBA::Boolean check_validity (void); + // check if results are valid + + CORBA::Boolean check_validity (CORBA::Request_ptr req); + // check if results are valid. This is used for DII results + + void print_values (void); + // print all the values + + void dii_req_invoke (CORBA::Request *, + CORBA::Environment &); + // invoke DII request with appropriate exception handling. + +private: + char *opname_; + // operation name + + Param_Test::Bounded_WStrSeq_var in_; + // in parameter + + Param_Test::Bounded_WStrSeq_var inout_; + // inout parameter + + Param_Test::Bounded_WStrSeq_var out_; + // out parameter + + Param_Test::Bounded_WStrSeq_var ret_; + // return value +}; + +#endif /* PARAM_TEST_BOUNDED_WSTRING_SEQUENCE_H */ diff --git a/TAO/tests/Param_Test/bd_wstring.cpp b/TAO/tests/Param_Test/bd_wstring.cpp new file mode 100644 index 00000000000..04e6e511097 --- /dev/null +++ b/TAO/tests/Param_Test/bd_wstring.cpp @@ -0,0 +1,210 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/Param_Test +// +// = FILENAME +// bd_wstring.cpp +// +// = DESCRIPTION +// tests bounded strings +// +// = AUTHORS +// Jeff Parsons +// +// ============================================================================ + +#include "helper.h" +#include "bd_wstring.h" + +// ************************************************************************ +// Test_Bounded_WString +// ************************************************************************ + +Test_Bounded_WString::Test_Bounded_WString (void) + : opname_ (CORBA::string_dup ("test_bounded_wstring")), + in_ (0), + inout_ (0), + out_ (0), + ret_ (0) +{ +} + +Test_Bounded_WString::~Test_Bounded_WString (void) +{ + CORBA::string_free (this->opname_); + CORBA::wstring_free (this->in_); + CORBA::wstring_free (this->inout_); + CORBA::wstring_free (this->out_); + CORBA::wstring_free (this->ret_); + this->opname_ = 0; + this->in_ = 0; + this->inout_ = 0; + this->out_ = 0; + this->ret_ = 0; +} + +const char * +Test_Bounded_WString::opname (void) const +{ + return this->opname_; +} + +void +Test_Bounded_WString::dii_req_invoke (CORBA::Request *req, + CORBA::Environment &ACE_TRY_ENV) +{ + req->invoke (ACE_TRY_ENV); +} + +int +Test_Bounded_WString::init_parameters (Param_Test_ptr, + CORBA::Environment &) +{ + Generator *gen = GENERATOR::instance (); // value generator + + // release any previously occupied values + CORBA::wstring_free (this->in_); + CORBA::wstring_free (this->inout_); + CORBA::wstring_free (this->out_); + CORBA::wstring_free (this->ret_); + this->in_ = 0; + this->inout_ = 0; + this->out_ = 0; + this->ret_ = 0; + + this->in_ = gen->gen_wstring (32); + this->inout_ = CORBA::wstring_dup (this->in_); + return 0; +} + +int +Test_Bounded_WString::reset_parameters (void) +{ + // release any previously occupied values + CORBA::wstring_free (this->inout_); + CORBA::wstring_free (this->out_); + CORBA::wstring_free (this->ret_); + this->inout_ = 0; + this->out_ = 0; + this->ret_ = 0; + + this->inout_ = CORBA::wstring_dup (this->in_); + return 0; +} + +int +Test_Bounded_WString::run_sii_test (Param_Test_ptr objref, + CORBA::Environment &ACE_TRY_ENV) +{ + ACE_TRY + { + CORBA::WString_out str_out (this->out_); + + this->ret_ = objref->test_bounded_wstring (this->in_, + this->inout_, + str_out, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + return 0; + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Test_Bounded_WString::run_sii_test\n"); + + } + ACE_ENDTRY; + return -1; +} + +int +Test_Bounded_WString::add_args (CORBA::NVList_ptr param_list, + CORBA::NVList_ptr retval, + CORBA::Environment &ACE_TRY_ENV) +{ + ACE_TRY + { + // create the parameters + CORBA::Any in_arg (CORBA::_tc_wstring, + &this->in_, + 0); + + CORBA::Any inout_arg (CORBA::_tc_wstring, + &this->inout_, + 0); + + CORBA::Any out_arg (CORBA::_tc_wstring, + &this->out_, + 0); + + // add parameters + param_list->add_value ("ws1", + in_arg, + CORBA::ARG_IN, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + param_list->add_value ("ws2", + inout_arg, + CORBA::ARG_INOUT, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + param_list->add_value ("s3", + out_arg, + CORBA::ARG_OUT, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + // add return value + CORBA::NamedValue *item = retval->item (0, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + item->value ()->replace (CORBA::_tc_wstring, + &this->ret_, + 0, // does not own + ACE_TRY_ENV); + ACE_TRY_CHECK; + + return 0; + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Test_Bounded_WString::add_args\n"); + + } + ACE_ENDTRY; + return -1; +} + +CORBA::Boolean +Test_Bounded_WString::check_validity (void) +{ + CORBA::ULong len = ACE_OS::wslen (this->in_); + + if (!ACE_OS::wscmp (this->in_, this->out_) && + !ACE_OS::wscmp (this->in_, this->ret_) && + ACE_OS::wslen (this->inout_) == 2*len && + !ACE_OS::wsncmp (this->in_, this->inout_, len) && + !ACE_OS::wsncmp (this->in_, &this->inout_[len], len)) + return 1; + + return 0; // otherwise +} + +CORBA::Boolean +Test_Bounded_WString::check_validity (CORBA::Request_ptr) +{ + return this->check_validity (); +} + +void +Test_Bounded_WString::print_values (void) +{ +} diff --git a/TAO/tests/Param_Test/bd_wstring.h b/TAO/tests/Param_Test/bd_wstring.h new file mode 100644 index 00000000000..65b22fdc5f9 --- /dev/null +++ b/TAO/tests/Param_Test/bd_wstring.h @@ -0,0 +1,89 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/Param_Test +// +// = FILENAME +// bd_wstring.h +// +// = DESCRIPTION +// Tests bounded wide string +// +// = AUTHORS +// Jeff Parsons +// +// ============================================================================ + +#ifndef PARAM_TEST_BOUNDED_WSTRING_H +#define PARAM_TEST_BOUNDED_WSTRING_H + +#include "param_testCli.h" + +// =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* +// tests bounded wide strings +// =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* +class Test_Bounded_WString +{ +public: + Test_Bounded_WString (void); + // ctor + + ~Test_Bounded_WString (void); + // dtor + + int run_sii_test (Param_Test_ptr objref, + CORBA::Environment &env); + // run the SII test + + int add_args (CORBA::NVList_ptr nvlist, + CORBA::NVList_ptr retval, + CORBA::Environment &env); + // add args to NVList for DII + + int add_args (CORBA::Request_ptr &req, + CORBA::Environment &env); + // add args to NVList using << operator + + const char *opname (void) const; + // return operation name + + int init_parameters (Param_Test_ptr objref, + CORBA::Environment &env); + // set values for parameters + + int reset_parameters (void); + // reset values for CORBA + + CORBA::Boolean check_validity (void); + // check if results are valid + + CORBA::Boolean check_validity (CORBA::Request_ptr req); + // check if results are valid. This is used for DII results + + void print_values (void); + // print all the values + + void dii_req_invoke (CORBA::Request *, + CORBA::Environment &); + // invoke DII request with appropriate exception handling. + +private: + char *opname_; + // operation name + + CORBA::WChar *in_; + // in parameter + + CORBA::WChar *inout_; + // inout parameter + + CORBA::WChar *out_; + // out parameter + + CORBA::WChar *ret_; + // return value +}; + +#endif /* PARAM_TEST_BOUNDED_WSTRING_H */ diff --git a/TAO/tests/Param_Test/client.dsp b/TAO/tests/Param_Test/client.dsp index 460976a4f4a..5fb3cc154b7 100644 --- a/TAO/tests/Param_Test/client.dsp +++ b/TAO/tests/Param_Test/client.dsp @@ -111,6 +111,14 @@ SOURCE=.\bd_struct_seq.cpp # End Source File
# Begin Source File
+SOURCE=.\bd_wstr_seq.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\bd_wstring.cpp
+# End Source File
+# Begin Source File
+
SOURCE=.\big_union.cpp
# End Source File
# Begin Source File
@@ -211,6 +219,14 @@ SOURCE=.\ub_struct_seq.cpp # End Source File
# Begin Source File
+SOURCE=.\ub_wstr_seq.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\ub_wstring.cpp
+# End Source File
+# Begin Source File
+
SOURCE=.\ulonglong.cpp
# End Source File
# Begin Source File
@@ -251,6 +267,14 @@ SOURCE=.\bd_struct_seq.h # End Source File
# Begin Source File
+SOURCE=.\bd_wstr_seq.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\bd_wstring.h
+# End Source File
+# Begin Source File
+
SOURCE=.\big_union.h
# End Source File
# Begin Source File
@@ -351,6 +375,14 @@ SOURCE=.\ub_struct_seq.h # End Source File
# Begin Source File
+SOURCE=.\ub_wstr_seq.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\ub_wstring.h
+# End Source File
+# Begin Source File
+
SOURCE=.\ulonglong.h
# End Source File
# Begin Source File
diff --git a/TAO/tests/Param_Test/driver.cpp b/TAO/tests/Param_Test/driver.cpp index 85c030f3383..829ba5f2bd3 100644 --- a/TAO/tests/Param_Test/driver.cpp +++ b/TAO/tests/Param_Test/driver.cpp @@ -181,6 +181,32 @@ Driver::run (void) delete client; } break; + case Options::TEST_UB_WSTRING: + { + Param_Test_Client<Test_Unbounded_WString> *client = new + Param_Test_Client<Test_Unbounded_WString> (this->orb_.in (), + this->objref_.in(), + new Test_Unbounded_WString); + if (opt->invoke_type () == Options::SII) + retstatus = client->run_sii_test (); + else + retstatus = client->run_dii_test (); + delete client; + } + break; + case Options::TEST_BD_WSTRING: + { + Param_Test_Client<Test_Bounded_WString> *client = new + Param_Test_Client<Test_Bounded_WString> (this->orb_.in (), + this->objref_.in(), + new Test_Bounded_WString); + if (opt->invoke_type () == Options::SII) + retstatus = client->run_sii_test (); + else + retstatus = client->run_dii_test (); + delete client; + } + break; case Options::TEST_FIXED_STRUCT: { Param_Test_Client<Test_Fixed_Struct> *client = new @@ -220,6 +246,32 @@ Driver::run (void) delete client; } break; + case Options::TEST_UB_WSTRING_SEQUENCE: + { + Param_Test_Client<Test_WString_Sequence> *client = new + Param_Test_Client<Test_WString_Sequence> (this->orb_.in (), + this->objref_.in(), + new Test_WString_Sequence); + if (opt->invoke_type () == Options::SII) + retstatus = client->run_sii_test (); + else + retstatus = client->run_dii_test (); + delete client; + } + break; + case Options::TEST_BD_WSTRING_SEQUENCE: + { + Param_Test_Client<Test_Bounded_WString_Sequence> *client = new + Param_Test_Client<Test_Bounded_WString_Sequence> (this->orb_.in (), + this->objref_.in(), + new Test_Bounded_WString_Sequence); + if (opt->invoke_type () == Options::SII) + retstatus = client->run_sii_test (); + else + retstatus = client->run_dii_test (); + delete client; + } + break; case Options::TEST_VAR_STRUCT: { Param_Test_Client<Test_Var_Struct> *client = new diff --git a/TAO/tests/Param_Test/helper.cpp b/TAO/tests/Param_Test/helper.cpp index ef81f429734..f9a6947289d 100644 --- a/TAO/tests/Param_Test/helper.cpp +++ b/TAO/tests/Param_Test/helper.cpp @@ -65,6 +65,34 @@ Generator::gen_string (int max_length) i++; } } + + buf[i] = 0; + return buf; +} + +CORBA::WChar * +Generator::gen_wstring (void) +{ + return gen_wstring (TEST_BUFSIZE); +} + +CORBA::WChar * +Generator::gen_wstring (int max_length) +{ + CORBA::ULong len = (CORBA::ULong) (::ACE_OS::rand () % max_length); + CORBA::WChar *buf = CORBA::wstring_alloc (len); + CORBA::ULong i = 0; + + while (i < len) + { + CORBA::WChar wc = ACE_OS::rand () % ACE_WCHAR_MAX; + if (wc) + { + buf[i] = wc; + i++; + } + } + buf[i] = 0; return buf; } diff --git a/TAO/tests/Param_Test/helper.h b/TAO/tests/Param_Test/helper.h index fb128fbfb2d..76e6453b3d4 100644 --- a/TAO/tests/Param_Test/helper.h +++ b/TAO/tests/Param_Test/helper.h @@ -33,14 +33,10 @@ public: CORBA::Short gen_short (void); CORBA::Long gen_long (void); -#if 0 - CORBA::Char gen_char (void); - CORBA::Octet gen_octet (void); - CORBA::Float gen_float (void); - CORBA::Double gen_double (void); -#endif CORBA::String gen_string (void); CORBA::String gen_string (int maxlength); + CORBA::WString gen_wstring (void); + CORBA::WString gen_wstring (int maxlength); const Param_Test::Fixed_Struct gen_fixed_struct (void); const Param_Test::Step gen_step (void); private: diff --git a/TAO/tests/Param_Test/options.cpp b/TAO/tests/Param_Test/options.cpp index 62368442156..59a117c549e 100644 --- a/TAO/tests/Param_Test/options.cpp +++ b/TAO/tests/Param_Test/options.cpp @@ -93,14 +93,22 @@ Options::parse_args (int argc, char **argv) this->test_type_ = Options::TEST_ULONGLONG; else if (!ACE_OS::strcmp (get_opts.optarg, "ubstring")) this->test_type_ = Options::TEST_UB_STRING; + else if (!ACE_OS::strcmp (get_opts.optarg, "ubwstring")) + this->test_type_ = Options::TEST_UB_WSTRING; else if (!ACE_OS::strcmp (get_opts.optarg, "bdstring")) this->test_type_ = Options::TEST_BD_STRING; + else if (!ACE_OS::strcmp (get_opts.optarg, "bdwstring")) + this->test_type_ = Options::TEST_BD_WSTRING; else if (!ACE_OS::strcmp (get_opts.optarg, "fixed_struct")) this->test_type_ = Options::TEST_FIXED_STRUCT; else if (!ACE_OS::strcmp (get_opts.optarg, "ub_strseq")) this->test_type_ = Options::TEST_UB_STRING_SEQUENCE; else if (!ACE_OS::strcmp (get_opts.optarg, "bd_strseq")) this->test_type_ = Options::TEST_BD_STRING_SEQUENCE; + else if (!ACE_OS::strcmp (get_opts.optarg, "ub_wstrseq")) + this->test_type_ = Options::TEST_UB_WSTRING_SEQUENCE; + else if (!ACE_OS::strcmp (get_opts.optarg, "bd_wstrseq")) + this->test_type_ = Options::TEST_BD_WSTRING_SEQUENCE; else if (!ACE_OS::strcmp (get_opts.optarg, "var_struct")) this->test_type_ = Options::TEST_VAR_STRUCT; else if (!ACE_OS::strcmp (get_opts.optarg, "nested_struct")) diff --git a/TAO/tests/Param_Test/options.h b/TAO/tests/Param_Test/options.h index 015fc78d8c8..0128a9fe0ed 100644 --- a/TAO/tests/Param_Test/options.h +++ b/TAO/tests/Param_Test/options.h @@ -37,10 +37,14 @@ public: TEST_SHORT, TEST_ULONGLONG, TEST_UB_STRING, + TEST_UB_WSTRING, TEST_BD_STRING, + TEST_BD_WSTRING, TEST_FIXED_STRUCT, TEST_UB_STRING_SEQUENCE, TEST_BD_STRING_SEQUENCE, + TEST_UB_WSTRING_SEQUENCE, + TEST_BD_WSTRING_SEQUENCE, TEST_VAR_STRUCT, TEST_NESTED_STRUCT, TEST_RECURSIVE_STRUCT, diff --git a/TAO/tests/Param_Test/param_test.idl b/TAO/tests/Param_Test/param_test.idl index 03ca97d8990..1ff5a5feaa3 100644 --- a/TAO/tests/Param_Test/param_test.idl +++ b/TAO/tests/Param_Test/param_test.idl @@ -54,11 +54,23 @@ interface Param_Test inout string s2, out string s3); + // strings bounded typedef string<128> short_string; short_string test_bounded_string (in short_string s1, inout short_string s2, out short_string s3); + // wstrings unbounded + wstring test_unbounded_wstring (in wstring ws1, + inout wstring ws2, + out wstring ws3); + + // wstrings bounded + typedef wstring<128> short_wstring; + short_wstring test_bounded_wstring (in short_wstring ws1, + inout short_wstring ws2, + out short_wstring ws3); + // structures (fixed size) struct Fixed_Struct { @@ -127,6 +139,16 @@ interface Param_Test inout Bounded_StrSeq s2, out Bounded_StrSeq s3); + typedef sequence<wstring> WStrSeq; + WStrSeq test_wstrseq (in WStrSeq ws1, + inout WStrSeq ws2, + out WStrSeq ws3); + + typedef sequence<wstring,32> Bounded_WStrSeq; + Bounded_WStrSeq test_bounded_wstrseq (in Bounded_WStrSeq ws1, + inout Bounded_WStrSeq ws2, + out Bounded_WStrSeq ws3); + typedef sequence<Fixed_Struct> StructSeq; StructSeq test_struct_sequence (in StructSeq s1, inout StructSeq s2, diff --git a/TAO/tests/Param_Test/param_test_i.cpp b/TAO/tests/Param_Test/param_test_i.cpp index 135712b9759..414b1f43bb8 100644 --- a/TAO/tests/Param_Test/param_test_i.cpp +++ b/TAO/tests/Param_Test/param_test_i.cpp @@ -133,6 +133,52 @@ Param_Test_i::test_bounded_string (const char *s1, return retstr; } +// test unbounded strings. For return and out types, we return duplicates of +// the in string. For the inout, we append the same string to itself and send +// it back +CORBA::WChar * +Param_Test_i::test_unbounded_wstring (const CORBA::WChar *ws1, + CORBA::WChar *&ws2, + CORBA::WString_out ws3, + CORBA::Environment &) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + CORBA::WChar *retwstr = CORBA::wstring_dup (ws1); + ws3 = CORBA::wstring_dup (ws1); + CORBA::ULong len = ACE_OS::wslen (ws2); + CORBA::WChar *tmp = CORBA::wstring_alloc (2*len); + for (CORBA::ULong i = 0; i < 2; i++) + for (CORBA::ULong j = 0; j < len; j++) + tmp[j + i*len] = ws2[j]; + tmp[2*len] = 0; + CORBA::wstring_free (ws2); + ws2 = tmp; + return retwstr; +} + +// test bounded strings. For return and out types, we return duplicates of +// the in string. For the inout, we append the same string to itself and send +// it back +CORBA::WChar * +Param_Test_i::test_bounded_wstring (const CORBA::WChar *ws1, + CORBA::WChar *&ws2, + CORBA::WString_out ws3, + CORBA::Environment &) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + CORBA::WChar *retwstr = CORBA::wstring_dup (ws1); + ws3 = CORBA::wstring_dup (ws1); + CORBA::ULong len = ACE_OS::wslen (ws2); + CORBA::WChar *tmp = CORBA::wstring_alloc (2*len); + for (CORBA::ULong i = 0; i < 2; i++) + for (CORBA::ULong j = 0; j < len; j++) + tmp[j + i*len] = ws2[j]; + tmp[2*len] = 0; + CORBA::wstring_free (ws2); + ws2 = tmp; + return retwstr; +} + // test for fixed structures. Just copy the in parameter into all the others Param_Test::Fixed_Struct Param_Test_i::test_fixed_struct (const Param_Test::Fixed_Struct &s1, @@ -277,6 +323,48 @@ Param_Test_i::test_bounded_strseq (const Param_Test::Bounded_StrSeq & s1, return ret; } +Param_Test::WStrSeq * +Param_Test_i::test_wstrseq (const Param_Test::WStrSeq &ws1, + Param_Test::WStrSeq &ws2, + Param_Test::WStrSeq_out ws3, + CORBA::Environment &) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // we copy the "in" sequences into all the inout, out and return sequences. + + Param_Test::WStrSeq + *ret = new Param_Test::WStrSeq, + *out = new Param_Test::WStrSeq; + + // now copy all elements of s1 into the others using the assignment operator + ws2 = ws1; + *out = ws1; + *ret = ws1; + ws3 = out; + return ret; +} + +Param_Test::Bounded_WStrSeq * +Param_Test_i::test_bounded_wstrseq (const Param_Test::Bounded_WStrSeq & ws1, + Param_Test::Bounded_WStrSeq & ws2, + Param_Test::Bounded_WStrSeq_out ws3, + CORBA::Environment &) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // we copy the "in" sequences into all the inout, out and return sequences. + + Param_Test::Bounded_WStrSeq + *ret = new Param_Test::Bounded_WStrSeq, + *out = new Param_Test::Bounded_WStrSeq; + + // now copy all elements of s1 into the others using the assignment operator + ws2 = ws1; + *out = ws1; + *ret = ws1; + ws3 = out; + return ret; +} + // test for struct sequences Param_Test::StructSeq * Param_Test_i::test_struct_sequence (const Param_Test::StructSeq &s1, diff --git a/TAO/tests/Param_Test/param_test_i.h b/TAO/tests/Param_Test/param_test_i.h index 41d0e0609c2..a94d7cc18a7 100644 --- a/TAO/tests/Param_Test/param_test_i.h +++ b/TAO/tests/Param_Test/param_test_i.h @@ -88,6 +88,20 @@ public: ACE_THROW_SPEC ((CORBA::SystemException)); // test for bounded strings + virtual CORBA::WChar *test_unbounded_wstring (const CORBA::WChar *ws1, + CORBA::WChar *&ws2, + CORBA::WString_out ws3, + CORBA::Environment &env) + ACE_THROW_SPEC ((CORBA::SystemException)); + // test for unbounded wstrings + + virtual CORBA::WChar *test_bounded_wstring (const CORBA::WChar *ws1, + CORBA::WChar *&ws2, + CORBA::WString_out ws3, + CORBA::Environment &env) + ACE_THROW_SPEC ((CORBA::SystemException)); + // test for bounded wstrings + virtual Param_Test::Fixed_Struct test_fixed_struct (const Param_Test::Fixed_Struct &s1, Param_Test::Fixed_Struct &s2, @@ -133,6 +147,18 @@ public: Param_Test::Bounded_StrSeq_out s3, CORBA::Environment &env) ACE_THROW_SPEC ((CORBA::SystemException)); + virtual Param_Test::WStrSeq * test_wstrseq ( + const Param_Test::WStrSeq & ws1, + Param_Test::WStrSeq & ws2, + Param_Test::WStrSeq_out ws3, + CORBA::Environment &env) + ACE_THROW_SPEC ((CORBA::SystemException)); + virtual Param_Test::Bounded_WStrSeq * test_bounded_wstrseq ( + const Param_Test::Bounded_WStrSeq & ws1, + Param_Test::Bounded_WStrSeq & ws2, + Param_Test::Bounded_WStrSeq_out ws3, + CORBA::Environment &env) + ACE_THROW_SPEC ((CORBA::SystemException)); virtual Param_Test::StructSeq * test_struct_sequence ( const Param_Test::StructSeq & s1, Param_Test::StructSeq & s2, diff --git a/TAO/tests/Param_Test/run_test.pl b/TAO/tests/Param_Test/run_test.pl index 780906e3949..d1f491b113f 100755 --- a/TAO/tests/Param_Test/run_test.pl +++ b/TAO/tests/Param_Test/run_test.pl @@ -56,8 +56,9 @@ sub run_test # Parse the arguments -@types = ("short", "ulonglong", "ubstring", "bdstring", "fixed_struct", - "ub_strseq", "bd_strseq", +@types = ("short", "ulonglong", "ubstring", "bdstring", + "ubwstring", "bdwstring", "fixed_struct", + "ub_strseq", "bd_strseq", "ub_wstrseq", bd_wstrseq", "var_struct", "nested_struct", "recursive_struct", "ub_struct_seq", "bd_struct_seq", "any", "objref", "objref_sequence", "objref_struct", diff --git a/TAO/tests/Param_Test/tests.h b/TAO/tests/Param_Test/tests.h index d4784748e74..feb3b7daea0 100644 --- a/TAO/tests/Param_Test/tests.h +++ b/TAO/tests/Param_Test/tests.h @@ -23,7 +23,9 @@ #include "bd_long_seq.h" #include "bd_short_seq.h" #include "bd_str_seq.h" +#include "bd_wstr_seq.h" #include "bd_string.h" +#include "bd_wstring.h" #include "bd_struct_seq.h" #include "fixed_array.h" #include "fixed_struct.h" @@ -39,7 +41,9 @@ #include "ub_objref_seq.h" #include "ub_short_seq.h" #include "ub_str_seq.h" +#include "ub_wstr_seq.h" #include "ub_string.h" +#include "ub_wstring.h" #include "ub_struct_seq.h" #include "var_array.h" #include "var_struct.h" diff --git a/TAO/tests/Param_Test/ub_wstr_seq.cpp b/TAO/tests/Param_Test/ub_wstr_seq.cpp new file mode 100644 index 00000000000..4cf3b33cf77 --- /dev/null +++ b/TAO/tests/Param_Test/ub_wstr_seq.cpp @@ -0,0 +1,209 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/Param_Test +// +// = FILENAME +// ub_wstr_seq.cpp +// +// = DESCRIPTION +// tests unbounded wide string sequences +// +// = AUTHORS +// Jeff Parsons +// +// ============================================================================ + +#include "helper.h" +#include "ub_wstr_seq.h" + +// ************************************************************************ +// Test_WString_Sequence +// ************************************************************************ + +Test_WString_Sequence::Test_WString_Sequence (void) + : opname_ (CORBA::string_dup ("test_wstrseq")), + in_ (new Param_Test::WStrSeq), + inout_ (new Param_Test::WStrSeq), + out_ (new Param_Test::WStrSeq), + ret_ (new Param_Test::WStrSeq) +{ +} + +Test_WString_Sequence::~Test_WString_Sequence (void) +{ + CORBA::string_free (this->opname_); + this->opname_ = 0; +} + +const char * +Test_WString_Sequence::opname (void) const +{ + return this->opname_; +} + +void +Test_WString_Sequence::dii_req_invoke (CORBA::Request *req, + CORBA::Environment &ACE_TRY_ENV) +{ + req->invoke (ACE_TRY_ENV); +} + +int +Test_WString_Sequence::init_parameters (Param_Test_ptr , + CORBA::Environment &) +{ + Generator *gen = GENERATOR::instance (); // value generator + + const CORBA::WChar *choiceList[3]; + CORBA::ULong i = 0; + + for (i = 0; i < 3; i++) + { + choiceList[i] = gen->gen_wstring (); + } + + CORBA::ULong len = sizeof(choiceList)/sizeof(CORBA::WChar *) - 1; + + // set the length of the sequences + this->in_->length (len); + this->inout_->length (len); + + // now set each individual element + for (i = 0; i < this->in_->length (); i++) + { + this->in_[i] = choiceList[i]; + this->inout_[i] = choiceList[i+1]; + } + return 0; +} + +int +Test_WString_Sequence::reset_parameters (void) +{ + this->inout_ = new Param_Test::WStrSeq; // delete the previous ones + this->out_ = new Param_Test::WStrSeq; + this->ret_ = new Param_Test::WStrSeq; + return 0; +} + +int +Test_WString_Sequence::run_sii_test (Param_Test_ptr objref, + CORBA::Environment &ACE_TRY_ENV) +{ + ACE_TRY + { + Param_Test::WStrSeq_out out (this->out_.out ()); + + this->ret_ = objref->test_wstrseq (this->in_.in (), + this->inout_.inout (), + out, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + return 0; + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Test_WString_Sequence::run_sii_test\n"); + + } + ACE_ENDTRY; + return -1; +} + +int +Test_WString_Sequence::add_args (CORBA::NVList_ptr param_list, + CORBA::NVList_ptr retval, + CORBA::Environment &ACE_TRY_ENV) +{ + ACE_TRY + { + CORBA::Any in_arg (Param_Test::_tc_WStrSeq, + (void *) &this->in_.in (), + 0); + + CORBA::Any inout_arg (Param_Test::_tc_WStrSeq, + &this->inout_.inout (), + 0); + + CORBA::Any out_arg (Param_Test::_tc_WStrSeq, + &this->out_.inout (), // .out () causes crash + 0); + + // add parameters + param_list->add_value ("ws1", + in_arg, + CORBA::ARG_IN, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + param_list->add_value ("ws2", + inout_arg, + CORBA::ARG_INOUT, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + param_list->add_value ("ws3", + out_arg, + CORBA::ARG_OUT, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + CORBA::NamedValue *item = retval->item (0, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + item->value ()->replace (Param_Test::_tc_WStrSeq, + &this->ret_.inout (), + 0, // does not own + ACE_TRY_ENV); + ACE_TRY_CHECK; + + return 0; + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Test_WString_Sequence::add_args\n"); + + } + ACE_ENDTRY; + return -1; +} + +CORBA::Boolean +Test_WString_Sequence::check_validity (void) +{ + CORBA::Boolean flag = 0; + if ((this->in_->length () == this->inout_->length ()) && + (this->in_->length () == this->out_->length ()) && + (this->in_->length () == this->ret_->length ())) + { + flag = 1; // assume all are equal + // lengths are same. Now compare the contents + for (CORBA::ULong i=0; i < this->in_->length () && flag; i++) + { + if (ACE_OS::strcmp (this->in_[i], this->inout_[i]) || + ACE_OS::strcmp (this->in_[i], this->out_[i]) || + ACE_OS::strcmp (this->in_[i], this->ret_[i])) + // not equal + flag = 0; + } + } + return flag; +} + +CORBA::Boolean +Test_WString_Sequence::check_validity (CORBA::Request_ptr ) +{ + return this->check_validity (); +} + +void +Test_WString_Sequence::print_values (void) +{ +} diff --git a/TAO/tests/Param_Test/ub_wstr_seq.h b/TAO/tests/Param_Test/ub_wstr_seq.h new file mode 100644 index 00000000000..d91fd0380d2 --- /dev/null +++ b/TAO/tests/Param_Test/ub_wstr_seq.h @@ -0,0 +1,86 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/Param_Test +// +// = FILENAME +// ub_wstr_seq.h +// +// = DESCRIPTION +// Tests sequences of wide strings +// +// = AUTHORS +// Jeff Parsons +// +// ============================================================================ + +#ifndef PARAM_TEST_UNBOUNDED_WSTRING_SEQUENCE_H +#define PARAM_TEST_UNBOUNDED_WSTRING_SEQUENCE_H + +#include "param_testCli.h" + +// =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* +// test typedefed sequences (in our case, sequences of wstrings) +// =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* + +class Test_WString_Sequence +{ +public: + Test_WString_Sequence (void); + // ctor + + ~Test_WString_Sequence (void); + // dtor + + int run_sii_test (Param_Test_ptr objref, + CORBA::Environment &env); + // run the SII test + + int add_args (CORBA::NVList_ptr nvlist, + CORBA::NVList_ptr retval, + CORBA::Environment &env); + // add args to NVList for DII + + const char *opname (void) const; + // return operation name + + int init_parameters (Param_Test_ptr objref, + CORBA::Environment &env); + // set values for parameters + + int reset_parameters (void); + // reset values for CORBA + + CORBA::Boolean check_validity (void); + // check if results are valid + + CORBA::Boolean check_validity (CORBA::Request_ptr req); + // check if results are valid. This is used for DII results + + void print_values (void); + // print all the values + + void dii_req_invoke (CORBA::Request *, + CORBA::Environment &); + // invoke DII request with appropriate exception handling. + +private: + char *opname_; + // operation name + + Param_Test::WStrSeq_var in_; + // in parameter + + Param_Test::WStrSeq_var inout_; + // inout parameter + + Param_Test::WStrSeq_var out_; + // out parameter + + Param_Test::WStrSeq_var ret_; + // return value +}; + +#endif /* PARAM_TEST_UNBOUNDED_WSTRING_SEQUENCE_H */ diff --git a/TAO/tests/Param_Test/ub_wstring.cpp b/TAO/tests/Param_Test/ub_wstring.cpp new file mode 100644 index 00000000000..f57fa0ecc2f --- /dev/null +++ b/TAO/tests/Param_Test/ub_wstring.cpp @@ -0,0 +1,211 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/Param_Test +// +// = FILENAME +// ub_wstring.cpp +// +// = DESCRIPTION +// tests unbounded wide strings +// +// = AUTHORS +// Jeff Parsons <parsons@cs.wustl.edu> +// +// ============================================================================ + +#include "helper.h" +#include "ub_wstring.h" + +// ************************************************************************ +// Test_Unbounded_WString +// ************************************************************************ + +Test_Unbounded_WString::Test_Unbounded_WString (void) + : opname_ (CORBA::string_dup ("test_unbounded_wstring")), + in_ (0), + inout_ (0), + out_ (0), + ret_ (0) +{ +} + +Test_Unbounded_WString::~Test_Unbounded_WString (void) +{ + CORBA::string_free (this->opname_); + CORBA::wstring_free (this->in_); + CORBA::wstring_free (this->inout_); + CORBA::wstring_free (this->out_); + CORBA::wstring_free (this->ret_); + this->opname_ = 0; + this->in_ = 0; + this->inout_ = 0; + this->out_ = 0; + this->ret_ = 0; +} + +const char * +Test_Unbounded_WString::opname (void) const +{ + return this->opname_; +} + +void +Test_Unbounded_WString::dii_req_invoke (CORBA::Request *req, + CORBA::Environment &ACE_TRY_ENV) +{ + req->invoke (ACE_TRY_ENV); +} + +int +Test_Unbounded_WString::init_parameters (Param_Test_ptr , + CORBA::Environment &) +{ + Generator *gen = GENERATOR::instance (); // value generator + + + // release any previously occupied values + CORBA::wstring_free (this->in_); + CORBA::wstring_free (this->inout_); + CORBA::wstring_free (this->out_); + CORBA::wstring_free (this->ret_); + this->in_ = 0; + this->inout_ = 0; + this->out_ = 0; + this->ret_ = 0; + + this->in_ = gen->gen_wstring (); + this->inout_ = CORBA::wstring_dup (this->in_); + return 0; +} + +int +Test_Unbounded_WString::reset_parameters (void) +{ + // release any previously occupied values + CORBA::wstring_free (this->inout_); + CORBA::wstring_free (this->out_); + CORBA::wstring_free (this->ret_); + this->inout_ = 0; + this->out_ = 0; + this->ret_ = 0; + + this->inout_ = CORBA::wstring_dup (this->in_); + return 0; +} + +int +Test_Unbounded_WString::run_sii_test (Param_Test_ptr objref, + CORBA::Environment &ACE_TRY_ENV) +{ + ACE_TRY + { + CORBA::WString_out str_out (this->out_); + + this->ret_ = objref->test_unbounded_wstring (this->in_, + this->inout_, + str_out, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + return 0; + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Test_Unbounded_WString::run_sii_test\n"); + + } + ACE_ENDTRY; + return -1; +} + +int +Test_Unbounded_WString::add_args (CORBA::NVList_ptr param_list, + CORBA::NVList_ptr retval, + CORBA::Environment &ACE_TRY_ENV) +{ + ACE_TRY + { + CORBA::Any in_arg (CORBA::_tc_wstring, + &this->in_, + 0); + + CORBA::Any inout_arg (CORBA::_tc_wstring, + &this->inout_, + 0); + + CORBA::Any out_arg (CORBA::_tc_wstring, + &this->out_, + 0); + + // add parameters + param_list->add_value ("ws1", + in_arg, + CORBA::ARG_IN, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + param_list->add_value ("ws2", + inout_arg, + CORBA::ARG_INOUT, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + param_list->add_value ("ws3", + out_arg, + CORBA::ARG_OUT, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + CORBA::NamedValue *item = retval->item (0, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + item->value ()->replace (CORBA::_tc_wstring, + &this->ret_, + 0, // does not own + ACE_TRY_ENV); + ACE_TRY_CHECK; + + return 0; + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Test_Unbounded_WString::add_args\n"); + + } + ACE_ENDTRY; + return -1; +} + +CORBA::Boolean +Test_Unbounded_WString::check_validity (void) +{ + CORBA::ULong len = ACE_OS::wslen (this->in_); + + if (!ACE_OS::wscmp (this->in_, this->out_) && + !ACE_OS::wscmp (this->in_, this->ret_) && + ACE_OS::wslen (this->inout_) == 2*len && + !ACE_OS::wsncmp (this->in_, this->inout_, len) && + !ACE_OS::wsncmp (this->in_, &this->inout_[len], len)) + return 1; + + return 0; // otherwise +} + +CORBA::Boolean +Test_Unbounded_WString::check_validity (CORBA::Request_ptr ) +{ + // No need to retrieve anything because, for all the args and + // the return, we provided the memory and we own it. + return this->check_validity (); +} + +void +Test_Unbounded_WString::print_values (void) +{ +} diff --git a/TAO/tests/Param_Test/ub_wstring.h b/TAO/tests/Param_Test/ub_wstring.h new file mode 100644 index 00000000000..7b7c37d27a0 --- /dev/null +++ b/TAO/tests/Param_Test/ub_wstring.h @@ -0,0 +1,89 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/Param_Test +// +// = FILENAME +// ub_wstring.h +// +// = DESCRIPTION +// Tests unbounded wide string +// +// = AUTHORS +// Jeff Parsons <parsons@cs.wustl.edu> +// +// ============================================================================ + +#ifndef PARAM_TEST_UNBOUNDED_WSTRING_H +#define PARAM_TEST_UNBOUNDED_WSTRING_H + +#include "param_testCli.h" + +// =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* +// test unbounded wide strings +// =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* +class Test_Unbounded_WString +{ +public: + Test_Unbounded_WString (void); + // ctor + + ~Test_Unbounded_WString (void); + // dtor + + int run_sii_test (Param_Test_ptr objref, + CORBA::Environment &env); + // run the SII test + + int add_args (CORBA::NVList_ptr nvlist, + CORBA::NVList_ptr retval, + CORBA::Environment &env); + // add args to NVList for DII +/* + int add_args (CORBA::Request_ptr &req, + CORBA::Environment &env); + // add args to DII request using << operator +*/ + const char *opname (void) const; + // return operation name + + int init_parameters (Param_Test_ptr objref, + CORBA::Environment &env); + // set values for parameters + + int reset_parameters (void); + // reset values for CORBA + + CORBA::Boolean check_validity (void); + // check if results are valid + + CORBA::Boolean check_validity (CORBA::Request_ptr req); + // check if results are valid. This is used for DII results + + void print_values (void); + // print all the values + + void dii_req_invoke (CORBA::Request *, + CORBA::Environment &); + // invoke DII request with appropriate exception handling. + +private: + char *opname_; + // operation name + + CORBA::WChar *in_; + // in parameter + + CORBA::WChar *inout_; + // inout parameter + + CORBA::WChar *out_; + // out parameter + + CORBA::WChar *ret_; + // return value +}; + +#endif /* PARAM_TEST_UNBOUNDED_WSTRING_H */ |