mirror of
https://github.com/reactos/reactos.git
synced 2024-08-28 22:28:36 +00:00
![Colin Finck](/assets/img/avatar_default.png)
In an attempt to simplify the code for further functions that return information structures, implement and document the undocumented PackStrings function. Hints were taken from an XP DDK sample and own testing. [SPOOLSS_APITEST] Add some tests for PackStrings that succeed under Windows Server 2003. svn path=/branches/colins-printing-for-freedom/; revision=68023
49 lines
1.7 KiB
C
49 lines
1.7 KiB
C
/*
|
|
* PROJECT: ReactOS Spooler Router API Tests
|
|
* LICENSE: GNU GPLv2 or any later version as published by the Free Software Foundation
|
|
* PURPOSE: Tests for PackStrings
|
|
* COPYRIGHT: Copyright 2015 Colin Finck <colin@reactos.org>
|
|
*/
|
|
|
|
#include <apitest.h>
|
|
|
|
#define WIN32_NO_STATUS
|
|
#include <windef.h>
|
|
#include <winbase.h>
|
|
|
|
PBYTE WINAPI PackStrings(PCWSTR*, PBYTE, PDWORD, PBYTE);
|
|
|
|
typedef struct _EXAMPLE_STRUCT
|
|
{
|
|
PWSTR String1;
|
|
PWSTR String2;
|
|
}
|
|
EXAMPLE_STRUCT, *PEXAMPLE_STRUCT;
|
|
|
|
START_TEST(PackStrings)
|
|
{
|
|
PCWSTR Source1[] = { L"Test", L"String" };
|
|
PCWSTR Source2[] = { L"Test", NULL };
|
|
|
|
BYTE Buffer[50];
|
|
PBYTE pEnd;
|
|
PEXAMPLE_STRUCT pStruct = (PEXAMPLE_STRUCT)Buffer;
|
|
DWORD Offsets[] = {
|
|
FIELD_OFFSET(EXAMPLE_STRUCT, String1),
|
|
FIELD_OFFSET(EXAMPLE_STRUCT, String2),
|
|
MAXDWORD
|
|
};
|
|
|
|
// Try a usual case with two strings. Verify that they are copied in reverse order.
|
|
pEnd = PackStrings(Source1, Buffer, Offsets, &Buffer[sizeof(Buffer)]);
|
|
ok(wcscmp(pStruct->String1, Source1[0]) == 0, "String1 and Source1[0] don't match!\n");
|
|
ok(wcscmp(pStruct->String2, Source1[1]) == 0, "String2 and Source1[1] don't match!\n");
|
|
ok(wcscmp((PWSTR)pEnd, Source1[1]) == 0, "pEnd and Source1[1] don't match!\n");
|
|
|
|
// Now verify that the corresponding pointer is set to NULL if a string is NULL.
|
|
pEnd = PackStrings(Source2, Buffer, Offsets, &Buffer[sizeof(Buffer)]);
|
|
ok(wcscmp(pStruct->String1, Source2[0]) == 0, "String1 and Source2[0] don't match!\n");
|
|
ok(!pStruct->String2, "String2 is %p!\n", pStruct->String2);
|
|
ok(wcscmp((PWSTR)pEnd, Source2[0]) == 0, "pEnd and Source2[0] don't match!\n");
|
|
}
|