ReactOS  0.4.14-dev-337-gf981a68
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 220 of file MultiByteToWideChar.c.

Function Documentation

◆ GetRealOSVersion()

static RTL_OSVERSIONINFOW* GetRealOSVersion ( void  )
static

Definition at line 222 of file MultiByteToWideChar.c.

223 {
224  static RTL_OSVERSIONINFOW osvi = { 0 };
226  HINSTANCE hNTDLL = LoadLibraryW(L"ntdll.dll");
228  if (hNTDLL)
229  {
230  fn = (RTLGETVERSION)GetProcAddress(hNTDLL, "RtlGetVersion");
231  if (fn)
232  {
233  osvi.dwOSVersionInfoSize = sizeof(osvi);
234  if (fn(&osvi) == STATUS_SUCCESS)
235  {
236  ptr = &osvi;
237  }
238  }
239  FreeLibrary(hNTDLL);
240  }
241  return ptr;
242 }
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:412
smooth NULL
Definition: ftsmooth.c:416
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:233
#define FreeLibrary(x)
Definition: compat.h:413
static const WCHAR L[]
Definition: oid.c:1250
#define GetProcAddress(x, y)
Definition: compat.h:418
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by IsWin10Plus().

◆ IsReactOS()

static BOOL IsReactOS ( void  )
static

Definition at line 253 of file MultiByteToWideChar.c.

254 {
255  WCHAR szWinDir[MAX_PATH];
256  GetWindowsDirectoryW(szWinDir, _countof(szWinDir));
257  return (wcsstr(szWinDir, L"ReactOS") != NULL);
258 }
_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 244 of file MultiByteToWideChar.c.

245 {
247  if (!info)
248  return FALSE;
249 
250  return info->dwMajorVersion >= 10;
251 }
static RTL_OSVERSIONINFOW * GetRealOSVersion(void)

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( MultiByteToWideChar  )

Definition at line 260 of file MultiByteToWideChar.c.

261 {
262  size_t i;
263 
264  if (!IsWin10Plus() && !IsReactOS())
265  {
266  trace("This test is designed for Windows 10+ and ReactOS.\n"
267  "It is expected to report some failures on older Windows versions.\n");
268 #if 0
269  skip("\n");
270  return;
271 #endif
272  }
273 
274  for (i = 0; i < _countof(Entries); ++i)
275  {
276  TestEntry(&Entries[i]);
277  }
278 }
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 162 of file MultiByteToWideChar.c.

163 {
164  int ret, i;
166  DWORD Error;
167 
168  FillMemory(Buffer, sizeof(Buffer), 0x7F);
169  SetLastError(0xBEAF);
170 
171  if (pEntry->DestLen == 0)
172  {
173  /* dest is NULL */
174  ret = MultiByteToWideChar(pEntry->CodePage, pEntry->Flags, pEntry->Src,
175  pEntry->SrcLen, NULL, 0);
176  }
177  else
178  {
179  ok(pEntry->DestLen >= pEntry->CheckLen - 1,
180  "Line %d: DestLen was shorter than (CheckLen - 1)\n", pEntry->LineNo);
181 
182  if (pEntry->SamePointer)
183  {
184  /* src ptr == dest ptr */
185  ret = MultiByteToWideChar(pEntry->CodePage, pEntry->Flags,
186  (const char *)Buffer, pEntry->SrcLen,
187  Buffer, pEntry->DestLen);
188  }
189  else
190  {
191  /* src ptr != dest ptr */
192  ret = MultiByteToWideChar(pEntry->CodePage, pEntry->Flags,
193  pEntry->Src, pEntry->SrcLen,
194  Buffer, pEntry->DestLen);
195  }
196  }
197 
198  Error = GetLastError();
199 
200  /* check ret */
201  ok(ret == pEntry->Return, "Line %d: ret expected %d, got %d\n",
202  pEntry->LineNo, pEntry->Return, ret);
203 
204  /* check error code */
205  ok(Error == pEntry->Error,
206  "Line %d: Wrong last error. Expected %lu, got %lu\n",
207  pEntry->LineNo, pEntry->Error, Error);
208 
209  if (pEntry->DestLen)
210  {
211  /* check buffer */
212  for (i = 0; i < pEntry->CheckLen; ++i)
213  {
214  ok(Buffer[i] == pEntry->CheckDest[i], "Line %d: Buffer[%d] expected %d, got %d\n",
215  pEntry->LineNo, i, pEntry->CheckDest[i], Buffer[i]);
216  }
217  }
218 }
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:417
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.