2
0
mirror of https://github.com/boostorg/gil.git synced 2026-02-27 05:02:19 +00:00

Fix GCC -Wsign-compare warning in tests (#217)

Fixes at least two warnings issued by channel tests due to
comparison of unsigned channel value with signed integer 1:

../../boost/test/tools/assertion.hpp:72:13:
  warning: comparison between signed and unsigned
    integer expressions [-Wsign-compare]
This commit is contained in:
Mateusz Loskot
2019-01-19 15:05:35 +01:00
committed by GitHub
parent 585e9226c8
commit e22c7cb108
2 changed files with 13 additions and 8 deletions

View File

@@ -27,6 +27,7 @@ void test_channel_arithmetic_mutable(boost::mpl::true_)
using channel_value_t = typename fixture_t::channel_value_t;
fixture_t f;
channel_value_t const v = f.min_v_;
channel_value_t const one = 1;
++f.min_v_;
f.min_v_++;
@@ -34,16 +35,16 @@ void test_channel_arithmetic_mutable(boost::mpl::true_)
f.min_v_--;
BOOST_TEST(v == f.min_v_);
f.min_v_ += 1;
f.min_v_ -= 1;
f.min_v_ += one;
f.min_v_ -= one;
BOOST_TEST(v == f.min_v_);
f.min_v_ *= 1;
f.min_v_ /= 1;
f.min_v_ *= one;
f.min_v_ /= one;
BOOST_TEST(v == f.min_v_);
f.min_v_ = 1; // assignable to scalar
BOOST_TEST(f.min_v_ == 1);
f.min_v_ = one; // assignable to scalar
BOOST_TEST(f.min_v_ == one);
f.min_v_ = v; // and to value type
BOOST_TEST(f.min_v_ == v);

View File

@@ -18,14 +18,18 @@ namespace fixture = boost::gil::test::fixture;
template <typename ChannelFixtureBase>
void test_channel_relation()
{
fixture::channel<ChannelFixtureBase> f;
using fixture_t = fixture::channel<ChannelFixtureBase>;
using channel_value_t = typename fixture_t::channel_value_t;
channel_value_t const one = 1;
fixture_t f;
BOOST_TEST(f.min_v_ <= f.max_v_);
BOOST_TEST(f.max_v_ >= f.min_v_);
BOOST_TEST(f.min_v_ < f.max_v_);
BOOST_TEST(f.max_v_ > f.min_v_);
BOOST_TEST(f.max_v_ != f.min_v_);
BOOST_TEST(f.min_v_ == f.min_v_);
BOOST_TEST(f.min_v_ != 1); // comparable to integral
BOOST_TEST(f.min_v_ != one); // comparable to integral
}
BOOST_AUTO_TEST_CASE_TEMPLATE(channel_value, Channel, fixture::channel_byte_types)