Opened 5 years ago
Closed 5 years ago
#13237 closed Bugs (worksforme)
BOOST_TEST comparing two char*/wchar_t*
| Reported by: | Owned by: | Gennadiy Rozental | |
|---|---|---|---|
| Milestone: | To Be Determined | Component: | test |
| Version: | Boost 1.65.0 | Severity: | Problem |
| Keywords: | Cc: |
Description
BOOST_TEST should compare pointers, not strings.
Consider:
char s[] = {65, 0, 65, 0};
char *c1 = &s[0], *c2 = &s[2];
if (c1 != c2)
{
BOOST_TEST(c1 != c2);
}
Error looks like this:
check c1 != c2 has failed [A == A]
With wchar_t:
check c1 != c2 has failed [0x7ffc3b6d9bb0 == 0x7ffc3b6d9bb8]
Change History (2)
comment:1 by , 5 years ago
comment:2 by , 5 years ago
| Resolution: | → worksforme |
|---|---|
| Status: | new → closed |
Note that BOOST_TEST does not support wchar_t comparisons well, as mentioned in other bug reports. Closing this ticket.
Note:
See TracTickets
for help on using tickets.

This is well explained in the documentation: http://www.boost.org/doc/libs/1_65_1/libs/test/doc/html/boost_test/testing_tools/extended_comparison/strings.html
If you want to compare pointers, maybe you can just use
instead?