Opened 11 years ago

Closed 10 years ago

#6513 closed Bugs (fixed)

assignment vs comparison in unit test

Reported by: Ulrich Eckhardt <ulrich.eckhardt@…> Owned by: az_sw_dude
Milestone: To Be Determined Component: date_time
Version: Boost 1.48.0 Severity: Problem
Keywords: Cc:

Description

In file date_time\test\gregorian\testdate_input_facet.cpp is the following line:

    check("No extra characters consumed", m = greg_month(Mar) && *sitr == '.');

Compiling with VC8 gives a warning C4800: 'unsigned short' : forcing value to bool 'true' or 'false' (performance warning). I believe the problem is that m is being assigned to, so that the actual expression being given to check() or operator&& is m, which is converted to a boolean. I would also split the test into two lines, just for clarity:

    check("Correct input", m == greg_month(Mar));
    check("No extra characters consumed", *sitr == '.');

I found this bug in 1.48, but it is still present in the trunk, even though in the trunk the tests were converted from the ad-hoc test framework to Boost's general test framework. It might apply to other versions, too.

Change History (2)

comment:1 by Marshall Clow, 10 years ago

(In [80709]) Fix typo in test case; Refs #6513

comment:2 by Marshall Clow, 10 years ago

Resolution: fixed
Status: newclosed

(In [80797]) Merge bug fixes to release; Fixes #5550 Fixes #6136 Fixes #6513 Fixes #7111 Fixes #7112 Fixes #7113 Fixes #7342 Fixes #7426

Note: See TracTickets for help on using tickets.