[TCPIP]
[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 #define ok_str(x, y) \
15 ok(strcmp(x, y) == 0, "got '%s', expected '%s'\n", x, y);
16
17 #define ok_int(x, y) \
18 ok(x == y, "got %d, expected %d\n", x, y);
19
20 START_TEST(splitpath)
21 {
22 char drive[5];
23 char dir[64];
24 char fname[32];
25 char ext[10];
26
27 _splitpath("c:\\dir1\\dir2\\file.ext", drive, dir, fname, ext);
28 ok_str(drive, "c:");
29 ok_str(dir, "\\dir1\\dir2\\");
30 ok_str(fname, "file");
31 ok_str(ext, ".ext");
32
33 *_errno() = 0;
34 _splitpath("c:\\dir1\\dir2\\file.ext", 0, 0, 0, 0);
35 ok_int(*_errno(), 0);
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 _splitpath("\\\\?\\c:\\dir1\\dir2\\file.ext", drive, dir, fname, ext);
46 ok_str(drive, "c:");
47 ok_str(dir, "\\dir1\\dir2\\");
48 ok_str(fname, "file");
49 ok_str(ext, ".ext");
50
51 _splitpath("ab:\\dir1\\..\\file", drive, dir, fname, ext);
52 ok_str(drive, "");
53 ok_str(dir, "ab:\\dir1\\..\\");
54 ok_str(fname, "file");
55 ok_str(ext, "");
56
57 _splitpath("//?/c:/dir1/dir2/file.ext", drive, dir, fname, ext);
58 ok_str(drive, "");
59 ok_str(dir, "//?/c:/dir1/dir2/");
60 ok_str(fname, "file");
61 ok_str(ext, ".ext");
62
63 _splitpath("\\\\?\\0:/dir1\\dir2/file.", drive, dir, fname, ext);
64 ok_str(drive, "0:");
65 ok_str(dir, "/dir1\\dir2/");
66 ok_str(fname, "file");
67 ok_str(ext, ".");
68
69 _splitpath("\\\\.\\c:\\dir1\\dir2\\.ext.ext2", drive, dir, fname, ext);
70 ok_str(drive, "");
71 ok_str(dir, "\\\\.\\c:\\dir1\\dir2\\");
72 ok_str(fname, ".ext");
73 ok_str(ext, ".ext2");
74
75 _splitpath("\\??\\c:\\dir1\\dir2\\file. ~ ", drive, dir, fname, ext);
76 ok_str(drive, "");
77 ok_str(dir, "\\??\\c:\\dir1\\dir2\\");
78 ok_str(fname, "file");
79 ok_str(ext, ". ~ ");
80
81 _splitpath("x: dir1\\/dir2 \\.blub", drive, dir, fname, ext);
82 ok_str(drive, "x:");
83 ok_str(dir, " dir1\\/dir2 \\");
84 ok_str(fname, "");
85 ok_str(ext, ".blub");
86
87 _splitpath("/:\\dir1\\dir2\\file.ext", drive, dir, fname, ext);
88 ok_str(drive, "/:");
89 ok_str(dir, "\\dir1\\dir2\\");
90 ok_str(fname, "file");
91 ok_str(ext, ".ext");
92
93 }
94