From 3e584471ab302f8f954466450f51462f43592e9b Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 31 May 2011 17:26:30 +0000 Subject: [PATCH] [MSVCRT_APITEST] Add tests for splitpath svn path=/trunk/; revision=52022 --- rostests/apitests/msvcrt/CMakeLists.txt | 12 +++ .../apitests/msvcrt/msvcrt_apitest.rbuild | 13 +++ rostests/apitests/msvcrt/splitpath.c | 94 +++++++++++++++++++ rostests/apitests/msvcrt/testlist.c | 16 ++++ 4 files changed, 135 insertions(+) create mode 100644 rostests/apitests/msvcrt/CMakeLists.txt create mode 100644 rostests/apitests/msvcrt/msvcrt_apitest.rbuild create mode 100644 rostests/apitests/msvcrt/splitpath.c create mode 100644 rostests/apitests/msvcrt/testlist.c diff --git a/rostests/apitests/msvcrt/CMakeLists.txt b/rostests/apitests/msvcrt/CMakeLists.txt new file mode 100644 index 00000000000..fc9797127d9 --- /dev/null +++ b/rostests/apitests/msvcrt/CMakeLists.txt @@ -0,0 +1,12 @@ + +add_definitions(-D_DLL -D__USE_CRTIMP) + +list(APPEND SOURCE + splitpath.c + testlist.c) + +add_executable(msvcrt_apitest ${SOURCE}) +target_link_libraries(msvcrt_apitest wine) +set_module_type(msvcrt_apitest win32cui) +add_importlibs(msvcrt_apitest msvcrt kernel32) +add_cd_file(TARGET msvcrt_apitest DESTINATION reactos/bin FOR all) diff --git a/rostests/apitests/msvcrt/msvcrt_apitest.rbuild b/rostests/apitests/msvcrt/msvcrt_apitest.rbuild new file mode 100644 index 00000000000..ce758772758 --- /dev/null +++ b/rostests/apitests/msvcrt/msvcrt_apitest.rbuild @@ -0,0 +1,13 @@ + + + + + . + wine + pseh + testlist.c + + splitpath.c + + + diff --git a/rostests/apitests/msvcrt/splitpath.c b/rostests/apitests/msvcrt/splitpath.c new file mode 100644 index 00000000000..a8208e0a3af --- /dev/null +++ b/rostests/apitests/msvcrt/splitpath.c @@ -0,0 +1,94 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for _splitpath + * PROGRAMMER: Timo Kreuzer + */ + +#include +#include +#include +#include +#include + +#define ok_str(x, y) \ + ok(strcmp(x, y) == 0, "got '%s', expected '%s'\n", x, y); + +#define ok_int(x, y) \ + ok(x == y, "got %d, expected %d\n", x, y); + +START_TEST(splitpath) +{ + char drive[5]; + char dir[64]; + char fname[32]; + char ext[10]; + + _splitpath("c:\\dir1\\dir2\\file.ext", drive, dir, fname, ext); + ok_str(drive, "c:"); + ok_str(dir, "\\dir1\\dir2\\"); + ok_str(fname, "file"); + ok_str(ext, ".ext"); + + *_errno() = 0; + _splitpath("c:\\dir1\\dir2\\file.ext", 0, 0, 0, 0); + ok_int(*_errno(), 0); + + *_errno() = 0; + _splitpath(0, drive, dir, fname, ext); + ok_int(*_errno(), EINVAL); + ok_str(drive, ""); + ok_str(dir, ""); + ok_str(fname, ""); + ok_str(ext, ""); + + _splitpath("\\\\?\\c:\\dir1\\dir2\\file.ext", drive, dir, fname, ext); + ok_str(drive, "c:"); + ok_str(dir, "\\dir1\\dir2\\"); + ok_str(fname, "file"); + ok_str(ext, ".ext"); + + _splitpath("ab:\\dir1\\..\\file", drive, dir, fname, ext); + ok_str(drive, ""); + ok_str(dir, "ab:\\dir1\\..\\"); + ok_str(fname, "file"); + ok_str(ext, ""); + + _splitpath("//?/c:/dir1/dir2/file.ext", drive, dir, fname, ext); + ok_str(drive, ""); + ok_str(dir, "//?/c:/dir1/dir2/"); + ok_str(fname, "file"); + ok_str(ext, ".ext"); + + _splitpath("\\\\?\\0:/dir1\\dir2/file.", drive, dir, fname, ext); + ok_str(drive, "0:"); + ok_str(dir, "/dir1\\dir2/"); + ok_str(fname, "file"); + ok_str(ext, "."); + + _splitpath("\\\\.\\c:\\dir1\\dir2\\.ext.ext2", drive, dir, fname, ext); + ok_str(drive, ""); + ok_str(dir, "\\\\.\\c:\\dir1\\dir2\\"); + ok_str(fname, ".ext"); + ok_str(ext, ".ext2"); + + _splitpath("\\??\\c:\\dir1\\dir2\\file. ~ ", drive, dir, fname, ext); + ok_str(drive, ""); + ok_str(dir, "\\??\\c:\\dir1\\dir2\\"); + ok_str(fname, "file"); + ok_str(ext, ". ~ "); + + _splitpath("x: dir1\\/dir2 \\.blub", drive, dir, fname, ext); + ok_str(drive, "x:"); + ok_str(dir, " dir1\\/dir2 \\"); + ok_str(fname, ""); + ok_str(ext, ".blub"); + + _splitpath("/:\\dir1\\dir2\\file.ext", drive, dir, fname, ext); + ok_str(drive, "/:"); + ok_str(dir, "\\dir1\\dir2\\"); + ok_str(fname, "file"); + ok_str(ext, ".ext"); + +} + diff --git a/rostests/apitests/msvcrt/testlist.c b/rostests/apitests/msvcrt/testlist.c new file mode 100644 index 00000000000..d54fb7efc9f --- /dev/null +++ b/rostests/apitests/msvcrt/testlist.c @@ -0,0 +1,16 @@ +#define WIN32_LEAN_AND_MEAN +#define __ROS_LONG64__ +#include + +#define STANDALONE +#include "wine/test.h" + +extern void func_splitpath(void); + +const struct test winetest_testlist[] = +{ + { "splitpath", func_splitpath }, + + { 0, 0 } +}; +