3 //=============================================================================
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)
22 wchar_reference::ref_wchar
[NUM_KEYS
] =
26 wchar_reference::ref_wstring
[NUM_KEYS
] =
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'} };
34 wchar_reference::ref_except
[NUM_KEYS
] =
37 wchar_reference::wchar_reference(int v
)
43 wchar_reference::set_verbose(int v
)
49 wchar_reference::get_wchar (short key
)
51 return wchar_reference::ref_wchar
[key
];
55 wchar_reference::get_wstring (short key
)
57 return wchar_reference::ref_wstring
[key
];
61 wchar_reference::get_warray (short key
)
63 return wchar_reference::ref_warray
[key
];
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
))
77 wchar_reference::get_except (short key
)
79 return wchar_reference::ref_except
[key
];
83 wchar_reference::match_wchar (short key
, ACE_OS::WChar test
)
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
;
93 wchar_reference::match_wstring (short key
, const ACE_OS::WChar
*test
)
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);
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
)
115 ACE_DEBUG ((LM_DEBUG
,
116 ACE_TEXT("match_warray: key %d\n"),key
));
117 for (int i
= 0; i
< 10; i
++)
120 ACE_DEBUG ((LM_DEBUG
,
121 ACE_TEXT(" expecting[%d] %x, got %x\n"),
122 i
, wchar_reference::ref_warray
[key
][i
],
124 if (wchar_reference::ref_warray
[key
][i
] != test
[i
])
131 wchar_reference::match_except(short key
, const ACE_OS::WChar
*test
)
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
)
146 wchar_reference::set_verbose(int v
)
152 wchar_reference::get_wchar (short )
157 const ACE_OS::WChar
*
158 wchar_reference::get_wstring (short )
164 wchar_reference::get_warray (short )
170 wchar_reference::assign_warray (short ,
175 const ACE_OS::WChar
*
176 wchar_reference::get_except (short )
182 wchar_reference::match_wchar (short , ACE_OS::WChar
)
188 wchar_reference::match_wstring (short , const ACE_OS::WChar
*)
194 wchar_reference::match_warray (short , const ACE_OS::WChar
*)
199 #endif // ACE_HAS_WCHAR