Opened 10 months ago

#12814 new Bugs

BOOST_TEST_EQ has wrong behavior for const char*

Reported by: Hans Dembinski <hans.dembinski@…> Owned by: Peter Dimov
Milestone: To Be Determined Component: core
Version: Boost 1.61.0 Severity: Problem
Keywords: Cc:


BOOST_TEST_EQ internally compares its arguments using test_eq_impl, which calls operator==. If BOOST_TEST_EQ is called with two c-strings of type const char*, it compares the addresses, not the strings.

The following fails, while it should succeed:

const char* s1 = "abc"; std::string s2("abc"); BOOST_TEST_EQ(s1, s2.c_str()); fails

Solution: Add an overload for boost::detail::test_eq_impl which compares const char* using std::strcmp.

Similarly for test_ne_impl.

Attachments (0)

Change History (0)

Modify Ticket

Change Properties
Set your email in Preferences
as new The owner will remain Peter Dimov.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.