2 // Copyright 2019 Mateusz Loskot <mateusz at loskot dot net>
4 // Distributed under the Boost Software License, Version 1.0
5 // See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt
8 #include <boost/config.hpp>
9 #include <boost/core/ignore_unused.hpp>
11 #if defined(BOOST_CLANG)
12 #pragma clang diagnostic push
13 #pragma clang diagnostic ignored "-Wconversion"
14 #pragma clang diagnostic ignored "-Wfloat-equal"
15 #pragma clang diagnostic ignored "-Wsign-conversion"
16 #elif BOOST_GCC >= 40700
17 #pragma GCC diagnostic push
18 #pragma GCC diagnostic ignored "-Wconversion"
19 #pragma GCC diagnostic ignored "-Wfloat-equal"
20 #pragma GCC diagnostic ignored "-Wsign-conversion"
23 #include <boost/gil.hpp>
29 #define BOOST_TEST_MODULE test_ext_numeric_test_fixture
30 #include "unit_test.hpp"
31 #include "test_fixture.hpp"
33 namespace gil
= boost::gil
;
34 namespace fixture
= boost::gil::test::fixture
;
36 BOOST_AUTO_TEST_CASE(consecutive_value
)
38 fixture::consecutive_value
<std::uint8_t> v(10);
39 BOOST_TEST(v() = std::uint8_t{11});
40 BOOST_TEST(v() = std::uint8_t{12});
41 BOOST_TEST(v() = std::uint8_t{13});
44 BOOST_AUTO_TEST_CASE(reverse_consecutive_value
)
46 fixture::reverse_consecutive_value
<std::uint8_t> v(10);
47 BOOST_TEST(v() = std::uint8_t{9});
48 BOOST_TEST(v() = std::uint8_t{8});
49 BOOST_TEST(v() = std::uint8_t{7});
52 BOOST_AUTO_TEST_CASE(random_value
)
54 // Generate N pseudo-random values
55 fixture::random_value
<std::uint8_t> random
;
56 std::vector
<std::uint8_t> v(10, 0);
57 for (auto& i
: v
) i
= random();
59 // Require not all of N values are equal (duplicates are possible!)
60 std::sort(v
.begin(), v
.end());
61 auto last
= std::unique(v
.begin(), v
.end());
62 v
.erase(last
, v
.end());
63 BOOST_TEST(v
.size() > 0);
64 BOOST_TEST(v
.size() <= 10);