ReactOS 0.4.15-dev-7928-g68a8619
_sntprintf.h
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPLv2+ - See COPYING in the top level directory
4 * PURPOSE: Test for _sntprintf
5 * PROGRAMMER: Thomas Faber <thfabba@gmx.de>
6 */
7
8#define WIN32_NO_STATUS
9#include <wine/test.h>
10#include <stdio.h>
11#include <tchar.h>
12#include <pseh/pseh2.h>
13#include <ndk/mmfuncs.h>
14#include <ndk/rtlfuncs.h>
15
16#define StartSeh() ExceptionStatus = STATUS_SUCCESS; _SEH2_TRY {
17#define EndSeh(ExpectedStatus) } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { ExceptionStatus = _SEH2_GetExceptionCode(); } _SEH2_END; ok(ExceptionStatus == ExpectedStatus, "Exception %lx, expected %lx\n", ExceptionStatus, ExpectedStatus)
18
19/* winetest_platform is "windows" for us, so broken() doesn't do what it should :( */
20#undef broken
21#define broken(x) 0
22
24{
25 NTSTATUS ExceptionStatus;
26 _TCHAR Buffer[128];
27 size_t BufferSize = sizeof(Buffer) / sizeof(Buffer[0]);
28 int Result;
29
30 StartSeh()
31 Result = _sntprintf(NULL, 0, _T("Hello"));
32#ifdef TEST_CRTDLL
33 ok_int(Result, -1);
34#else
35 ok_int(Result, 5);
36#endif
38
39 StartSeh()
40 Result = _sntprintf(NULL, 1, _T("Hello"));
41 ok(Result == 5 ||
42 broken(Result == -1) /* Win7 */, "Result = %d\n", Result);
43#if defined(_UNICODE) || defined(TEST_CRTDLL)
45#else
47#endif
48
49 StartSeh()
50 FillMemory(Buffer, sizeof(Buffer), 0x55);
51 Result = _sntprintf(Buffer, BufferSize, _T("Hello"));
52 ok_int(Result, 5);
53 ok(Buffer[0] == _T('H'), "\n");
54 ok(Buffer[1] == _T('e'), "\n");
55 ok(Buffer[2] == _T('l'), "\n");
56 ok(Buffer[3] == _T('l'), "\n");
57 ok(Buffer[4] == _T('o'), "\n");
58 ok(Buffer[5] == _T('\0'), "\n");
59 ok(Buffer[6] == (_TCHAR)0x5555, "\n");
61
62 StartSeh()
63 FillMemory(Buffer, sizeof(Buffer), 0x55);
64 Result = _sntprintf(Buffer, 5, _T("Hello"));
65 ok_int(Result, 5);
66 ok(Buffer[0] == _T('H'), "\n");
67 ok(Buffer[1] == _T('e'), "\n");
68 ok(Buffer[2] == _T('l'), "\n");
69 ok(Buffer[3] == _T('l'), "\n");
70 ok(Buffer[4] == _T('o'), "\n");
71 ok(Buffer[5] == (_TCHAR)0x5555, "\n");
73
74 StartSeh()
75 FillMemory(Buffer, sizeof(Buffer), 0x55);
76 Result = _sntprintf(Buffer, 1, _T("Hello"));
77 ok_int(Result, -1);
78 ok(Buffer[0] == _T('H'), "\n");
79 ok(Buffer[1] == (_TCHAR)0x5555, "\n");
81
82 StartSeh()
83 FillMemory(Buffer, sizeof(Buffer), 0x55);
84 Result = _sntprintf(Buffer, 0, _T("Hello"));
85 ok_int(Result, -1);
86 ok(Buffer[0] == (_TCHAR)0x5555, "\n");
88}
#define broken(x)
Definition: _sntprintf.h:21
#define StartSeh()
Definition: _sntprintf.h:16
#define EndSeh(ExpectedStatus)
Definition: _sntprintf.h:17
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
#define ok_int(expression, result)
Definition: atltest.h:134
LONG NTSTATUS
Definition: precomp.h:26
Definition: bufpool.h:45
#define NULL
Definition: types.h:112
#define FillMemory(BUF, SIZ, MASK)
Definition: strucsup.c:31
char _TCHAR
Definition: tchar.h:1392
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:242
#define STATUS_SUCCESS
Definition: shellext.h:65
#define _T(x)
Definition: vfdio.h:22
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
#define _sntprintf
Definition: xmlstorage.h:201