Index: reactos/sdk/lib/atl/cstringt.h =================================================================== --- reactos/sdk/lib/atl/cstringt.h (revision 74140) +++ reactos/sdk/lib/atl/cstringt.h (working copy) @@ -326,48 +326,52 @@ *this = static_cast(strSrc); } +protected: + /* helper function */ + template + void LoadFromPtr_(_In_opt_z_ const T_CHAR* pszSrc) + { + if (pszSrc == NULL) + return; + if (IS_INTRESOURCE(pszSrc)) + LoadString(LOWORD(pszSrc)); + else + *this = pszSrc; + } + +public: CStringT(_In_opt_z_ const XCHAR* pszSrc) : - CThisSimpleString( StringTraits::GetDefaultManager() ) + CThisSimpleString(StringTraits::GetDefaultManager()) { - // FIXME: Check whether pszSrc is not a resource string ID! - *this = pszSrc; + LoadFromPtr_(pszSrc); } - CStringT( - _In_opt_z_ const XCHAR* pszSrc, - _In_ IAtlStringMgr* pStringMgr) : - CThisSimpleString( pStringMgr ) + CStringT(_In_opt_z_ const XCHAR* pszSrc, + _In_ IAtlStringMgr* pStringMgr) : CThisSimpleString(pStringMgr) { - // FIXME: Check whether pszSrc is not a resource string ID! - *this = pszSrc; + LoadFromPtr_(pszSrc); } CStringT(_In_opt_z_ const YCHAR* pszSrc) : - CThisSimpleString( StringTraits::GetDefaultManager() ) + CThisSimpleString(StringTraits::GetDefaultManager()) { - // FIXME: Check whether pszSrc is not a resource string ID! - *this = pszSrc; + LoadFromPtr_(pszSrc); } - CStringT( - _In_opt_z_ const YCHAR* pszSrc, - _In_ IAtlStringMgr* pStringMgr) : - CThisSimpleString( pStringMgr ) + CStringT(_In_opt_z_ const YCHAR* pszSrc, + _In_ IAtlStringMgr* pStringMgr) : CThisSimpleString(pStringMgr) { - // FIXME: Check whether pszSrc is not a resource string ID! - *this = pszSrc; + LoadFromPtr_(pszSrc); } - CStringT( - _In_reads_z_(nLength) const XCHAR* pch, - _In_ int nLength) : + CStringT(_In_reads_z_(nLength) const XCHAR* pch, + _In_ int nLength) : CThisSimpleString(pch, nLength, StringTraits::GetDefaultManager()) { } - CStringT( - _In_reads_z_(nLength) const YCHAR* pch, - _In_ int nLength) : + CStringT(_In_reads_z_(nLength) const YCHAR* pch, + _In_ int nLength) : CThisSimpleString(pch, nLength, StringTraits::GetDefaultManager()) { } Index: rostests/apitests/atl/CMakeLists.txt =================================================================== --- rostests/apitests/atl/CMakeLists.txt (revision 74140) +++ rostests/apitests/atl/CMakeLists.txt (working copy) @@ -17,7 +17,7 @@ testlist.c atl_apitest.rc) -target_link_libraries(atl_apitest wine uuid) +target_link_libraries(atl_apitest wine atlnew uuid) set_module_type(atl_apitest win32cui) add_importlibs(atl_apitest rpcrt4 ole32 oleaut32 msimg32 gdi32 advapi32 user32 msvcrt kernel32 ntdll) add_rostests_file(TARGET atl_apitest) Index: rostests/apitests/atl/CString.cpp =================================================================== --- rostests/apitests/atl/CString.cpp (revision 74140) +++ rostests/apitests/atl/CString.cpp (working copy) @@ -2,12 +2,70 @@ * PROJECT: ReactOS api tests * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory * PURPOSE: Test for CString - * PROGRAMMER: Mark Jansen + * PROGRAMMERS: Mark Jansen + * Katayama Hirofumi MZ */ #include -#include +#include "resource.h" +#ifdef __REACTOS__ + #include +#else + #include + #include + #include + #include + int g_tests_executed = 0; + int g_tests_failed = 0; + int g_tests_skipped = 0; + const char *g_file = NULL; + int g_line = 0; + void set_location(const char *file, int line) + { + g_file = file; + g_line = line; + } + void ok_func(bool value, const char *fmt, ...) + { + va_list va; + va_start(va, fmt); + if (!value) + { + printf("%s (%d): ", g_file, g_line); + vprintf(fmt, va); + g_tests_failed++; + } + g_tests_executed++; + va_end(va); + } + void skip_func(const char *fmt, ...) + { + va_list va; + va_start(va, fmt); + printf("%s (%d): test skipped: ", g_file, g_line); + vprintf(fmt, va); + g_tests_skipped++; + va_end(va); + } + #undef ok + #define ok(value, ...) do { \ + set_location(__FILE__, __LINE__); \ + ok_func(value, __VA_ARGS__); \ + } while (0) + #define ok_(x1,x2) set_location(x1,x2); ok_func + #define skip(...) do { \ + set_location(__FILE__, __LINE__); \ + skip_func(__VA_ARGS__); \ + } while (0) + #define START_TEST(x) int main(void) + char *wine_dbgstr_w(const wchar_t *wstr) + { + static char buf[512]; + WideCharToMultiByte(CP_ACP, 0, wstr, -1, buf, _countof(buf), NULL, NULL); + return buf; + } +#endif struct traits_test { @@ -123,9 +181,12 @@ #define CStringX CStringW #define _X(x) L ## x #define XCHAR WCHAR +#define YCHAR CHAR #define dbgstrx(x) wine_dbgstr_w(x) #define ok ok_("CStringW:\n" __FILE__, __LINE__) #define GetWindowsDirectoryX GetWindowsDirectoryW +#define MAKEINTRESOURCEX(x) MAKEINTRESOURCEW(x) +#define MAKEINTRESOURCEY(x) MAKEINTRESOURCEA(x) #include "CString.inl" @@ -133,17 +194,23 @@ #undef TEST_NAMEX #undef _X #undef XCHAR +#undef YCHAR #undef dbgstrx #undef ok #undef GetWindowsDirectoryX +#undef MAKEINTRESOURCEX +#undef MAKEINTRESOURCEY #define TEST_NAMEX(name) void test_##name##A() #define CStringX CStringA #define _X(x) x #define XCHAR CHAR +#define YCHAR WCHAR #define dbgstrx(x) (const char*)x #define ok ok_("CStringA:\n" __FILE__, __LINE__) #define GetWindowsDirectoryX GetWindowsDirectoryA +#define MAKEINTRESOURCEX(x) MAKEINTRESOURCEA(x) +#define MAKEINTRESOURCEY(x) MAKEINTRESOURCEW(x) #include "CString.inl" @@ -179,4 +246,12 @@ test_envW(); test_envA(); + + test_load_strW(); + test_load_strA(); + +#ifndef __REACTOS__ + printf("CString: %i tests executed (0 marked as todo, %i failures), %i skipped.\n", g_tests_executed, g_tests_failed, g_tests_skipped); + return 0; +#endif } Index: rostests/apitests/atl/CString.inl =================================================================== --- rostests/apitests/atl/CString.inl (revision 74140) +++ rostests/apitests/atl/CString.inl (working copy) @@ -388,3 +388,39 @@ ok(test.IsEmpty() == true, "Expected test to be empty\n"); ok(test.GetLength() == 0, "Expected GetLength() to be 0, was: %i\n", test.GetLength()); } + +TEST_NAMEX(load_str) +{ + CStringX str; + + ok(str.LoadString(0) == FALSE, "LoadString should fail.\n"); + + ok(str.LoadString(IDS_TEST1) == TRUE, "LoadString failed.\n"); + ok(str == _X("Test string one."), "The value was '%s'\n", dbgstrx(str)); + + ok(str.LoadString(IDS_TEST2) == TRUE, "LoadString failed.\n"); + ok(str == _X("I am a happy BSTR"), "The value was '%s'\n", dbgstrx(str)); + + ok(str.LoadString(0) == FALSE, "LoadString should fail.\n"); + ok(str == _X("I am a happy BSTR"), "The value was '%s'\n", dbgstrx(str)); + + XCHAR *xNULL = NULL; + CStringX str0(xNULL); + ok(str0.IsEmpty(), "str0 should be empty.\n"); + + YCHAR *yNULL = NULL; + CStringX str1(yNULL); + ok(str1.IsEmpty(), "str1 should be empty.\n"); + + CStringX str2(MAKEINTRESOURCEX(IDS_TEST1)); + ok(str2 == _X("Test string one."), "The value was '%s'\n", dbgstrx(str2)); + + CStringX str3(MAKEINTRESOURCEX(IDS_TEST2)); + ok(str3 == _X("I am a happy BSTR"), "The value was '%s'\n", dbgstrx(str3)); + + CStringX str4(MAKEINTRESOURCEY(IDS_TEST1)); + ok(str4 == _X("Test string one."), "The value was '%s'\n", dbgstrx(str4)); + + CStringX str5(MAKEINTRESOURCEY(IDS_TEST2)); + ok(str5 == _X("I am a happy BSTR"), "The value was '%s'\n", dbgstrx(str5)); +} Index: rostests/apitests/atl/devenv/ATLTest.sln =================================================================== --- rostests/apitests/atl/devenv/ATLTest.sln (revision 74140) +++ rostests/apitests/atl/devenv/ATLTest.sln (working copy) @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.24720.0 +VisualStudioVersion = 14.0.25420.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CImage", "CImage.vcxproj", "{AE520E17-2DAE-40FF-B082-F32A7A935FB2}" EndProject @@ -9,6 +9,8 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CSimpleMap", "CSimpleMap.vcxproj", "{EC560DE6-6DB3-437D-85CA-582491FE6F95}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CString", "CString.vcxproj", "{FBA6DAE7-7996-4DE1-BD03-9E44F7DB4ABD}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -41,6 +43,14 @@ {EC560DE6-6DB3-437D-85CA-582491FE6F95}.Release|x64.Build.0 = Release|x64 {EC560DE6-6DB3-437D-85CA-582491FE6F95}.Release|x86.ActiveCfg = Release|Win32 {EC560DE6-6DB3-437D-85CA-582491FE6F95}.Release|x86.Build.0 = Release|Win32 + {FBA6DAE7-7996-4DE1-BD03-9E44F7DB4ABD}.Debug|x64.ActiveCfg = Debug|x64 + {FBA6DAE7-7996-4DE1-BD03-9E44F7DB4ABD}.Debug|x64.Build.0 = Debug|x64 + {FBA6DAE7-7996-4DE1-BD03-9E44F7DB4ABD}.Debug|x86.ActiveCfg = Debug|Win32 + {FBA6DAE7-7996-4DE1-BD03-9E44F7DB4ABD}.Debug|x86.Build.0 = Debug|Win32 + {FBA6DAE7-7996-4DE1-BD03-9E44F7DB4ABD}.Release|x64.ActiveCfg = Release|x64 + {FBA6DAE7-7996-4DE1-BD03-9E44F7DB4ABD}.Release|x64.Build.0 = Release|x64 + {FBA6DAE7-7996-4DE1-BD03-9E44F7DB4ABD}.Release|x86.ActiveCfg = Release|Win32 + {FBA6DAE7-7996-4DE1-BD03-9E44F7DB4ABD}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE Index: rostests/apitests/atl/devenv/CImage.vcxproj =================================================================== --- rostests/apitests/atl/devenv/CImage.vcxproj (revision 74140) +++ rostests/apitests/atl/devenv/CImage.vcxproj (working copy) @@ -27,13 +27,13 @@ Application true - v120_xp + v140_xp Unicode Application false - v120_xp + v140_xp Unicode @@ -40,12 +40,12 @@ Application true Unicode - v120_xp + v140_xp Application false - v120_xp + v140_xp Unicode Index: rostests/apitests/atl/devenv/CSimpleArray.vcxproj =================================================================== --- rostests/apitests/atl/devenv/CSimpleArray.vcxproj (revision 74140) +++ rostests/apitests/atl/devenv/CSimpleArray.vcxproj (working copy) @@ -27,25 +27,25 @@ Application true - v120_xp + v140_xp Unicode Application false - v120_xp + v140_xp Unicode Application true - v120_xp + v140_xp Unicode Application false - v120_xp + v140_xp Unicode Index: rostests/apitests/atl/devenv/CSimpleMap.vcxproj =================================================================== --- rostests/apitests/atl/devenv/CSimpleMap.vcxproj (revision 74140) +++ rostests/apitests/atl/devenv/CSimpleMap.vcxproj (working copy) @@ -27,25 +27,25 @@ Application true - v120_xp + v140_xp Unicode Application false - v120_xp + v140_xp Unicode Application true - v120_xp + v140_xp Unicode Application false - v120_xp + v140_xp Unicode Index: rostests/apitests/atl/devenv/CString.vcxproj =================================================================== --- rostests/apitests/atl/devenv/CString.vcxproj (nonexistent) +++ rostests/apitests/atl/devenv/CString.vcxproj (working copy) @@ -0,0 +1,189 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {FBA6DAE7-7996-4DE1-BD03-9E44F7DB4ABD} + 8.1 + AtlProj + + + + Application + true + v140_xp + Unicode + + + Application + false + v140_xp + Unicode + + + Application + true + v140_xp + Unicode + + + Application + false + v140_xp + Unicode + + + + + + + + + + + + + + + + + + + + + true + true + + + true + true + + + true + false + + + true + false + + + + NotUsing + Level3 + Disabled + WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) + true + + + 0x0409 + $(IntDir);%(AdditionalIncludeDirectories) + _DEBUG;%(PreprocessorDefinitions) + + + Console + true + true + + + + + NotUsing + Level3 + Disabled + _WINDOWS;_DEBUG;%(PreprocessorDefinitions) + true + + + 0x0409 + $(IntDir);%(AdditionalIncludeDirectories) + _DEBUG;%(PreprocessorDefinitions) + + + Console + true + true + + + + + NotUsing + Level3 + MaxSpeed + WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions) + true + + + 0x0409 + $(IntDir);%(AdditionalIncludeDirectories) + NDEBUG;%(PreprocessorDefinitions) + + + Console + true + true + true + true + + + + + NotUsing + Level3 + MaxSpeed + _WINDOWS;NDEBUG;%(PreprocessorDefinitions) + true + + + 0x0409 + $(IntDir);%(AdditionalIncludeDirectories) + NDEBUG;%(PreprocessorDefinitions) + + + Console + true + true + true + true + + + + + MultiThreaded + MultiThreaded + MultiThreadedDebug + MultiThreadedDebug + NotUsing + NotUsing + NotUsing + NotUsing + + + + + + + + + + + + + + + \ No newline at end of file