ReactOS  0.4.15-dev-2144-g2282205
ReallocSplStr.c File Reference
#include <apitest.h>
#include <windef.h>
#include <winbase.h>
#include <spoolss.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 15 of file ReallocSplStr.c.

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