2 * Unit test suite for dir functions
4 * Copyright 2006 CodeWeavers, Aric Stewart
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "wine/test.h"
34 static void test_makepath(void)
36 char buffer[MAX_PATH];
38 _makepath(buffer, "C", "\\foo", "dummy", "txt");
39 ok( strcmp(buffer, "C:\\foo\\dummy.txt") == 0, "unexpected result: %s\n", buffer);
40 _makepath(buffer, "C:", "\\foo\\", "dummy", ".txt");
41 ok( strcmp(buffer, "C:\\foo\\dummy.txt") == 0, "unexpected result: %s\n", buffer);
43 /* this works with native and e.g. Freelancer depends on it */
44 strcpy(buffer, "foo");
45 _makepath(buffer, NULL, buffer, "dummy.txt", NULL);
46 ok( strcmp(buffer, "foo\\dummy.txt") == 0, "unexpected result: %s\n", buffer);
49 static void test_fullpath(void)
52 char tmppath[MAX_PATH];
53 char prevpath[MAX_PATH];
54 char level1[MAX_PATH];
55 char level2[MAX_PATH];
56 char teststring[MAX_PATH];
61 GetCurrentDirectory(MAX_PATH, prevpath);
62 GetTempPath(MAX_PATH,tmppath);
63 strcpy(level1,tmppath);
64 strcat(level1,"msvcrt-test\\");
66 rc = CreateDirectory(level1,NULL);
67 if (!rc && GetLastError()==ERROR_ALREADY_EXISTS)
70 strcpy(level2,level1);
71 strcat(level2,"nextlevel\\");
72 rc = CreateDirectory(level2,NULL);
73 if (!rc && GetLastError()==ERROR_ALREADY_EXISTS)
75 SetCurrentDirectory(level2);
77 ok(_fullpath(full,"test", MAX_PATH)!=NULL,"_fullpath failed\n");
78 strcpy(teststring,level2);
79 strcat(teststring,"test");
80 ok(strcmp(full,teststring)==0,"Invalid Path returned %s\n",full);
81 ok(_fullpath(full,"\\test", MAX_PATH)!=NULL,"_fullpath failed\n");
82 strncpy(teststring,level2,3);
84 strcat(teststring,"test");
85 ok(strcmp(full,teststring)==0,"Invalid Path returned %s\n",full);
86 ok(_fullpath(full,"..\\test", MAX_PATH)!=NULL,"_fullpath failed\n");
87 strcpy(teststring,level1);
88 strcat(teststring,"test");
89 ok(strcmp(full,teststring)==0,"Invalid Path returned %s\n",full);
90 ok(_fullpath(full,"..\\test", 10)==NULL,"_fullpath failed to generate error\n");
92 freeme = _fullpath(NULL,"test", 0);
93 ok(freeme!=NULL,"No path returned\n");
94 strcpy(teststring,level2);
95 strcat(teststring,"test");
96 ok(strcmp(freeme,teststring)==0,"Invalid Path returned %s\n",freeme);
99 SetCurrentDirectory(prevpath);
101 RemoveDirectory(level2);
103 RemoveDirectory(level1);