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_fullpath(void)
37 char tmppath
[MAX_PATH
];
38 char prevpath
[MAX_PATH
];
39 char level1
[MAX_PATH
];
40 char level2
[MAX_PATH
];
41 char teststring
[MAX_PATH
];
46 GetCurrentDirectory(MAX_PATH
, prevpath
);
47 GetTempPath(MAX_PATH
,tmppath
);
48 strcpy(level1
,tmppath
);
49 strcat(level1
,"msvcrt-test\\");
51 rc
= CreateDirectory(level1
,NULL
);
52 if (!rc
&& GetLastError()==ERROR_ALREADY_EXISTS
)
55 strcpy(level2
,level1
);
56 strcat(level2
,"nextlevel\\");
57 rc
= CreateDirectory(level2
,NULL
);
58 if (!rc
&& GetLastError()==ERROR_ALREADY_EXISTS
)
60 SetCurrentDirectory(level2
);
62 ok(_fullpath(full
,"test", MAX_PATH
)!=NULL
,"_fullpath failed\n");
63 strcpy(teststring
,level2
);
64 strcat(teststring
,"test");
65 ok(strcmp(full
,teststring
)==0,"Invalid Path returned %s\n",full
);
66 ok(_fullpath(full
,"\\test", MAX_PATH
)!=NULL
,"_fullpath failed\n");
67 strncpy(teststring
,level2
,3);
69 strcat(teststring
,"test");
70 ok(strcmp(full
,teststring
)==0,"Invalid Path returned %s\n",full
);
71 ok(_fullpath(full
,"..\\test", MAX_PATH
)!=NULL
,"_fullpath failed\n");
72 strcpy(teststring
,level1
);
73 strcat(teststring
,"test");
74 ok(strcmp(full
,teststring
)==0,"Invalid Path returned %s\n",full
);
75 ok(_fullpath(full
,"..\\test", 10)==NULL
,"_fullpath failed to generate error\n");
77 freeme
= _fullpath(NULL
,"test", 0);
78 ok(freeme
!=NULL
,"No path returned\n");
79 strcpy(teststring
,level2
);
80 strcat(teststring
,"test");
81 ok(strcmp(freeme
,teststring
)==0,"Invalid Path returned %s\n",freeme
);
84 SetCurrentDirectory(prevpath
);
86 RemoveDirectory(level2
);
88 RemoveDirectory(level1
);