ReactOS  0.4.13-dev-101-g0ca4b50
_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 ok_int(x, y)
Definition: sprintf.c:21
LONG NTSTATUS
Definition: precomp.h:26
#define StartSeh()
Definition: _sntprintf.h:16
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
_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:426
Definition: bufpool.h:45
char _TCHAR
Definition: tchar.h:1392
#define _T(x)
Definition: vfdio.h:22
START_TEST(_sntprintf)
Definition: _sntprintf.h:23
#define BufferSize
Definition: classpnp.h:419
#define FillMemory(BUF, SIZ, MASK)
Definition: strucsup.c:31
#define _sntprintf
Definition: xmlstorage.h:201
#define broken(x)
Definition: _sntprintf.h:21
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:228
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
return STATUS_SUCCESS
Definition: btrfs.c:2725
#define EndSeh(ExpectedStatus)
Definition: _sntprintf.h:17