Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / interop-tests / wchar / wchar_reference.cpp
blobc3ac52fa6b9787b6cd45b03af8c0150562cfa3be
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file wchar_reference.cpp
7 * C++ reference data for testing interoperability with wchars. This is
8 * linked into both clients and servers so that both sides have common
9 * values for testing what is received or sent.
11 * @author Phil Mesnier <mesnier_p@ociweb.com>
13 //=============================================================================
15 #include "wchar_reference.h"
16 #include "ace/Log_Msg.h"
17 #include "ace/OS_NS_string.h"
19 #if defined (ACE_HAS_WCHAR) || defined (ACE_HAS_XPG4_MULTIBYTE_CHAR)
21 ACE_OS::WChar
22 wchar_reference::ref_wchar[NUM_KEYS] =
23 {1234};
25 const ACE_OS::WChar *
26 wchar_reference::ref_wstring[NUM_KEYS] =
27 {L"have a nice day"};
29 ACE_OS::WChar
30 wchar_reference::ref_warray[NUM_KEYS][10] =
31 { {L'a',L'A',L'!',L'1',L'4',L'[',L'?',L'%',L'X',L'E'} };
33 const ACE_OS::WChar *
34 wchar_reference::ref_except[NUM_KEYS] =
35 {L"TEST EXCEPTION"};
37 wchar_reference::wchar_reference(int v)
38 : verbose_ (v)
42 void
43 wchar_reference::set_verbose(int v)
45 this->verbose_ = v;
48 ACE_OS::WChar
49 wchar_reference::get_wchar (short key)
51 return wchar_reference::ref_wchar[key];
54 const ACE_OS::WChar *
55 wchar_reference::get_wstring (short key)
57 return wchar_reference::ref_wstring[key];
60 ACE_OS::WChar *
61 wchar_reference::get_warray (short key)
63 return wchar_reference::ref_warray[key];
66 void
67 wchar_reference::assign_warray (short key,
68 ACE_OS::WChar *warray)
70 ACE_OS::memcpy(warray,
71 wchar_reference::ref_warray[key],
72 10*(sizeof(ACE_OS::WChar))
76 const ACE_OS::WChar *
77 wchar_reference::get_except (short key)
79 return wchar_reference::ref_except[key];
82 int
83 wchar_reference::match_wchar (short key, ACE_OS::WChar test)
85 if (verbose_)
86 ACE_DEBUG ((LM_DEBUG,
87 ACE_TEXT("match_wchar, expecting %x, got %x for key %d\n"),
88 wchar_reference::ref_wchar[key],test,key));
89 return wchar_reference::ref_wchar[key] == test;
92 int
93 wchar_reference::match_wstring (short key, const ACE_OS::WChar *test)
95 if (key == -1)
97 if (verbose_)
98 ACE_DEBUG ((LM_DEBUG,
99 ACE_TEXT("match_wstring: expecting nul string, ")
100 ACE_TEXT("got string length %d\n"),
101 ACE_OS::strlen (test)));
102 return (ACE_OS::strlen (test) == 0);
104 if (verbose_)
105 ACE_DEBUG ((LM_DEBUG,
106 ACE_TEXT("match_wstring: expecting %W, got %W for key %d\n"),
107 wchar_reference::ref_wstring[key],test,key));
108 return ACE_OS::strcmp(wchar_reference::ref_wstring[key],test) == 0;
112 wchar_reference::match_warray (short key, const ACE_OS::WChar *test)
114 if (verbose_)
115 ACE_DEBUG ((LM_DEBUG,
116 ACE_TEXT("match_warray: key %d\n"),key));
117 for (int i = 0; i < 10; i++)
119 if (verbose_)
120 ACE_DEBUG ((LM_DEBUG,
121 ACE_TEXT(" expecting[%d] %x, got %x\n"),
122 i, wchar_reference::ref_warray[key][i],
123 test[i]));
124 if (wchar_reference::ref_warray[key][i] != test[i])
125 return 0;
127 return 1;
131 wchar_reference::match_except(short key, const ACE_OS::WChar *test)
133 if (verbose_)
134 ACE_DEBUG ((LM_DEBUG,
135 ACE_TEXT("match_except: expecting %W, got %W for key %d\n"),
136 wchar_reference::ref_except[key],test,key));
137 return ACE_OS::strcmp(wchar_reference::ref_except[key],test) == 0;
139 #else // ACE_HAS_WCHAR
140 wchar_reference::wchar_reference(int v)
141 : verbose_ (v)
145 void
146 wchar_reference::set_verbose(int v)
148 this->verbose_ = v;
151 ACE_OS::WChar
152 wchar_reference::get_wchar (short )
154 return 0;
157 const ACE_OS::WChar *
158 wchar_reference::get_wstring (short )
160 return 0;
163 ACE_OS::WChar *
164 wchar_reference::get_warray (short )
166 return 0;
169 void
170 wchar_reference::assign_warray (short ,
171 ACE_OS::WChar *)
175 const ACE_OS::WChar *
176 wchar_reference::get_except (short )
178 return 0;
182 wchar_reference::match_wchar (short , ACE_OS::WChar )
184 return 0;
188 wchar_reference::match_wstring (short , const ACE_OS::WChar *)
190 return 0;
194 wchar_reference::match_warray (short , const ACE_OS::WChar *)
196 return 0;
199 #endif // ACE_HAS_WCHAR