ReactOS 0.4.15-dev-7705-g2320c37
RtlSplayTree.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS kernel-mode tests
3 * LICENSE: LGPLv2+ - See COPYING.LIB in the top level directory
4 * PURPOSE: Kernel-Mode Test Suite RtlGenericTable
5 * PROGRAMMER: arty
6 */
7
8#define KMT_EMULATE_KERNEL
9#include <kmt_test.h>
10
11#define NDEBUG
12#include <debug.h>
13
15
18{
20 (*((PCHAR)A) > *((PCHAR)B)) ? GenericGreaterThan :
22 return Result;
23}
24
25static PVOID NTAPI
27{
29 (NonPagedPool, sizeof(LIST_ENTRY) + ByteSize);
31 return &Entry[1];
32}
33
34static VOID NTAPI
36{
40}
41
42static void RtlSplayTreeTest()
43{
44 ULONG i, del;
45 PCHAR Ch;
46 CHAR Text[] = "the quick_brown!fOx-jUmp3d/0vER+THe^lazy.D@g";
47 CHAR NewE[] = "11111111111111111111111111111111110111111111";
50 (&Table,
54 NULL);
55 for (i = 0; Text[i]; i++) {
56 BOOLEAN WasNew;
58 (&Table,
59 &Text[i],
60 sizeof(Text[i]),
61 &WasNew);
62 ok(Ch && *Ch == Text[i], "Copy character into node\n");
63 ok(WasNew == (NewE[i] == '1'),
64 "Character newness didn't match for char %u: '%c'\n",
65 i, Text[i]);
66 }
68 Ch;
70 ok(strchr(Text, *Ch) != NULL, "Nonexistent character\n");
71 }
72 ok(RtlNumberGenericTableElements(&Table) == strlen(Text) - 1, "Not the right number of elements\n");
73 ok(RtlLookupElementGenericTable(&Table, "q") != NULL, "Could not lookup q\n");
74 ok(!RtlLookupElementGenericTable(&Table, "#"), "Found a character that shouldn't appear\n");
75 ok(strlen(Text) == i + 1, "Didn't enumerate enough characters\n");
76 del = 0;
77 for (i = 0; Text[i]; i++) {
78 if (NewE[i] == '1') {
79 BOOLEAN WasDeleted;
80 WasDeleted = RtlDeleteElementGenericTable(&Table, &Text[i]);
81 del += WasDeleted;
82 }
83 }
84 ok(!RtlNumberGenericTableElements(&Table), "Not zero elements\n");
85 ok(!RtlGetElementGenericTable(&Table, 0), "Elements left when we removed them all\n");
86 ok(strlen(Text) == del + 1, "Deleted too many times\n");
87 ok(IsListEmpty(&Allocations), "Didn't free all memory\n");
88}
89
90START_TEST(RtlSplayTree)
91{
94}
unsigned char BOOLEAN
static void RtlSplayTreeTest()
Definition: RtlSplayTree.c:42
static PVOID NTAPI AllocRoutine(PRTL_GENERIC_TABLE Table, CLONG ByteSize)
Definition: RtlSplayTree.c:26
static RTL_GENERIC_COMPARE_RESULTS NTAPI CompareCharTable(PRTL_GENERIC_TABLE Table, PVOID A, PVOID B)
Definition: RtlSplayTree.c:17
static LIST_ENTRY Allocations
Definition: RtlSplayTree.c:14
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strchr(const char *String, int ch)
Definition: utclib.c:501
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
static VOID del(LPHIST_ENTRY item)
Definition: history.c:199
Definition: ehthrow.cxx:93
Definition: ehthrow.cxx:54
Definition: bufpool.h:45
char * Text
Definition: combotst.c:136
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define A(row, col)
#define B(row, col)
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define InsertTailList(ListHead, Entry)
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define NonPagedPool
Definition: env_spec_w32.h:307
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
VOID NTAPI RtlInitializeGenericTable(IN PRTL_GENERIC_TABLE Table, IN PRTL_GENERIC_COMPARE_ROUTINE CompareRoutine, IN PRTL_GENERIC_ALLOCATE_ROUTINE AllocateRoutine, IN PRTL_GENERIC_FREE_ROUTINE FreeRoutine, IN PVOID TableContext)
Definition: generictable.c:100
ASMGENDATA Table[]
Definition: genincdata.c:61
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define PCHAR
Definition: match.c:90
#define Ch(x, y, z)
Definition: sha2.c:141
base of all file and directory entries
Definition: entries.h:83
Definition: typedefs.h:120
#define LIST_ENTRY(type)
Definition: queue.h:175
struct _LIST_ENTRY * PLIST_ENTRY
#define NTAPI
Definition: typedefs.h:36
uint32_t ULONG
Definition: typedefs.h:59
char * PCHAR
Definition: typedefs.h:51
ULONG CLONG
Definition: umtypes.h:126
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
NTSYSAPI BOOLEAN NTAPI RtlDeleteElementGenericTable(_In_ PRTL_GENERIC_TABLE Table, _In_ PVOID Buffer)
NTSYSAPI PVOID NTAPI RtlInsertElementGenericTable(_In_ PRTL_GENERIC_TABLE Table, _In_reads_bytes_(BufferSize) PVOID Buffer, _In_ CLONG BufferSize, _Out_opt_ PBOOLEAN NewElement)
_Must_inspect_result_ NTSYSAPI PVOID NTAPI RtlEnumerateGenericTable(_In_ PRTL_GENERIC_TABLE Table, _In_ BOOLEAN Restart)
_Must_inspect_result_ NTSYSAPI PVOID NTAPI RtlGetElementGenericTable(_In_ PRTL_GENERIC_TABLE Table, _In_ ULONG I)
NTSYSAPI ULONG NTAPI RtlNumberGenericTableElements(_In_ PRTL_GENERIC_TABLE Table)
_In_ PRTL_GENERIC_COMPARE_ROUTINE _In_ PRTL_GENERIC_ALLOCATE_ROUTINE _In_ PRTL_GENERIC_FREE_ROUTINE FreeRoutine
Definition: rtlfuncs.h:1090
_Must_inspect_result_ NTSYSAPI PVOID NTAPI RtlLookupElementGenericTable(_In_ PRTL_GENERIC_TABLE Table, _In_ PVOID Buffer)
_IRQL_requires_same_ _In_ CLONG ByteSize
Definition: rtltypes.h:399
@ GenericLessThan
Definition: rtltypes.h:376
@ GenericEqual
Definition: rtltypes.h:378
@ GenericGreaterThan
Definition: rtltypes.h:377
enum _RTL_GENERIC_COMPARE_RESULTS RTL_GENERIC_COMPARE_RESULTS
char CHAR
Definition: xmlstorage.h:175