Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / gil / test / core / algorithm / for_each_pixel.cpp
1 //
2 // Copyright 2018 Mateusz Loskot <mateusz at loskot dot net>
3 //
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
7 //
8 #include <boost/gil/algorithm.hpp>
9 #include <boost/gil/image.hpp>
10
11 #include <boost/core/lightweight_test.hpp>
12
13 namespace gil = boost::gil;
14
15 void test_lambda_expression()
16 {
17     gil::gray8_pixel_t const gray128(128);
18     gil::gray8_image_t image(2, 2, gray128);
19
20     int sum{0};
21     gil::for_each_pixel(gil::view(image), [&sum](gil::gray8_pixel_t& p) {
22         sum += gil::at_c<0>(p);
23     });
24     BOOST_TEST(sum == 2 * 2 * 128);
25 }
26
27 int main()
28 {
29     test_lambda_expression();
30
31     return boost::report_errors();
32 }