[MSVCRT:APITEST]
[reactos.git] / rostests / apitests / msvcrt / splitpath.c
1 /*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for _splitpath
5 * PROGRAMMER: Timo Kreuzer
6 */
7
8 #include <wine/test.h>
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include <strings.h>
12 #include <stdarg.h>
13
14 START_TEST(splitpath)
15 {
16 char drive[5];
17 char dir[64];
18 char fname[32];
19 char ext[10];
20 DWORD Major;
21
22 Major = (DWORD)(LOBYTE(LOWORD(GetVersion())));
23
24 _splitpath("c:\\dir1\\dir2\\file.ext", drive, dir, fname, ext);
25 ok_str(drive, "c:");
26 ok_str(dir, "\\dir1\\dir2\\");
27 ok_str(fname, "file");
28 ok_str(ext, ".ext");
29
30 *_errno() = 0;
31 _splitpath("c:\\dir1\\dir2\\file.ext", 0, 0, 0, 0);
32 ok_int(*_errno(), 0);
33
34 if (Major >= 6)
35 {
36 *_errno() = 0;
37 _splitpath(0, drive, dir, fname, ext);
38 ok_int(*_errno(), EINVAL);
39 ok_str(drive, "");
40 ok_str(dir, "");
41 ok_str(fname, "");
42 ok_str(ext, "");
43 }
44 else
45 {
46 win_skip("This test only succeed on NT6+\n");
47 }
48
49 _splitpath("\\\\?\\c:\\dir1\\dir2\\file.ext", drive, dir, fname, ext);
50 if (Major >= 6)
51 {
52 ok_str(drive, "c:");
53 ok_str(dir, "\\dir1\\dir2\\");
54 }
55 else
56 {
57 ok_str(drive, "");
58 ok_str(dir, "\\\\?\\c:\\dir1\\dir2\\");
59 }
60 ok_str(fname, "file");
61 ok_str(ext, ".ext");
62
63 _splitpath("ab:\\dir1\\..\\file", drive, dir, fname, ext);
64 ok_str(drive, "");
65 ok_str(dir, "ab:\\dir1\\..\\");
66 ok_str(fname, "file");
67 ok_str(ext, "");
68
69 _splitpath("//?/c:/dir1/dir2/file.ext", drive, dir, fname, ext);
70 ok_str(drive, "");
71 ok_str(dir, "//?/c:/dir1/dir2/");
72 ok_str(fname, "file");
73 ok_str(ext, ".ext");
74
75 _splitpath("\\\\?\\0:/dir1\\dir2/file.", drive, dir, fname, ext);
76 if (Major >= 6)
77 {
78 ok_str(drive, "0:");
79 ok_str(dir, "/dir1\\dir2/");
80 }
81 else
82 {
83 ok_str(drive, "");
84 ok_str(dir, "\\\\?\\0:/dir1\\dir2/");
85 }
86 ok_str(fname, "file");
87 ok_str(ext, ".");
88
89 _splitpath("\\\\.\\c:\\dir1\\dir2\\.ext.ext2", drive, dir, fname, ext);
90 ok_str(drive, "");
91 ok_str(dir, "\\\\.\\c:\\dir1\\dir2\\");
92 ok_str(fname, ".ext");
93 ok_str(ext, ".ext2");
94
95 _splitpath("\\??\\c:\\dir1\\dir2\\file. ~ ", drive, dir, fname, ext);
96 ok_str(drive, "");
97 ok_str(dir, "\\??\\c:\\dir1\\dir2\\");
98 ok_str(fname, "file");
99 ok_str(ext, ". ~ ");
100
101 _splitpath("x: dir1\\/dir2 \\.blub", drive, dir, fname, ext);
102 ok_str(drive, "x:");
103 ok_str(dir, " dir1\\/dir2 \\");
104 ok_str(fname, "");
105 ok_str(ext, ".blub");
106
107 _splitpath("/:\\dir1\\dir2\\file.ext", drive, dir, fname, ext);
108 ok_str(drive, "/:");
109 ok_str(dir, "\\dir1\\dir2\\");
110 ok_str(fname, "file");
111 ok_str(ext, ".ext");
112
113 }
114