Boost logo

Boost :

Subject: Re: [boost] [teeks99][test] Test failures on MSVC 8-11
From: Paul A. Bristow (pbristow_at_[hidden])
Date: 2015-11-22 12:26:45


> -----Original Message-----
> From: Boost [mailto:boost-bounces_at_[hidden]] On Behalf Of Bjorn Reese
> Sent: 22 November 2015 16:21
> To: boost_at_[hidden]
> Subject: Re: [boost] [teeks99][test] Test failures on MSVC 8-11
>
> On 11/21/2015 09:54 PM, Raffi Enficiaud wrote:
>
> > #ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST
> > static std::map<char,char const*> const char_type{{
> > {'<' , "lt"},
> > {'>' , "gt"},
> > {'&' , "amp"},
> > {'\'', "apos"},
> > {'"' , "quot"}
> > }};
> > #else /.../
>
> I would replace the std::map with a switch statement in this case. Then there is no need for an
> #ifndef.
>
> >> http://www.boost.org/development/tests/develop/developer/output/igazt
> >> anaga-gcc-5-1c++14-boost-bin-v2-libs-log-test-attr_function-test-gcc-
> >> mngw-5-1c+-dbg-dbg-symbl-off-thrd-mlt.html
> >>
> >>
> > and maybe because of "-Werror=sign-compare" ? or again this is hiding
> > something else that was cut off in the report...
>
> The problem is that if we test an unsigned integer against a literal integer value, then we a
warning in
> the first test but not the second:
>
> unsigned int value = 1;
> BOOST_REQUIRE(value == 1); // No sign compare warning
> BOOST_REQUIRE_EQUAL(value, 1); // Sign compare warning
>
> The quick fix is for all Boost.Test users to do:
>
> BOOST_REQUIRE_EQUAL(value, 1U);
>
> but this is inconvenient if you do not know the signedness of the type, e.g. when you use a size()
> member function on some container.

I think that Boost.Test behaviour is correct/best here and that users should be providing the right
type for the test, even if a bit more work and/or thought.

For size() items one should best use size_t or size_type?

And in general BOOST_REQUIRE_EQUAL rather than BOOST_REQUIRE
is usually much more helpful in telling *why* the test has failed.

Paul

---
Paul A. Bristow
Prizet Farmhouse
Kendal UK LA8 8AB
+44 (0) 1539 561830

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk