ReactOS 0.4.15-dev-8408-g466a198
ReallocSplStr.c File Reference
#include <apitest.h>
#include <windef.h>
#include <winbase.h>
#include <spoolss.h>
#include <pseh/pseh2.h>
Include dependency graph for ReallocSplStr.c:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 

Functions

 START_TEST (ReallocSplStr)
 

Macro Definition Documentation

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 10 of file ReallocSplStr.c.

Function Documentation

◆ START_TEST()

START_TEST ( ReallocSplStr  )

Definition at line 17 of file ReallocSplStr.c.

18{
19 const WCHAR wszTestString1[] = L"Test";
20 const WCHAR wszTestString2[] = L"New";
21
22 DWORD dwResult;
23 PWSTR pwszBackup;
24 PWSTR pwszTest;
25
26 // Verify that ReallocSplStr raises an exception if all parameters are NULL.
28 {
29 dwResult = 0;
31 }
33 {
34 dwResult = _SEH2_GetExceptionCode();
35 }
37
38 ok(dwResult == EXCEPTION_ACCESS_VIOLATION, "dwResult is %lx!\n", dwResult);
39
40 // Allocate a string for testing.
41 pwszTest = AllocSplStr(wszTestString1);
42 if (!pwszTest)
43 {
44 skip("AllocSplStr failed with error %lu!\n", GetLastError());
45 return;
46 }
47
48 // Verify that ReallocSplStr frees the old string even if pwszInput is NULL.
49 ok(ReallocSplStr(&pwszTest, NULL), "ReallocSplStr is FALSE!\n");
50 ok(pwszTest == NULL, "pwszTest is %p\n", pwszTest);
51
52 // Now verify that ReallocSplStr copies the new string into a new block and frees the old one.
53 pwszBackup = pwszTest;
54 ok(ReallocSplStr(&pwszTest, wszTestString2), "ReallocSplStr is FALSE!\n");
55 ok(wcscmp(pwszTest, wszTestString2) == 0, "New string was not copied into pwszTest!\n");
56
58 {
59 dwResult = (DWORD)wcscmp(pwszBackup, wszTestString1);
60 }
62 {
63 dwResult = _SEH2_GetExceptionCode();
64 }
66
67 ok(dwResult == EXCEPTION_ACCESS_VIOLATION, "dwResult is %lx!\n", dwResult);
68}
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define NULL
Definition: types.h:112
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
unsigned long DWORD
Definition: ntddk_ex.h:95
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define DWORD
Definition: nt_native.h:44
#define L(x)
Definition: ntvdm.h:50
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:66
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
uint16_t * PWSTR
Definition: typedefs.h:56
PWSTR WINAPI AllocSplStr(PCWSTR pwszInput)
Definition: memory.c:56
BOOL WINAPI ReallocSplStr(PWSTR *ppwszString, PCWSTR pwszInput)
Definition: memory.c:195
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define EXCEPTION_ACCESS_VIOLATION
Definition: winbase.h:311
__wchar_t WCHAR
Definition: xmlstorage.h:180