2 * Unit test suite for directory functions.
4 * Copyright 2002 Dmitry Timoshkov
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "wine/test.h"
25 /* If you change something in these tests, please do the same
26 * for GetSystemDirectory tests.
28 static void test_GetWindowsDirectoryA(void)
30 UINT len, len_with_null;
34 len_with_null = GetWindowsDirectoryA(buf, 1);
35 ok(lstrcmpA(buf, "foo") == 0, "should not touch the buffer");
36 ok(len_with_null <= MAX_PATH, "should fit into MAX_PATH");
39 len = GetWindowsDirectoryA(buf, len_with_null - 1);
40 ok(lstrcmpA(buf, "foo") == 0, "should not touch the buffer");
41 ok(len == len_with_null, "should return length with terminating 0");
44 len = GetWindowsDirectoryA(buf, len_with_null);
45 ok(lstrcmpA(buf, "foo") != 0, "should touch the buffer");
46 ok(len == lstrlenA(buf), "returned length should be equal to the length of string");
47 ok(len == (len_with_null - 1), "should return length without terminating 0");
50 static void test_GetWindowsDirectoryW(void)
52 UINT len, len_with_null;
54 static const WCHAR fooW[] = {'f','o','o',0};
57 len_with_null = GetWindowsDirectoryW(buf, 1);
58 ok(lstrcmpW(buf, fooW) == 0, "should not touch the buffer");
59 ok(len_with_null <= MAX_PATH, "should fit into MAX_PATH");
62 len = GetWindowsDirectoryW(buf, len_with_null - 1);
63 ok(lstrcmpW(buf, fooW) == 0, "should not touch the buffer");
64 ok(len == len_with_null, "should return length with terminating 0");
67 len = GetWindowsDirectoryW(buf, len_with_null);
68 ok(lstrcmpW(buf, fooW) != 0, "should touch the buffer");
69 ok(len == lstrlenW(buf), "returned length should be equal to the length of string");
70 ok(len == (len_with_null - 1), "should return length without terminating 0");
74 /* If you change something in these tests, please do the same
75 * for GetWindowsDirectory tests.
77 static void test_GetSystemDirectoryA(void)
79 UINT len, len_with_null;
83 len_with_null = GetSystemDirectoryA(buf, 1);
84 ok(lstrcmpA(buf, "foo") == 0, "should not touch the buffer");
85 ok(len_with_null <= MAX_PATH, "should fit into MAX_PATH");
88 len = GetSystemDirectoryA(buf, len_with_null - 1);
89 ok(lstrcmpA(buf, "foo") == 0, "should not touch the buffer");
90 ok(len == len_with_null, "should return length with terminating 0");
93 len = GetSystemDirectoryA(buf, len_with_null);
94 ok(lstrcmpA(buf, "foo") != 0, "should touch the buffer");
95 ok(len == lstrlenA(buf), "returned length should be equal to the length of string");
96 ok(len == (len_with_null - 1), "should return length without terminating 0");
99 static void test_GetSystemDirectoryW(void)
101 UINT len, len_with_null;
103 static const WCHAR fooW[] = {'f','o','o',0};
106 len_with_null = GetSystemDirectoryW(buf, 1);
107 ok(lstrcmpW(buf, fooW) == 0, "should not touch the buffer");
108 ok(len_with_null <= MAX_PATH, "should fit into MAX_PATH");
111 len = GetSystemDirectoryW(buf, len_with_null - 1);
112 ok(lstrcmpW(buf, fooW) == 0, "should not touch the buffer");
113 ok(len == len_with_null, "should return length with terminating 0");
116 len = GetSystemDirectoryW(buf, len_with_null);
117 ok(lstrcmpW(buf, fooW) != 0, "should touch the buffer");
118 ok(len == lstrlenW(buf), "returned length should be equal to the length of string");
119 ok(len == (len_with_null - 1), "should return length without terminating 0");
122 START_TEST(directory)
124 test_GetWindowsDirectoryA();
125 test_GetWindowsDirectoryW();
126 test_GetSystemDirectoryA();
127 test_GetSystemDirectoryW();