mirror of
https://github.com/reactos/reactos.git
synced 2026-05-30 14:34:57 +08:00
[SHELL32_APITEST] Improve the existing PCH and make use of it. Convert AddCommas.c to c++ in order to have it benefit from the PCH.
This commit is contained in:
75
modules/rostests/apitests/shell32/AddCommas.cpp
Normal file
75
modules/rostests/apitests/shell32/AddCommas.cpp
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* PROJECT: ReactOS API tests
|
||||
* LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
|
||||
* PURPOSE: Test for AddCommas
|
||||
* PROGRAMMER: Thomas Faber <thomas.faber@reactos.org>
|
||||
*/
|
||||
|
||||
#include "shelltest.h"
|
||||
|
||||
#include <winnls.h>
|
||||
#include <bcrypt.h>
|
||||
#include <strsafe.h>
|
||||
|
||||
extern "C" DECLSPEC_IMPORT LPWSTR WINAPI AddCommasW(DWORD lValue, LPWSTR lpNumber);
|
||||
|
||||
START_TEST(AddCommas)
|
||||
{
|
||||
WCHAR Separator[4];
|
||||
WCHAR Grouping[11];
|
||||
WCHAR Number[32];
|
||||
WCHAR Expected[32];
|
||||
PWSTR Ptr;
|
||||
int Ret;
|
||||
|
||||
StartSeh()
|
||||
AddCommasW(0, NULL);
|
||||
EndSeh(STATUS_ACCESS_VIOLATION);
|
||||
|
||||
RtlFillMemory(Number, sizeof(Number), 0x55);
|
||||
Ptr = AddCommasW(0, Number);
|
||||
ok(Ptr == Number, "Ptr = %p, expected %p\n", Ptr, Number);
|
||||
ok(Number[0] == L'0', "Number[0] = 0x%x\n", Number[0]);
|
||||
ok(Number[1] == 0, "Number[1] = 0x%x\n", Number[1]);
|
||||
ok(Number[2] == 0x5555, "Number[2] = 0x%x\n", Number[2]);
|
||||
|
||||
Ret = GetLocaleInfoW(LOCALE_USER_DEFAULT,
|
||||
LOCALE_STHOUSAND,
|
||||
Separator,
|
||||
RTL_NUMBER_OF(Separator));
|
||||
if (!Ret)
|
||||
{
|
||||
skip("GetLocaleInfoW failed with %lu\n", GetLastError());
|
||||
return;
|
||||
}
|
||||
Ret = GetLocaleInfoW(LOCALE_USER_DEFAULT,
|
||||
LOCALE_SGROUPING,
|
||||
Grouping,
|
||||
RTL_NUMBER_OF(Grouping));
|
||||
if (!Ret)
|
||||
{
|
||||
skip("GetLocaleInfoW failed with %lu\n", GetLastError());
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcscmp(Grouping, L"3;0"))
|
||||
{
|
||||
skip("Skipping remaining tests due to incompatible locale (separator '%ls', grouping '%ls')\n",
|
||||
Separator, Grouping);
|
||||
return;
|
||||
}
|
||||
|
||||
RtlFillMemory(Number, sizeof(Number), 0x55);
|
||||
Ptr = AddCommasW(123456789, Number);
|
||||
ok(Ptr == Number, "Ptr = %p, expected %p\n", Ptr, Number);
|
||||
StringCbPrintfW(Expected, sizeof(Expected), L"123%ls456%ls789", Separator, Separator);
|
||||
ok(!wcscmp(Number, Expected), "Number = '%ls', expected %ls\n", Number, Expected);
|
||||
ok(Number[wcslen(Number) + 1] == 0x5555, "Number[N] = 0x%x\n", Number[wcslen(Number) + 1]);
|
||||
|
||||
RtlFillMemory(Number, sizeof(Number), 0x55);
|
||||
Ptr = AddCommasW(4294967295U, Number);
|
||||
ok(Ptr == Number, "Ptr = %p, expected %p\n", Ptr, Number);
|
||||
StringCbPrintfW(Expected, sizeof(Expected), L"4%ls294%ls967%ls295", Separator, Separator, Separator);
|
||||
ok(!wcscmp(Number, Expected), "Number = '%ls', expected %ls\n", Number, Expected);
|
||||
ok(Number[wcslen(Number) + 1] == 0x5555, "Number[N] = 0x%x\n", Number[wcslen(Number) + 1]);
|
||||
}
|
||||
Reference in New Issue
Block a user