ReactOS 0.4.15-dev-8002-gbbb3b00
PathIsEqualOrSubFolder.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS API Tests
3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4 * PURPOSE: Tests for PathIsEqualOrSubFolder
5 * COPYRIGHT: Copyright 2023 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
6 */
7
8#include "shelltest.h"
9#include <undocshell.h>
10
12{
14 ok_int(PathIsEqualOrSubFolder(L"C:", L"C:\\"), TRUE);
15 ok_int(PathIsEqualOrSubFolder(L"C:\\", L"C:"), TRUE);
16 ok_int(PathIsEqualOrSubFolder(L"C:\\", L"C:\\"), TRUE);
17 ok_int(PathIsEqualOrSubFolder(L"C:\\", L"C:\\TestTestTest"), TRUE);
18 ok_int(PathIsEqualOrSubFolder(L"C:\\TestTestTest", L"C:\\"), FALSE);
19 ok_int(PathIsEqualOrSubFolder(L"C:\\TestTestTest", L"C:\\TestTestTest"), TRUE);
20 ok_int(PathIsEqualOrSubFolder(L"C:\\TestTestTest", L"C:\\TestTestTest\\"), TRUE);
21
22 WCHAR szPath1[MAX_PATH], szPath2[MAX_PATH];
23
24 GetWindowsDirectoryW(szPath1, _countof(szPath1));
25 ok_int(PathIsEqualOrSubFolder(szPath1, szPath1), TRUE);
26
27 GetWindowsDirectoryW(szPath2, _countof(szPath2));
28 PathAppendW(szPath2, L"TestTestTest");
29
30 ok_int(PathIsEqualOrSubFolder(szPath1, szPath2), TRUE);
31 ok_int(PathIsEqualOrSubFolder(szPath2, szPath1), FALSE);
32 ok_int(PathIsEqualOrSubFolder(szPath2, szPath2), TRUE);
33
34 GetTempPathW(_countof(szPath1), szPath1);
35 GetTempPathW(_countof(szPath2), szPath2);
36 PathAppendW(szPath2, L"TestTestTest");
37
38 ok_int(PathIsEqualOrSubFolder(szPath1, szPath2), TRUE);
39 ok_int(PathIsEqualOrSubFolder(szPath2, szPath1), FALSE);
40 ok_int(PathIsEqualOrSubFolder(szPath2, szPath2), TRUE);
41}
#define START_TEST(x)
Definition: atltest.h:75
#define ok_int(expression, result)
Definition: atltest.h:134
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define MAX_PATH
Definition: compat.h:34
DWORD WINAPI GetTempPathW(IN DWORD count, OUT LPWSTR path)
Definition: path.c:2080
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2352
EXTERN_C BOOL WINAPI PathIsEqualOrSubFolder(_In_ LPCWSTR pszPath1OrCSIDL, _In_ LPCWSTR pszPath2)
Definition: utils.cpp:1219
#define L(x)
Definition: ntvdm.h:50
#define PathAppendW
Definition: pathcch.h:309
#define _countof(array)
Definition: sndvol32.h:68
__wchar_t WCHAR
Definition: xmlstorage.h:180