ReactOS 0.4.15-dev-7842-g558ab78
PackStrings.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Spooler Router API Tests
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: Tests for PackStrings
5 * COPYRIGHT: Copyright 2015-2017 Colin Finck (colin@reactos.org)
6 */
7
8#include <apitest.h>
9
10#define WIN32_NO_STATUS
11#include <windef.h>
12#include <winbase.h>
13#include <spoolss.h>
14
15typedef struct _EXAMPLE_STRUCT
16{
19}
21
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[] = {
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}
struct _EXAMPLE_STRUCT * PEXAMPLE_STRUCT
struct _EXAMPLE_STRUCT EXAMPLE_STRUCT
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
PBYTE WINAPI PackStrings(PCWSTR *pSource, PBYTE pDest, const DWORD *DestOffsets, PBYTE pEnd)
Definition: tools.c:39
Definition: bufpool.h:45
#define NULL
Definition: types.h:112
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ const STRING * String2
Definition: rtlfuncs.h:2357
#define MAXDWORD
#define L(x)
Definition: ntvdm.h:50
BYTE * PBYTE
Definition: pedump.c: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
const uint16_t * PCWSTR
Definition: typedefs.h:57
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
unsigned char BYTE
Definition: xxhash.c:193