From: Zhiyi Zhang zzhang@codeweavers.com
--- dlls/ntdll/tests/rtl.c | 43 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+)
diff --git a/dlls/ntdll/tests/rtl.c b/dlls/ntdll/tests/rtl.c index 9978c0d878e..ae430256855 100644 --- a/dlls/ntdll/tests/rtl.c +++ b/dlls/ntdll/tests/rtl.c @@ -122,6 +122,7 @@ static NTSTATUS (WINAPI *pRtlRetrieveNtUserPfn)( const UINT64 **client_procsA, const UINT64 **client_workers ); static NTSTATUS (WINAPI *pRtlResetNtUserPfn)(void); static PRTL_SPLAY_LINKS (WINAPI *pRtlSubtreePredecessor)(PRTL_SPLAY_LINKS); +static PRTL_SPLAY_LINKS (WINAPI *pRtlSubtreeSuccessor)(PRTL_SPLAY_LINKS);
static HMODULE hkernel32 = 0; static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL); @@ -173,6 +174,7 @@ static void InitFunctionPtrs(void) pRtlRetrieveNtUserPfn = (void *)GetProcAddress(hntdll, "RtlRetrieveNtUserPfn"); pRtlResetNtUserPfn = (void *)GetProcAddress(hntdll, "RtlResetNtUserPfn"); pRtlSubtreePredecessor = (void *)GetProcAddress(hntdll, "RtlSubtreePredecessor"); + pRtlSubtreeSuccessor = (void *)GetProcAddress(hntdll, "RtlSubtreeSuccessor"); } hkernel32 = LoadLibraryA("kernel32.dll"); ok(hkernel32 != 0, "LoadLibrary failed\n"); @@ -4135,6 +4137,46 @@ static void test_RtlSubtreePredecessor(void) } }
+static void test_RtlSubtreeSuccessor(void) +{ + /* 3 + * / \ + * 1 5 + * / \ / \ + * 0 2 4 6 + */ + static const struct splay_index splay_indices[] = + { + {3, 1, 5}, + {1, 0, 2}, + {5, 4, 6}, + }; + static const int expected_successors[] = {-1, 2, -1, 4, -1, 6, -1}; + RTL_SPLAY_LINKS links[7], *successor; + unsigned int i; + + if (!pRtlSubtreeSuccessor) + { + win_skip("RtlSubtreeSuccessor is unavailable.\n"); + return; + } + + init_splay_indices(links, ARRAY_SIZE(links), splay_indices, ARRAY_SIZE(splay_indices)); + for (i = 0; i < ARRAY_SIZE(expected_successors); i++) + { + winetest_push_context("%d", i); + + successor = pRtlSubtreeSuccessor(&links[i]); + if (expected_successors[i] == -1) + ok(!successor, "Expected NULL, got unexpected %d.\n", (int)(successor - links)); + else + ok(successor == &links[expected_successors[i]], "Expected %d, got unexpected %d.\n", + expected_successors[i], (int)(successor ? successor - links : -1)); + + winetest_pop_context(); + } +} + START_TEST(rtl) { InitFunctionPtrs(); @@ -4188,4 +4230,5 @@ START_TEST(rtl) test_rb_tree(); test_user_procs(); test_RtlSubtreePredecessor(); + test_RtlSubtreeSuccessor(); }