Reactos
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 PathIsTemporaryA/W
5 * COPYRIGHT: Copyright 2023 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
6 */
7
8#include "shelltest.h"
9#include <undocshell.h>
10
11static void Test_PathIsTemporaryA(void)
12{
13 CHAR szPath[MAX_PATH];
14 ok_int(PathIsTemporaryA("C:\\"), FALSE);
15 ok_int(PathIsTemporaryA("C:\\TestTestTest"), FALSE);
16
17 GetWindowsDirectoryA(szPath, _countof(szPath));
18 ok_int(PathIsTemporaryA(szPath), FALSE);
19
20 GetTempPathA(_countof(szPath), szPath);
21 ok_int(PathIsTemporaryA(szPath), TRUE);
22
23 if (_WIN32_WINNT <= _WIN32_WINNT_WS03)
24 {
25 /* This is not reliable on Vista+ */
26 PathAppendA(szPath, "TestTestTest");
27 ok_int(PathIsTemporaryA(szPath), FALSE);
28 }
29
30 CreateDirectoryA(szPath, NULL);
31 ok_int(PathIsTemporaryA(szPath), TRUE);
32
33 RemoveDirectoryA(szPath);
34}
35
36static void Test_PathIsTemporaryW(void)
37{
38 WCHAR szPath[MAX_PATH];
39 ok_int(PathIsTemporaryW(L"C:\\"), FALSE);
40 ok_int(PathIsTemporaryW(L"C:\\TestTestTest"), FALSE);
41
42 GetWindowsDirectoryW(szPath, _countof(szPath));
43 ok_int(PathIsTemporaryW(szPath), FALSE);
44
45 GetTempPathW(_countof(szPath), szPath);
46 ok_int(PathIsTemporaryW(szPath), TRUE);
47
48 if (_WIN32_WINNT <= _WIN32_WINNT_WS03)
49 {
50 /* This is not reliable on Vista+ */
51 PathAppendW(szPath, L"TestTestTest");
52 ok_int(PathIsTemporaryW(szPath), FALSE);
53 }
54
55 CreateDirectoryW(szPath, NULL);
56 ok_int(PathIsTemporaryW(szPath), TRUE);
57
58 RemoveDirectoryW(szPath);
59}
60
61START_TEST(PathIsTemporary)
62{
63 Test_PathIsTemporaryA();
64 Test_PathIsTemporaryW();
65}