ReactOS  0.4.15-dev-3181-g4acf100
PackStrings.c File Reference
#include <apitest.h>
#include <windef.h>
#include <winbase.h>
#include <spoolss.h>
Include dependency graph for PackStrings.c:

Go to the source code of this file.

Classes

struct  _EXAMPLE_STRUCT
 

Macros

#define WIN32_NO_STATUS
 

Typedefs

typedef struct _EXAMPLE_STRUCT EXAMPLE_STRUCT
 
typedef struct _EXAMPLE_STRUCTPEXAMPLE_STRUCT
 

Functions

 START_TEST (PackStrings)
 

Macro Definition Documentation

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 10 of file PackStrings.c.

Typedef Documentation

◆ EXAMPLE_STRUCT

◆ PEXAMPLE_STRUCT

Function Documentation

◆ START_TEST()

START_TEST ( PackStrings  )

Definition at line 22 of file PackStrings.c.

23 {
24  PCWSTR Source1[] = { L"Test", L"String" };
25  PCWSTR Source2[] = { L"Test", NULL };
26 
27  BYTE Buffer[50];
28  PBYTE pEnd;
30  DWORD Offsets[] = {
31  FIELD_OFFSET(EXAMPLE_STRUCT, String1),
33  MAXDWORD
34  };
35 
36  // Try a usual case with two strings. Verify that they are copied in reverse order.
37  pEnd = PackStrings(Source1, Buffer, Offsets, &Buffer[sizeof(Buffer)]);
38  ok(wcscmp(pStruct->String1, Source1[0]) == 0, "String1 and Source1[0] don't match!\n");
39  ok(wcscmp(pStruct->String2, Source1[1]) == 0, "String2 and Source1[1] don't match!\n");
40  ok(wcscmp((PWSTR)pEnd, Source1[1]) == 0, "pEnd and Source1[1] don't match!\n");
41 
42  // Now verify that the corresponding pointer is set to NULL if a string is NULL.
43  pEnd = PackStrings(Source2, Buffer, Offsets, &Buffer[sizeof(Buffer)]);
44  ok(wcscmp(pStruct->String1, Source2[0]) == 0, "String1 and Source2[0] don't match!\n");
45  ok(!pStruct->String2, "String2 is %p!\n", pStruct->String2);
46  ok(wcscmp((PWSTR)pEnd, Source2[0]) == 0, "pEnd and Source2[0] don't match!\n");
47 }
const uint16_t * PCWSTR
Definition: typedefs.h:57
uint16_t * PWSTR
Definition: typedefs.h:56
#define MAXDWORD
Definition: bufpool.h:45
PBYTE WINAPI PackStrings(PCWSTR *pSource, PBYTE pDest, const DWORD *DestOffsets, PBYTE pEnd)
Definition: tools.c:39
struct _EXAMPLE_STRUCT * PEXAMPLE_STRUCT
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
unsigned char BYTE
Definition: xxhash.c:193
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define ok(value,...)
Definition: atltest.h:57
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define NULL
Definition: types.h:112
_In_ const STRING * String2
Definition: rtlfuncs.h:2304
BYTE * PBYTE
Definition: pedump.c:66