Opened 11 years ago
Closed 10 years ago
#6513 closed Bugs (fixed)
assignment vs comparison in unit test
Reported by: | 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.
(In [80709]) Fix typo in test case; Refs #6513