[Boost-bugs] [Boost C++ Libraries] #13287: Broken wchar EQUAL

Subject: [Boost-bugs] [Boost C++ Libraries] #13287: Broken wchar EQUAL
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2017-11-04 22:07:01


#13287: Broken wchar EQUAL
------------------------------+-------------------------------
 Reporter: stier08@… | Owner: Gennadiy Rozental
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: test
  Version: Boost 1.65.0 | Severity: Problem
 Keywords: |
------------------------------+-------------------------------
 boost: boost_1_65_1-msvc-14.1-32.exe

 Problem description: BOOST_REQUIRE_EQUAL does not work with unicode
 arguments on windows platform with official boost dlls.

 Namely does not

 1) compile with std::wstring (see example 1 below)

 2) link with wchar_t* (see example 2 below)

 arguments on windows platform with official boost dlls.

 Some analysis from my side.

 Could not test static libraries, as could not figure out how to link
 against official static libs.

 I was able to build static boost test lib manually as described at
 http://www.boost.org/doc/libs/1_65_1/libs/test/doc/html/boost_test/adv_scenarios/static_lib_customizations/entry_point.html.
 I.e. b2 --with-test link=static define=BOOST_TEST_NO_MAIN
 define=BOOST_TEST_ALTERNATIVE_INIT_API

 and make BOOST_REQUIRE_EQUAL to accept wchar_t. See example 3 below.
 Unfortunately example 3 did not compile with official binaries (?!)

 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.

 --- Example 1 ---
 {{{

 #include <iostream>
 #include <memory>
 #include <string>

 #define BOOST_TEST_MODULE test_module_name
 #define BOOST_TEST_DYN_LINK
 #define BOOST_TEST_NO_MAIN
 #include <boost/test/unit_test.hpp>

 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( &init_unit_test, argc, argv );
 }

 }}}

 Error:
 {{{
 D:\LIBS\boost\boost-1_65_1\boost/test/tools/detail/print_helper.hpp(52):
 error C2338: Type has to implement operator<< 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
 &boost::test_tools::tt_detail::impl::boost_test_print_type<R>(std::ostream
 &,const T &)' being compiled
         with
         [
             R=std::wstring,
             T=std::wstring
         ]
 }}}

 --- Example 2 ---
 {{{
 #include <iostream>
 #include <memory>
 #include <string>

 #define BOOST_TEST_MODULE test_module_name
 #define BOOST_TEST_DYN_LINK
 #define BOOST_TEST_NO_MAIN
 #include <boost/test/unit_test.hpp>

 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 );
 }

 }}}
 Error:
 {{{
  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_at_tt_detail_at_test_tools_at_boost@@YA?AVassertion_result_at_23@PB_W0_at_Z)
 }}}

 -- Example 3 --
 {{{

 #include <iostream>
 #include <memory>
 #include <string>

 #define BOOST_TEST_MODULE test_module_name
 #define BOOST_TEST_NO_MAIN
 #define BOOST_TEST_ALTERNATIVE_INIT_API
 #include <boost/test/unit_test.hpp>

 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);
 }

 }}}

-- 
Ticket URL: <https://svn.boost.org/trac10/boost/ticket/13287>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-11-04 22:13:01 UTC