tests/msvcrt: add test for _splitpath function
Alexander Yastrebov
menone7 at gmail.com
Wed May 18 13:00:13 CDT 2011
--- dlls/msvcrt/tests/dir.c
+++ dlls/msvcrt/tests/dir.c
@@ -33,6 +33,7 @@
static int (__cdecl *p_makepath_s)(char *, size_t, const char *,
const char *, const char *, const char *);
static int (__cdecl *p_wmakepath_s)(wchar_t *, size_t, const wchar_t
*,const wchar_t *, const wchar_t *, const wchar_t *);
+static void (__cdecl *p__splitpath)(const char*,char*,char*,char*,char*);
static void init(void)
{
@@ -40,6 +41,7 @@
p_makepath_s = (void *)GetProcAddress(hmod, "_makepath_s");
p_wmakepath_s = (void *)GetProcAddress(hmod, "_wmakepath_s");
+ p__splitpath = (void *)GetProcAddress(hmod, "_splitpath");
}
typedef struct
@@ -390,6 +392,57 @@
RemoveDirectory(level1);
}
+void test__splitpath(void)
+{
+ int i;
+ struct {
+ char* Path;
+ char* Drive;
+ char* Dir;
+ char* Fname;
+ char* Ext;
+ } Paths[] = { {"C:/directory/test.txt", "C:", "/directory/",
"test", ".txt"},
+ {"C:\\directory\\test.txt", "C:", "\\directory\\",
"test", ".txt"},
+ {"C:\\directory\\test", "C:", "\\directory\\", "test", ""},
+ {"C:\\directory\\.txt", "C:", "\\directory\\", "", ".txt"},
+ {"C:\\directory\\", "C:", "\\directory\\", "", ""},
+ {"C:\\test.txt", "C:", "\\", "test", ".txt"},
+ {"C:\\test", "C:", "\\", "test", ""},
+ {"C:\\.txt", "C:", "\\", "", ".txt"},
+ {"C:\\", "C:", "\\", "", ""},
+ {"\\directory\\test.txt", "", "\\directory\\", "test", ".txt"},
+ {"\\directory\\test", "", "\\directory\\", "test", ""},
+ {"\\directory\\.txt", "", "\\directory\\", "", ".txt"},
+ {"\\directory\\", "", "\\directory\\", "", ""},
+ {"\\test.txt", "", "\\", "test", ".txt"},
+ {"\\test", "", "\\", "test", ""},
+ {"\\.txt", "", "\\", "", ".txt"},
+ {"\\", "", "\\", "", ""},
+ {"test.txt", "", "", "test", ".txt"},
+ {"test", "", "", "test", ""},
+ {".txt", "", "", "", ".txt"},
+ {"", "", "", "", ""}};
+
+ char Drive[32];
+ char Dir[32];
+ char Fname[32];
+ char Ext[32];
+
+ for(i=0; i < sizeof(Paths) / sizeof(*Paths); i++)
+ {
+ memset(Drive, 0xfe, sizeof(Drive));
+ memset(Dir, 0xfe, sizeof(Dir));
+ memset(Fname, 0xfe, sizeof(Fname));
+ memset(Ext, 0xfe, sizeof(Ext));
+
+ p__splitpath(Paths[i].Path, Drive, Dir, Fname, Ext);
+ ok(!strcmp(Drive, Paths[i].Drive), "For %d path expected %s,
got %s\n", i, Paths[i].Drive, Drive);
+ ok(!strcmp(Dir, Paths[i].Dir), "For %d path expected %s, got
%s\n", i, Paths[i].Dir, Dir);
+ ok(!strcmp(Fname, Paths[i].Fname), "For %d path expected %s,
got %s\n", i, Paths[i].Fname, Fname);
+ ok(!strcmp(Ext, Paths[i].Ext), "For %d path expected %s, got
%s\n", i, Paths[i].Ext, Ext);
+ }
+}
+
START_TEST(dir)
{
init();
@@ -397,4 +450,5 @@
test_fullpath();
test_makepath();
test_makepath_s();
+ test__splitpath();
}
More information about the wine-patches
mailing list