[test] BOOST_CHECK_EQUAL and wchar_t
The following code: BOOST_CHECK_EQUAL("boo", "boo"); BOOST_CHECK_EQUAL("boo", "bar"); BOOST_CHECK_EQUAL(L"boo", L"boo"); BOOST_CHECK_EQUAL(L"boo", L"bar"); Gives the following results test.cpp(368): error in "Strings": check "boo" == "bar" failed [boo != bar] test.cpp(370): error in "Strings": check L"boo" == L"bar" failed [00B6FAA4 != 00B6FA90] Can this be fixed ?
The following code:
BOOST_CHECK_EQUAL("boo", "boo"); BOOST_CHECK_EQUAL("boo", "bar"); BOOST_CHECK_EQUAL(L"boo", L"boo"); BOOST_CHECK_EQUAL(L"boo", L"bar");
Gives the following results
test.cpp(368): error in "Strings": check "boo" == "bar" failed [boo != bar] test.cpp(370): error in "Strings": check L"boo" == L"bar" failed [00B6FAA4 != 00B6FA90]
Can this be fixed ?
Is this unexpected behavior? B/Rgds Max
Alexander
The following code:
BOOST_CHECK_EQUAL("boo", "boo"); BOOST_CHECK_EQUAL("boo", "bar"); BOOST_CHECK_EQUAL(L"boo", L"boo"); BOOST_CHECK_EQUAL(L"boo", L"bar");
Gives the following results
test.cpp(368): error in "Strings": check "boo" == "bar" failed [boo != bar] test.cpp(370): error in "Strings": check L"boo" == L"bar" failed [00B6FAA4 != 00B6FA90]
Can this be fixed ?
Depends. This particular problem is a result of incorrect printing operation of wchar_t strings into ostream. You can probably implement one yourself, which does the better job. In general there are some issues with wide char support in Boost.Test, but they are not so trivial to address. Especially in backward compatible manner. Gennadiy
This particular problem is a result of incorrect printing operation of wchar_t strings into ostream. You can probably implement one yourself, which does the better job.
The only way I get it called is when I declare it in boost::test_tools namespace: namespace boost { namespace test_tools { std::ostream& operator<<(std::ostream& stream, wchar_t const * s) { return (stream<< CW2A(s)); } } }
Alexander
This particular problem is a result of incorrect printing operation of wchar_t strings into ostream. You can probably implement one yourself, which does the better job.
The only way I get it called is when I declare it in boost::test_tools namespace:
So, now it looks like you desired? Unfortunately, theses are intricates of ADL and I am not sure I can do better at the moment.
So, now it looks like you desired?
Yes, thank you.
Unfortunately, theses are intricates of ADL and I am not sure I can do better at the moment.
May the final printing function be in root namespace, prefixed like boost_test_output ? Or something like "using namespace ::" if there any legal construct like this ? Or document this location (boost::test_tools) to make such hack sound more legal ?
participants (4)
-
Alexader
-
Alexander
-
Gennadiy Rozental
-
Max