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