Index: crtdll_crt_apitest.cmake =================================================================== --- crtdll_crt_apitest.cmake (revision 56828) +++ crtdll_crt_apitest.cmake (working copy) @@ -264,8 +264,6 @@ # _setmode.c # _setsystime.c # _sleep.c -# _snprintf.c -# _snwprintf.c # _sopen.c # _spawnl.c # _spawnle.c @@ -454,6 +452,8 @@ # signal.c # sin.c # sinh.c + snprintf.c + snwprintf.c sprintf.c # sqrt.c # srand.c @@ -477,7 +477,7 @@ # strtod.c # strtok.c # strtol.c -# strtoul.c + strtoul.c # strxfrm.c # swprintf.c # swscanf.c @@ -518,7 +518,7 @@ # wcstok.c # wcstol.c # wcstombs.c -# wcstoul.c + wcstoul.c # wcsxfrm.c # wctomb.c # wprintf.c Index: msvcrt_crt_apitest.cmake =================================================================== --- msvcrt_crt_apitest.cmake (revision 56828) +++ msvcrt_crt_apitest.cmake (working copy) @@ -679,7 +679,6 @@ # _setmode.c # _setsystime.c # _sleep.c -# _snprintf.c # _snprintf_c # _snprintf_c_l # _snprintf_l @@ -689,7 +688,6 @@ # _snscanf_l # _snscanf_s # _snscanf_s_l -# _snwprintf.c # _snwprintf_l # _snwprintf_s # _snwprintf_s_l @@ -1156,6 +1154,8 @@ # signal.c # sin.c # sinh.c + snprintf.c + snwprintf.c sprintf.c # sprintf_s.c # sqrt.c @@ -1188,7 +1188,7 @@ # strtok.c # strtok_s.c # strtol.c -# strtoul.c + strtoul.c # strxfrm.c # swprintf.c # swprintf_s.c @@ -1252,7 +1252,7 @@ # wcstol.c # wcstombs.c # wcstombs_s.c -# wcstoul.c + wcstoul.c # wcsxfrm.c # wctob # wctomb.c Index: ntdll_crt_apitest.cmake =================================================================== --- ntdll_crt_apitest.cmake (revision 56828) +++ ntdll_crt_apitest.cmake (working copy) @@ -19,8 +19,6 @@ # _ltow.c # _memccpy.c # _memicmp.c -# _snprintf.c -# _snwprintf.c # _splitpath.c # _strcmpi == _stricmp # _stricmp.c @@ -80,6 +78,8 @@ # pow.c # qsort.c # sin.c + snprintf.c + snwprintf.c sprintf.c # sqrt.c # sscanf.c @@ -97,7 +97,7 @@ # strspn.c # strstr.c # strtol.c -# strtoul.c + strtoul.c # swprintf.c # tan.c # tolower.c @@ -121,7 +121,7 @@ # wcstok.c # wcstol.c # wcstombs.c -# wcstoul.c + wcstoul.c ) if (ARCH MATCHES i386) Index: snprintf.c =================================================================== --- snprintf.c (revision 0) +++ snprintf.c (working copy) @@ -0,0 +1,2 @@ +#define func_sntprintf func_snprintf +#include "sntprintf.h" Index: snprintf.c =================================================================== --- snprintf.c (revision 0) +++ snprintf.c (working copy) Property changes on: snprintf.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: sntprintf.h =================================================================== --- sntprintf.h (revision 0) +++ sntprintf.h (working copy) @@ -0,0 +1,88 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPLv2+ - See COPYING in the top level directory + * PURPOSE: Test for _sntprintf + * PROGRAMMER: Thomas Faber + */ + +#define WIN32_NO_STATUS +#include +#include +#include +#include +#include +#include + +#define StartSeh() ExceptionStatus = STATUS_SUCCESS; _SEH2_TRY { +#define EndSeh(ExpectedStatus) } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { ExceptionStatus = _SEH2_GetExceptionCode(); } _SEH2_END; ok(ExceptionStatus == ExpectedStatus, "Exception %lx, expected %lx\n", ExceptionStatus, ExpectedStatus) + +/* winetest_platform is "windows" for us, so broken() doesn't do what it should :( */ +#undef broken +#define broken(x) 0 + +START_TEST(sntprintf) +{ + NTSTATUS ExceptionStatus; + _TCHAR Buffer[128]; + size_t BufferSize = sizeof(Buffer) / sizeof(Buffer[0]); + int Result; + + StartSeh() + Result = _sntprintf(NULL, 0, _T("Hello")); +#ifdef TEST_CRTDLL + ok_int(Result, -1); +#else + ok_int(Result, 5); +#endif + EndSeh(STATUS_SUCCESS); + + StartSeh() + Result = _sntprintf(NULL, 1, _T("Hello")); + ok(Result == 5 || + broken(Result == -1) /* Win7 */, "Result = %d\n", Result); +#if defined(_UNICODE) || defined(TEST_CRTDLL) + EndSeh(STATUS_ACCESS_VIOLATION); +#else + EndSeh(STATUS_SUCCESS); +#endif + + StartSeh() + FillMemory(Buffer, sizeof(Buffer), 0x55); + Result = _sntprintf(Buffer, BufferSize, _T("Hello")); + ok_int(Result, 5); + ok(Buffer[0] == _T('H'), "\n"); + ok(Buffer[1] == _T('e'), "\n"); + ok(Buffer[2] == _T('l'), "\n"); + ok(Buffer[3] == _T('l'), "\n"); + ok(Buffer[4] == _T('o'), "\n"); + ok(Buffer[5] == _T('\0'), "\n"); + ok(Buffer[6] == (_TCHAR)0x5555, "\n"); + EndSeh(STATUS_SUCCESS); + + StartSeh() + FillMemory(Buffer, sizeof(Buffer), 0x55); + Result = _sntprintf(Buffer, 5, _T("Hello")); + ok_int(Result, 5); + ok(Buffer[0] == _T('H'), "\n"); + ok(Buffer[1] == _T('e'), "\n"); + ok(Buffer[2] == _T('l'), "\n"); + ok(Buffer[3] == _T('l'), "\n"); + ok(Buffer[4] == _T('o'), "\n"); + ok(Buffer[5] == (_TCHAR)0x5555, "\n"); + EndSeh(STATUS_SUCCESS); + + StartSeh() + FillMemory(Buffer, sizeof(Buffer), 0x55); + Result = _sntprintf(Buffer, 1, _T("Hello")); + ok_int(Result, -1); + ok(Buffer[0] == _T('H'), "\n"); + ok(Buffer[1] == (_TCHAR)0x5555, "\n"); + EndSeh(STATUS_SUCCESS); + + StartSeh() + FillMemory(Buffer, sizeof(Buffer), 0x55); + Result = _sntprintf(Buffer, 0, _T("Hello")); + ok_int(Result, -1); + ok(Buffer[0] == (_TCHAR)0x5555, "\n"); + EndSeh(STATUS_SUCCESS); +} Index: sntprintf.h =================================================================== --- sntprintf.h (revision 0) +++ sntprintf.h (working copy) Property changes on: sntprintf.h ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: snwprintf.c =================================================================== --- snwprintf.c (revision 0) +++ snwprintf.c (working copy) @@ -0,0 +1,3 @@ +#define _UNICODE +#define func_sntprintf func_snwprintf +#include "sntprintf.h" Index: snwprintf.c =================================================================== --- snwprintf.c (revision 0) +++ snwprintf.c (working copy) Property changes on: snwprintf.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: strtoul.c =================================================================== --- strtoul.c (revision 0) +++ strtoul.c (working copy) @@ -0,0 +1,2 @@ +#define func_tcstoul func_strtoul +#include "tcstoul.h" Index: strtoul.c =================================================================== --- strtoul.c (revision 0) +++ strtoul.c (working copy) Property changes on: strtoul.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: tcstoul.h =================================================================== --- tcstoul.h (revision 0) +++ tcstoul.h (working copy) @@ -0,0 +1,102 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPLv2+ - See COPYING in the top level directory + * PURPOSE: Test for _tcstoul + * PROGRAMMER: Thomas Faber + */ + +#define WIN32_NO_STATUS +#include +#include +#include +#include +#include + +#define StartSeh() ExceptionStatus = STATUS_SUCCESS; _SEH2_TRY { +#define EndSeh(ExpectedStatus) } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { ExceptionStatus = _SEH2_GetExceptionCode(); } _SEH2_END; ok(ExceptionStatus == ExpectedStatus, "Exception %lx, expected %lx\n", ExceptionStatus, ExpectedStatus) + +#define ok_ulong(expression, result) \ + do { \ + unsigned long _value = (expression); \ + ok(_value == (result), "Wrong value for '%s', expected: " #result " (%lu), got: %lu\n", \ + #expression, (unsigned long)(result), _value); \ + } while (0) + +START_TEST(tcstoul) +{ + NTSTATUS ExceptionStatus; + ULONG Result; + _TCHAR Dummy; + _TCHAR *End; + struct + { + const _TCHAR *Input; + int ExpectedLength0; + ULONG Expected0; + int ExpectedLength10; + ULONG Expected10; + } Tests[] = + { + { _T(""), 0, 0, 0, 0 }, + { _T(" "), 0, 0, 0, 0 }, + { _T(" 0"), 2, 0, 2, 0 }, + { _T("0 "), 1, 0, 1, 0 }, + { _T("0"), 1, 0, 1, 0 }, + { _T("1"), 1, 1, 1, 1 }, + { _T("10"), 2, 10, 2, 10 }, + { _T("01"), 2, 1, 2, 1 }, + { _T("010"), 3, 8, 3, 10 }, + { _T("08"), 1, 0, 2, 8 }, + { _T("008"), 2, 0, 3, 8 }, + { _T("-1"), 2, -1, 2, -1 }, + { _T("+1"), 2, 1, 2, 1 }, + { _T("--1"), 0, 0, 0, 0 }, + { _T("++1"), 0, 0, 0, 0 }, + { _T("0a"), 1, 0, 1, 0 }, + { _T("0x"), 0, 0, 1, 0 }, + { _T("0x0"), 3, 0, 1, 0 }, + { _T("0xFFFFFFFF"), 10, -1, 1, 0 }, + { _T("0xFFFFFFFFF"),11, -1, 1, 0 }, + { _T("4294967295"), 10, -1, 10, -1 }, + { _T("4294967296"), 10, -1, 10, -1 }, + { _T("4294967297"), 10, -1, 10, -1 }, + { _T("42949672951"),11, -1, 11, -1 }, + }; + const INT TestCount = sizeof(Tests) / sizeof(Tests[0]); + INT i; + + StartSeh() + Result = _tcstoul(NULL, NULL, 0); + EndSeh(STATUS_ACCESS_VIOLATION); + + StartSeh() + Result = _tcstoul(_T(""), NULL, 0); + ok_ulong(Result, 0); + EndSeh(STATUS_SUCCESS); + + StartSeh() + Result = _tcstoul(_T("1"), NULL, 0); + ok_ulong(Result, 1); + EndSeh(STATUS_SUCCESS); + + Result = _tcstoul(_T("1"), &End, 0); + ok_ulong(Result, 1); + + for (i = 0; i < TestCount; i++) + { +#ifdef _UNICODE + trace("%d: '%ls'\n", i, Tests[i].Input); +#else + trace("%d: '%s'\n", i, Tests[i].Input); +#endif + End = &Dummy; + Result = _tcstoul(Tests[i].Input, &End, 0); + ok_ulong(Result, Tests[i].Expected0); + ok_ptr(End, Tests[i].Input + Tests[i].ExpectedLength0); + + End = &Dummy; + Result = _tcstoul(Tests[i].Input, &End, 10); + ok_ulong(Result, Tests[i].Expected10); + ok_ptr(End, Tests[i].Input + Tests[i].ExpectedLength10); + } +} Index: tcstoul.h =================================================================== --- tcstoul.h (revision 0) +++ tcstoul.h (working copy) Property changes on: tcstoul.h ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: testlist.c =================================================================== --- testlist.c (revision 56828) +++ testlist.c (working copy) @@ -5,15 +5,27 @@ #define STANDALONE #include "wine/test.h" +extern void func_fputc(void); +extern void func_fputwc(void); +extern void func_snprintf(void); +extern void func_snwprintf(void); extern void func_sprintf(void); extern void func_strcpy(void); +extern void func_strnlen(void); +extern void func_strtoul(void); +extern void func_wcsnlen(void); +extern void func_wcstoul(void); const struct test winetest_testlist[] = { + { "snprintf", func_snprintf }, + { "snwprintf", func_snwprintf }, { "sprintf", func_sprintf }, { "strcpy", func_strcpy }, + { "strtoul", func_strtoul }, + { "wcstoul", func_wcstoul }, #if defined(TEST_CRTDLL) || defined(TEST_MSVCRT) || defined(TEST_STATIC_CRT) - // ... + #endif #if defined(TEST_STATIC_CRT) || defined(TEST_MSVCRT) // ... Index: wcstoul.c =================================================================== --- wcstoul.c (revision 0) +++ wcstoul.c (working copy) @@ -0,0 +1,3 @@ +#define _UNICODE +#define func_tcstoul func_wcstoul +#include "tcstoul.h" Index: wcstoul.c =================================================================== --- wcstoul.c (revision 0) +++ wcstoul.c (working copy) Property changes on: wcstoul.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property