ReactOS  0.4.13-dev-1174-gdff75d7
MultiByteToWideChar.c File Reference
#include "precomp.h"
Include dependency graph for MultiByteToWideChar.c:

Go to the source code of this file.

Classes

struct  ENTRY
 

Macros

#define CP932   932 /* Japanese Shift_JIS (SJIS) codepage */
 
#define MAX_BUFFER   10
 

Typedefs

typedef struct ENTRY ENTRY
 
typedef NTSTATUS(WINAPIRTLGETVERSION) (PRTL_OSVERSIONINFOW)
 

Functions

static void TestEntry (const ENTRY *pEntry)
 
static RTL_OSVERSIONINFOWGetRealOSVersion (void)
 
static BOOL IsWin10Plus (void)
 
static BOOL IsReactOS (void)
 
 START_TEST (MultiByteToWideChar)
 

Variables

static const char UTF8_Japanese [] = "\xE6\x97\xA5\xE6\x9C\xAC\xE8\xAA\x9E"
 
static const char SJIS_Japanese [] = "\x93\xFA\x96\x7B\x8C\xEA"
 
static const ENTRY Entries []
 

Macro Definition Documentation

◆ CP932

#define CP932   932 /* Japanese Shift_JIS (SJIS) codepage */

Definition at line 16 of file MultiByteToWideChar.c.

◆ MAX_BUFFER

#define MAX_BUFFER   10

Definition at line 23 of file MultiByteToWideChar.c.

Typedef Documentation

◆ ENTRY

typedef struct ENTRY ENTRY

◆ RTLGETVERSION

typedef NTSTATUS(WINAPI* RTLGETVERSION) (PRTL_OSVERSIONINFOW)

Definition at line 208 of file MultiByteToWideChar.c.

Function Documentation

◆ GetRealOSVersion()

static RTL_OSVERSIONINFOW* GetRealOSVersion ( void  )
static

Definition at line 210 of file MultiByteToWideChar.c.

211 {
212  static RTL_OSVERSIONINFOW osvi = { 0 };
214  HINSTANCE hNTDLL = LoadLibraryW(L"ntdll.dll");
216  if (hNTDLL)
217  {
218  fn = (RTLGETVERSION)GetProcAddress(hNTDLL, "RtlGetVersion");
219  if (fn)
220  {
221  osvi.dwOSVersionInfoSize = sizeof(osvi);
222  if (fn(&osvi) == STATUS_SUCCESS)
223  {
224  ptr = &osvi;
225  }
226  }
227  FreeLibrary(hNTDLL);
228  }
229  return ptr;
230 }
NTSTATUS(WINAPI * RTLGETVERSION)(PRTL_OSVERSIONINFOW)
OSVERSIONINFO osvi
Definition: ver.c:28
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
static PVOID ptr
Definition: dispmode.c:27
#define LoadLibraryW(x)
Definition: compat.h:404
smooth NULL
Definition: ftsmooth.c:416
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:233
#define FreeLibrary(x)
Definition: compat.h:405
static const WCHAR L[]
Definition: oid.c:1250
#define GetProcAddress(x, y)
Definition: compat.h:410
return STATUS_SUCCESS
Definition: btrfs.c:2966

Referenced by IsWin10Plus().

◆ IsReactOS()

static BOOL IsReactOS ( void  )
static

Definition at line 241 of file MultiByteToWideChar.c.

242 {
243  WCHAR szWinDir[MAX_PATH];
244  GetWindowsDirectoryW(szWinDir, _countof(szWinDir));
245  return (wcsstr(szWinDir, L"ReactOS") != NULL);
246 }
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
#define _countof(array)
Definition: fontsub.cpp:30
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2351
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
static const WCHAR L[]
Definition: oid.c:1250

Referenced by START_TEST().

◆ IsWin10Plus()

static BOOL IsWin10Plus ( void  )
static

Definition at line 232 of file MultiByteToWideChar.c.

233 {
235  if (!info)
236  return FALSE;
237 
238  return info->dwMajorVersion >= 10;
239 }
static RTL_OSVERSIONINFOW * GetRealOSVersion(void)

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( MultiByteToWideChar  )

Definition at line 248 of file MultiByteToWideChar.c.

249 {
250  size_t i;
251 
252  if (!IsWin10Plus() && !IsReactOS())
253  {
254  trace("This test is designed for Windows 10+ and ReactOS.\n"
255  "It is expected to report some failures on older Windows versions.\n");
256 #if 0
257  skip("\n");
258  return;
259 #endif
260  }
261 
262  for (i = 0; i < _countof(Entries); ++i)
263  {
264  TestEntry(&Entries[i]);
265  }
266 }
static BOOL IsReactOS(void)
#define _countof(array)
Definition: fontsub.cpp:30
static void TestEntry(const ENTRY *pEntry)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define trace
Definition: atltest.h:70
#define skip(...)
Definition: atltest.h:64
static BOOL IsWin10Plus(void)
static const ENTRY Entries[]

◆ TestEntry()

static void TestEntry ( const ENTRY pEntry)
static

Definition at line 150 of file MultiByteToWideChar.c.

151 {
152  int ret, i;
154  DWORD Error;
155 
156  FillMemory(Buffer, sizeof(Buffer), 0x7F);
157  SetLastError(0xBEAF);
158 
159  if (pEntry->DestLen == 0)
160  {
161  /* dest is NULL */
162  ret = MultiByteToWideChar(pEntry->CodePage, pEntry->Flags, pEntry->Src,
163  pEntry->SrcLen, NULL, 0);
164  }
165  else
166  {
167  ok(pEntry->DestLen >= pEntry->CheckLen - 1,
168  "Line %d: DestLen was shorter than (CheckLen - 1)\n", pEntry->LineNo);
169 
170  if (pEntry->SamePointer)
171  {
172  /* src ptr == dest ptr */
173  ret = MultiByteToWideChar(pEntry->CodePage, pEntry->Flags,
174  (const char *)Buffer, pEntry->SrcLen,
175  Buffer, pEntry->DestLen);
176  }
177  else
178  {
179  /* src ptr != dest ptr */
180  ret = MultiByteToWideChar(pEntry->CodePage, pEntry->Flags,
181  pEntry->Src, pEntry->SrcLen,
182  Buffer, pEntry->DestLen);
183  }
184  }
185 
186  Error = GetLastError();
187 
188  /* check ret */
189  ok(ret == pEntry->Return, "Line %d: ret expected %d, got %d\n",
190  pEntry->LineNo, pEntry->Return, ret);
191 
192  /* check error code */
193  ok(Error == pEntry->Error,
194  "Line %d: Wrong last error. Expected %lu, got %lu\n",
195  pEntry->LineNo, pEntry->Error, Error);
196 
197  if (pEntry->DestLen)
198  {
199  /* check buffer */
200  for (i = 0; i < pEntry->CheckLen; ++i)
201  {
202  ok(Buffer[i] == pEntry->CheckDest[i], "Line %d: Buffer[%d] expected %d, got %d\n",
203  pEntry->LineNo, i, pEntry->CheckDest[i], Buffer[i]);
204  }
205  }
206 }
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
smooth NULL
Definition: ftsmooth.c:416
WCHAR CheckDest[MAX_BUFFER]
Definition: bufpool.h:45
const char * Src
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define FillMemory(BUF, SIZ, MASK)
Definition: strucsup.c:31
BOOL Error
Definition: chkdsk.c:66
#define SetLastError(x)
Definition: compat.h:409
int CodePage
int ret
#define ok(value,...)
Definition: atltest.h:57
BOOL SamePointer
#define MultiByteToWideChar
Definition: compat.h:100
#define MAX_BUFFER

Referenced by DriverEntry(), DriverIoControl(), FindTest(), ListTests(), and START_TEST().

Variable Documentation

◆ Entries

const ENTRY Entries[]
static

Definition at line 41 of file MultiByteToWideChar.c.

Referenced by START_TEST().

◆ SJIS_Japanese

const char SJIS_Japanese[] = "\x93\xFA\x96\x7B\x8C\xEA"
static

Definition at line 21 of file MultiByteToWideChar.c.

◆ UTF8_Japanese

const char UTF8_Japanese[] = "\xE6\x97\xA5\xE6\x9C\xAC\xE8\xAA\x9E"
static

Definition at line 19 of file MultiByteToWideChar.c.