diff --git a/rostests/apitests/kernel32/CMakeLists.txt b/rostests/apitests/kernel32/CMakeLists.txt index 53beb34e832..8d610425934 100644 --- a/rostests/apitests/kernel32/CMakeLists.txt +++ b/rostests/apitests/kernel32/CMakeLists.txt @@ -5,6 +5,7 @@ list(APPEND SOURCE GetCurrentDirectory.c GetDriveType.c GetModuleFileName.c + lstrcpynW.c SetCurrentDirectory.c testlist.c) diff --git a/rostests/apitests/kernel32/lstrcpynW.c b/rostests/apitests/kernel32/lstrcpynW.c new file mode 100644 index 00000000000..102b371f0e4 --- /dev/null +++ b/rostests/apitests/kernel32/lstrcpynW.c @@ -0,0 +1,27 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPLv2+ - See COPYING in the top level directory + * PURPOSE: Test for lstrcpynW + */ + +#define WIN32_NO_STATUS +#include +#include +#include + +START_TEST(lstrcpynW) +{ + WCHAR buffer[256]; + + /* Test basic functionality */ + ok(lstrcpynW(buffer, L"Copy this string", 256) == buffer, "lstrncpyW failed!\n"); + ok(!lstrcmpW(buffer, L"Copy this string"), "Copy went wrong.\n"); + + /* Test for buffer too small */ + ok(lstrcpynW(buffer, L"Copy this string", 10) == buffer, "lstrncpyW failed!\n"); + ok(buffer[9] == 0, "lstrncpyW should have NULL-terminated the string"); + ok(!lstrcmpW(buffer, L"Copy this"), "Copy went wrong.\n"); + + /* Test some invalid buffer */ + ok(lstrcpynW((LPWSTR)0xbaadf00d, L"Copy this string", 256) == NULL, "lstrncpyW should have returned NULL.\n"); +} diff --git a/rostests/apitests/kernel32/testlist.c b/rostests/apitests/kernel32/testlist.c index 622c52e084c..3ec27cbb866 100644 --- a/rostests/apitests/kernel32/testlist.c +++ b/rostests/apitests/kernel32/testlist.c @@ -8,6 +8,7 @@ extern void func_GetCurrentDirectory(void); extern void func_GetDriveType(void); extern void func_GetModuleFileName(void); +extern void func_lstrcpynW(void); extern void func_SetCurrentDirectory(void); const struct test winetest_testlist[] = @@ -15,6 +16,7 @@ const struct test winetest_testlist[] = { "GetCurrentDirectory", func_GetCurrentDirectory }, { "GetDriveType", func_GetDriveType }, { "GetModuleFileName", func_GetModuleFileName }, + { "lstrcpynW", func_lstrcpynW }, { "SetCurrentDirectory", func_SetCurrentDirectory }, { 0, 0 }