1 /* 2 * PROJECT: ReactOS API tests 3 * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory 4 * PURPOSE: Test for RtlUnicodeStringToAnsiString 5 * PROGRAMMERS: Pierre Schweitzer <pierre@reactos.org> 6 */ 7 8 #include "precomp.h" 9 10 START_TEST(RtlUnicodeStringToAnsiString) 11 { 12 WCHAR BufferU[10]; 13 CHAR BufferA[10]; 14 UNICODE_STRING StringU; 15 ANSI_STRING StringA; 16 NTSTATUS Status; 17 DWORD i; 18 19 memset(BufferU, 0xAA, sizeof(BufferU)); 20 memset(BufferA, 0xAA, sizeof(BufferA)); 21 22 BufferU[0] = L'A'; 23 BufferU[1] = UNICODE_NULL; 24 25 StringU.Buffer = BufferU; 26 StringU.MaximumLength = 10 * sizeof(WCHAR); 27 28 RtlInitUnicodeString(&StringU, BufferU); 29 ok(StringU.Length == 1 * sizeof(WCHAR), "Invalid size: %d\n", StringU.Length); 30 ok(StringU.MaximumLength == 2 * sizeof(WCHAR), "Invalid size: %d\n", StringU.MaximumLength); 31 ok(StringU.Buffer == BufferU, "Invalid buffer: %p\n", StringU.Buffer); 32 33 StringA.Buffer = BufferA; 34 StringA.MaximumLength = 10 * sizeof(CHAR); 35 36 Status = RtlUnicodeStringToAnsiString(&StringA, &StringU, FALSE); 37 ok(NT_SUCCESS(Status), "RtlUnicodeStringToAnsiString failed: %lx\n", Status); 38 ok(StringA.Length == 1 * sizeof(CHAR), "Invalid size: %d\n", StringA.Length); 39 ok(StringA.MaximumLength == 10 * sizeof(CHAR), "Invalid size: %d\n", StringA.MaximumLength); 40 ok(StringA.Buffer == BufferA, "Invalid buffer: %p\n", StringA.Buffer); 41 42 for (i = 0; i < 10; ++i) 43 { 44 if (BufferA[i] == 0) 45 { 46 break; 47 } 48 } 49 50 ok(i != 10, "String was not null terminated!\n"); 51 } 52