ReactOS  0.4.15-dev-3173-g40ee59d
RtlUnicodeToOemN.c File Reference
#include "precomp.h"
Include dependency graph for RtlUnicodeToOemN.c:

Go to the source code of this file.

Functions

 START_TEST (RtlUnicodeToOemN)
 

Variables

struct {
   ULONG   AnsiCp
 
   ULONG   OemCp
 
   struct {
      LPCWSTR   StrW
 
      NTSTATUS   Status
 
      ULONG   ReturnedSize
 
      LPCSTR   StrOem
 
   }   Test [10]
 
TestData []
 

Function Documentation

◆ START_TEST()

START_TEST ( RtlUnicodeToOemN  )

Definition at line 111 of file RtlUnicodeToOemN.c.

112 {
113  ULONG Length;
114  LPSTR StrOem;
115  ULONG ResultSize;
117  CHAR OemBuffer[4];
118 
119  /* Basic things */
120  Status = RtlUnicodeToOemN(NULL, 0, NULL, NULL, 0);
122 
123  Status = RtlUnicodeToOemN(NULL, 0, NULL, L"ABCDEF", 0);
125 
126  Status = RtlUnicodeToOemN(NULL, 0, NULL, NULL, 2);
128 
129  Status = RtlUnicodeToOemN(NULL, 0, NULL, L"A", 2);
131 
132  Status = RtlUnicodeToOemN(NULL, 0, NULL, L"A", 2);
134 
135  StartSeh()
136  Status = RtlUnicodeToOemN(NULL, 1, NULL, L"A", 2);
138 
139  OemBuffer[0] = 0xAA;
140  OemBuffer[1] = 0xAA;
141  Status = RtlUnicodeToOemN(OemBuffer, 1, NULL, L"A", 2);
143  ok_char(OemBuffer[0], 'A');
144  ok_char(OemBuffer[1], (CHAR)0xAA);
145 
146  OemBuffer[0] = 0xAA;
147  OemBuffer[1] = 0xAA;
148  Status = RtlUnicodeToOemN(OemBuffer, 1, NULL, L"AB", 4);
150  ok_char(OemBuffer[0], 'A');
151  ok_char(OemBuffer[1], (CHAR)0xAA);
152 
153  OemBuffer[0] = 0xAA;
154  OemBuffer[1] = 0xAA;
155  Status = RtlUnicodeToOemN(OemBuffer, 2, NULL, L"A", 4);
157  ok_char(OemBuffer[0], 'A');
158  ok_char(OemBuffer[1], '\0');
159 
160  /* RtlUnicodeToOemN doesn't care about string termination */
161  OemBuffer[0] = 0xAA;
162  OemBuffer[1] = 0xAA;
163  Status = RtlUnicodeToOemN(OemBuffer, 1, NULL, L"A", 4);
165  ok_char(OemBuffer[0], 'A');
166  ok_char(OemBuffer[1], (CHAR)0xAA);
167 
168  OemBuffer[0] = 0xAA;
169  OemBuffer[1] = 0xAA;
170  OemBuffer[2] = 0xAA;
171  OemBuffer[3] = 0xAA;
172  Status = RtlUnicodeToOemN(OemBuffer, 4, NULL, L"A\0B", 8);
174  ok_char(OemBuffer[0], 'A');
175  ok_char(OemBuffer[1], '\0');
176  ok_char(OemBuffer[2], 'B');
177  ok_char(OemBuffer[3], '\0');
178 
179  /* Odd Unicode buffer size */
180  OemBuffer[0] = 0xAA;
181  OemBuffer[1] = 0xAA;
182  OemBuffer[2] = 0xAA;
183  OemBuffer[3] = 0xAA;
184  Status = RtlUnicodeToOemN(OemBuffer, 2, NULL, L"AB", 5);
186  ok_char(OemBuffer[0], 'A');
187  ok_char(OemBuffer[1], 'B');
188  ok_char(OemBuffer[2], (CHAR)0xAA);
189  ok_char(OemBuffer[3], (CHAR)0xAA);
190 
191  /* Odd Unicode buffer size */
192  OemBuffer[0] = 0xAA;
193  OemBuffer[1] = 0xAA;
194  OemBuffer[2] = 0xAA;
195  OemBuffer[3] = 0xAA;
196  Status = RtlUnicodeToOemN(OemBuffer, 3, NULL, L"AB", 5);
198  ok_char(OemBuffer[0], 'A');
199  ok_char(OemBuffer[1], 'B');
200  ok_char(OemBuffer[2], (CHAR)0xAA);
201  ok_char(OemBuffer[3], (CHAR)0xAA);
202 
203  for (int i = 0; i < _countof(TestData); i++)
204  {
206 
207  for (int j = 0; TestData[i].Test[j].StrW != NULL; j++)
208  {
210  StrOem = RtlAllocateHeap(RtlGetProcessHeap(), 0, Length + 1);
211 
212  memset(StrOem, 0xAA, Length + 1);
213  ResultSize = 0x0BADF00D;
214 
216  Length,
217  &ResultSize,
218  TestData[i].Test[j].StrW,
219  wcslen(TestData[i].Test[j].StrW) * sizeof(WCHAR));
220 
222  ok_long(ResultSize, TestData[i].Test[j].ReturnedSize);
223  for (int k = 0; k < ResultSize; k++)
224  {
225  ok(StrOem[k] == TestData[i].Test[j].StrOem[k],
226  "Wrong char \\x%02x, expected TestData[%u].Test[%u].StrOem[%u] (\\x%02x)\n",
227  StrOem[k], i, j, k, TestData[i].Test[j].StrOem[k]);
228  }
229  for (int k = ResultSize; k < (Length + 1); k++)
230  {
231  ok_char(StrOem[k], (CHAR)0xAA);
232  }
233 
234  RtlFreeHeap(RtlGetProcessHeap(), 0, StrOem);
235  }
236  }
237 }
ULONG ReturnedSize
Definition: ehthrow.cxx:53
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
ULONG AnsiCp
void SetupLocale(ULONG AnsiCode, ULONG OemCode, ULONG Unicode)
Definition: IsTextUnicode.c:38
char CHAR
Definition: xmlstorage.h:175
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
LPCSTR StrOem
LPCWSTR StrW
char * LPSTR
Definition: xmlstorage.h:182
#define ok_long(expression, result)
Definition: atltest.h:133
#define StartSeh()
Definition: _sntprintf.h:16
Definition: ehthrow.cxx:92
NTSYSAPI NTSTATUS NTAPI RtlUnicodeToOemN(PCHAR OemString, ULONG OemSize, PULONG ResultSize, PCWCH UnicodeString, ULONG UnicodeSize)
#define ok_char(expression, result)
Definition: atltest.h:122
ULONG OemCp
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 GLint GLint j
Definition: glfuncs.h:250
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
Status
Definition: gdiplustypes.h:24
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define for
Definition: utility.h:88
static const WCHAR L[]
Definition: oid.c:1250
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
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 STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:242
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
NTSTATUS Status
#define ok_ntstatus(status, expected)
Definition: atltest.h:135
unsigned int ULONG
Definition: retypes.h:1
#define STATUS_SUCCESS
Definition: shellext.h:65
#define memset(x, y, z)
Definition: compat.h:39
int k
Definition: mpi.c:3369
#define EndSeh(ExpectedStatus)
Definition: _sntprintf.h:17

Variable Documentation

◆ AnsiCp

ULONG AnsiCp

Definition at line 12 of file RtlUnicodeToOemN.c.

Referenced by START_TEST().

◆ OemCp

ULONG OemCp

Definition at line 13 of file RtlUnicodeToOemN.c.

Referenced by START_TEST().

◆ ReturnedSize

◆ Status

Definition at line 17 of file RtlUnicodeToOemN.c.

Referenced by START_TEST().

◆ StrOem

LPCSTR StrOem

Definition at line 19 of file RtlUnicodeToOemN.c.

Referenced by START_TEST().

◆ StrW

LPCWSTR StrW

Definition at line 16 of file RtlUnicodeToOemN.c.

Referenced by START_TEST().

◆ Test

struct { ... } Test[10]

◆ TestData

const { ... } TestData[]