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 <apitest.h> 9 #include <ndk/rtlfuncs.h> 10 11 START_TEST(RtlUnicodeStringToAnsiString) 12 { 13 WCHAR BufferU[10]; 14 CHAR BufferA[10]; 15 UNICODE_STRING StringU; 16 ANSI_STRING StringA; 17 NTSTATUS Status; 18 DWORD i; 19 20 memset(BufferU, 0xAA, sizeof(BufferU)); 21 memset(BufferA, 0xAA, sizeof(BufferA)); 22 23 BufferU[0] = L'A'; 24 BufferU[1] = UNICODE_NULL; 25 26 StringU.Buffer = BufferU; 27 StringU.MaximumLength = 10 * sizeof(WCHAR); 28 29 RtlInitUnicodeString(&StringU, BufferU); 30 ok(StringU.Length == 1 * sizeof(WCHAR), "Invalid size: %d\n", StringU.Length); 31 ok(StringU.MaximumLength == 2 * sizeof(WCHAR), "Invalid size: %d\n", StringU.MaximumLength); 32 ok(StringU.Buffer == BufferU, "Invalid buffer: %p\n", StringU.Buffer); 33 34 StringA.Buffer = BufferA; 35 StringA.MaximumLength = 10 * sizeof(CHAR); 36 37 Status = RtlUnicodeStringToAnsiString(&StringA, &StringU, FALSE); 38 ok(NT_SUCCESS(Status), "RtlUnicodeStringToAnsiString failed: %lx\n", Status); 39 ok(StringA.Length == 1 * sizeof(CHAR), "Invalid size: %d\n", StringA.Length); 40 ok(StringA.MaximumLength == 10 * sizeof(CHAR), "Invalid size: %d\n", StringA.MaximumLength); 41 ok(StringA.Buffer == BufferA, "Invalid buffer: %p\n", StringA.Buffer); 42 43 for (i = 0; i < 10; ++i) 44 { 45 if (BufferA[i] == 0) 46 { 47 break; 48 } 49 } 50 51 ok(i != 10, "String was not null terminated!\n"); 52 } 53