ReactOS 0.4.15-dev-7924-g5949c20
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{
115 ULONG ResultSize;
117 CHAR OemBuffer[4];
118
119 /* Basic things */
122
123 Status = RtlUnicodeToOemN(NULL, 0, NULL, L"ABCDEF", 0);
125
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}
void SetupLocale(ULONG AnsiCode, ULONG OemCode, ULONG Unicode)
Definition: IsTextUnicode.c:39
NTSTATUS Status
ULONG ReturnedSize
LPCWSTR StrW
ULONG AnsiCp
LPCSTR StrOem
ULONG OemCp
#define StartSeh()
Definition: _sntprintf.h:16
#define EndSeh(ExpectedStatus)
Definition: _sntprintf.h:17
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define ok_ntstatus(status, expected)
Definition: atltest.h:135
#define ok_long(expression, result)
Definition: atltest.h:133
#define ok(value,...)
Definition: atltest.h:57
#define ok_char(expression, result)
Definition: atltest.h:122
LONG NTSTATUS
Definition: precomp.h:26
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:590
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:608
Definition: ehthrow.cxx:93
Definition: ehthrow.cxx:54
#define NULL
Definition: types.h:112
Status
Definition: gdiplustypes.h:25
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
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
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define for
Definition: utility.h:88
int k
Definition: mpi.c:3369
_Use_decl_annotations_ NTSTATUS NTAPI RtlUnicodeToOemN(_Out_ PCHAR OemString, _In_ ULONG OemSize, _Out_opt_ PULONG ResultSize, _In_ PCWCH UnicodeString, _In_ ULONG UnicodeSize)
Definition: nlsboot.c:263
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:242
#define L(x)
Definition: ntvdm.h:50
#define memset(x, y, z)
Definition: compat.h:39
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#define _countof(array)
Definition: sndvol32.h:68
uint32_t ULONG
Definition: typedefs.h:59
char * LPSTR
Definition: xmlstorage.h:182
__wchar_t WCHAR
Definition: xmlstorage.h:180
char CHAR
Definition: xmlstorage.h:175

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().

◆ 

struct { ... } Test[10]

◆ 

const struct { ... } TestData[]