Boost C++ Libraries: Ticket #13287: Broken wchar EQUAL https://svn.boost.org/trac10/ticket/13287 <p> boost: boost_1_65_1-msvc-14.1-32.exe </p> <p> Problem description: BOOST_REQUIRE_EQUAL does not work with unicode arguments on windows platform with official boost dlls. </p> <p> Namely does not </p> <p> 1) compile with std::wstring (see example 1 below) </p> <p> 2) link with wchar_t* (see example 2 below) </p> <p> arguments on windows platform with official boost dlls. </p> <p> Some analysis from my side. </p> <p> Could not test static libraries, as could not figure out how to link against official static libs. </p> <p> I was able to build static boost test lib manually as described at <a href="http://www.boost.org/doc/libs/1_65_1/libs/test/doc/html/boost_test/adv_scenarios/static_lib_customizations/entry_point.html">http://www.boost.org/doc/libs/1_65_1/libs/test/doc/html/boost_test/adv_scenarios/static_lib_customizations/entry_point.html</a>. I.e. b2 --with-test link=static define=BOOST_TEST_NO_MAIN define=BOOST_TEST_ALTERNATIVE_INIT_API </p> <p> and make BOOST_REQUIRE_EQUAL to accept wchar_t. See example 3 below. Unfortunately example 3 did not compile with official binaries (?!) </p> <p> boost::test_tools::tt_detail::equal_impl(wchar_t const *,wchar_t const *) is lost in dlls, but available in static lib. In boost_1_54_0-msvc-11.0-32.exe however, equal_impl(wchar_t const *,wchar_t const *) is available in boost_unit_test_framework-vc110-1_54.dll. </p> <p> --- Example 1 --- </p> <pre class="wiki"> #include &lt;iostream&gt; #include &lt;memory&gt; #include &lt;string&gt; #define BOOST_TEST_MODULE test_module_name #define BOOST_TEST_DYN_LINK #define BOOST_TEST_NO_MAIN #include &lt;boost/test/unit_test.hpp&gt; BOOST_AUTO_TEST_SUITE( boost_my_test ); BOOST_AUTO_TEST_CASE(boost_my_test_1) { std::wstring v1(L"a"); std::wstring v2(L"a"); BOOST_REQUIRE_EQUAL(v1, v2); } BOOST_AUTO_TEST_SUITE_END(); int main(int argc, char* argv[], char* envp[]) { return boost::unit_test::unit_test_main( &amp;init_unit_test, argc, argv ); } </pre><p> Error: </p> <pre class="wiki">D:\LIBS\boost\boost-1_65_1\boost/test/tools/detail/print_helper.hpp(52): error C2338: Type has to implement operator&lt;&lt; to be printable D:\LIBS\boost\boost-1_65_1\boost/test/tools/detail/print_helper.hpp(61): note: see reference to function template instantiation 'std::ostream &amp;boost::test_tools::tt_detail::impl::boost_test_print_type&lt;R&gt;(std::ostream &amp;,const T &amp;)' being compiled with [ R=std::wstring, T=std::wstring ] </pre><p> --- Example 2 --- </p> <pre class="wiki">#include &lt;iostream&gt; #include &lt;memory&gt; #include &lt;string&gt; #define BOOST_TEST_MODULE test_module_name #define BOOST_TEST_DYN_LINK #define BOOST_TEST_NO_MAIN #include &lt;boost/test/unit_test.hpp&gt; BOOST_AUTO_TEST_SUITE( boost_my_test ); BOOST_AUTO_TEST_CASE(boost_my_test_1) { const wchar_t* v1 = L"a"; const wchar_t* v2 = L"a"; BOOST_REQUIRE_EQUAL(v1, v2); } BOOST_AUTO_TEST_SUITE_END(); int main(int argc, char* argv[], char* envp[]) { return boost::unit_test::unit_test_main( &amp;init_unit_test, argc, argv ); } </pre><p> Error: </p> <pre class="wiki"> error LNK2001: unresolved external symbol "__declspec(dllimport) class boost::test_tools::assertion_result __cdecl boost::test_tools::tt_detail::equal_impl(wchar_t const *,wchar_t const *)" (__imp_?equal_impl@tt_detail@test_tools@boost@@YA?AVassertion_result@23@PB_W0@Z) </pre><p> -- Example 3 -- </p> <pre class="wiki"> #include &lt;iostream&gt; #include &lt;memory&gt; #include &lt;string&gt; #define BOOST_TEST_MODULE test_module_name #define BOOST_TEST_NO_MAIN #define BOOST_TEST_ALTERNATIVE_INIT_API #include &lt;boost/test/unit_test.hpp&gt; BOOST_AUTO_TEST_SUITE( boost_my_test ); BOOST_AUTO_TEST_CASE(boost_my_test_1) { const wchar_t* v1 = L"a"; const wchar_t* v2 = L"a"; BOOST_REQUIRE_EQUAL(v1, v2); } BOOST_AUTO_TEST_SUITE_END(); int main(int argc, char* argv[], char* envp[]) { return boost::unit_test::unit_test_main(init_unit_test, argc, argv); } </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/13287 Trac 1.4.3