Index: kmtests/rtl/RtlUnicodeString.c =================================================================== --- kmtests/rtl/RtlUnicodeString.c (revision 60823) +++ kmtests/rtl/RtlUnicodeString.c (working copy) @@ -173,7 +173,74 @@ #endif } +static +VOID +TestRtlUpcaseUnicodeString(VOID) +{ + + NTSTATUS Status; + LONG Comparison; + USHORT i; + + UNICODE_STRING StringUpcased1; + UNICODE_STRING StringToUpcase1 = RTL_CONSTANT_STRING(L" rEactOS rO#ks !!\"??"); + UNICODE_STRING StringUpcasedRef1 = RTL_CONSTANT_STRING(L" REACTOS RO#KS !!\"??"); + + UNICODE_STRING StringUpcased2; + UNICODE_STRING ZeroLengthString; + + WCHAR MAX[UNICODE_STRING_MAX_BYTES]; + WCHAR MAXExp[UNICODE_STRING_MAX_BYTES]; + UNICODE_STRING StringMaxToUpcase; + UNICODE_STRING StringMaxUpcased; + UNICODE_STRING StringMaxUpcasedExp; + + WCHAR Buffer[10]; + UNICODE_STRING StringZeroed; + UNICODE_STRING StringToUpcase2 = RTL_CONSTANT_STRING(L"aBcde"); + UNICODE_STRING StringUpcasedRef2 = RTL_CONSTANT_STRING(L"ABCDE0"); + + +// TEST#1: Allocate buffer. + RtlUpcaseUnicodeString(&StringUpcased1, &StringToUpcase1, TRUE); + + Comparison = RtlCompareUnicodeString(&StringUpcasedRef1, &StringUpcased1, FALSE); + RtlFreeUnicodeString(&StringUpcased1); + ok_eq_ulong(Comparison, 0); + +// TEST#2: Allocate Buffer. RtlUpcaseUnicodeString accepts NULL as StringToUpcase argument. + RtlInitUnicodeString(&ZeroLengthString, NULL); + Status = RtlUpcaseUnicodeString(&StringUpcased2, &ZeroLengthString, TRUE); + ok_eq_hex(Status, STATUS_SUCCESS); + RtlFreeUnicodeString(&StringUpcased2); + ok(StringUpcased2.Buffer == NULL, "Expected NULL" ); + +// TEST#3: Allocate UNICODE_STRING_MAX_BYTES buffer + for (i = 0; i < (UNICODE_STRING_MAX_BYTES)/sizeof(WCHAR)-1; i++) MAX[i] = L'r'; + for (i = 0; i < (UNICODE_STRING_MAX_BYTES)/sizeof(WCHAR)-1; i++) MAXExp[i]= L'R'; + + RtlInitUnicodeString(&StringMaxToUpcase, MAX); + RtlInitUnicodeString(&StringMaxUpcasedExp, MAXExp); + + RtlUpcaseUnicodeString(&StringMaxUpcased, &StringMaxToUpcase, TRUE); + + Comparison = RtlCompareUnicodeString(&StringMaxUpcased, &StringMaxUpcasedExp, FALSE); + RtlFreeUnicodeString(&StringMaxUpcased); + ok_eq_ulong(Comparison, 0); + + +// TEST#4: Don't allocate buffer. Also RtlUpcaseUnicodeString doesnt NULL terminate the StringUpcased + RtlInitEmptyUnicodeString(&StringZeroed, Buffer, sizeof(Buffer)); + RtlAppendUnicodeToString(&StringZeroed, L"000000"); + + RtlUpcaseUnicodeString(&StringZeroed, &StringToUpcase2, FALSE); + RtlCompareUnicodeString(&StringZeroed, &StringUpcasedRef2, FALSE); + ok_eq_wstr(StringZeroed.Buffer, StringUpcasedRef2.Buffer); + +} + START_TEST(RtlUnicodeString) { TestFindCharInUnicodeString(); + TestRtlUpcaseUnicodeString(); }