From f578a8be9c85698a4bb2cc3907c14f6d68d3ebc5 Mon Sep 17 00:00:00 2001 From: Mateusz Loskot Date: Sat, 12 Jan 2019 10:21:01 +0100 Subject: [PATCH] Replace assert() macro with BOOST_ASSERT() macro (#208) Add #include where necessary. Apply minor clean-up near the macro replacements. Closes #96 --- .appveyor.yml | 5 +- .travis.yml | 4 +- include/boost/gil/algorithm.hpp | 21 +- .../boost/gil/bit_aligned_pixel_reference.hpp | 56 ++-- include/boost/gil/channel.hpp | 140 +++++----- include/boost/gil/channel_algorithm.hpp | 95 ++++--- include/boost/gil/color_base.hpp | 14 +- include/boost/gil/color_base_algorithm.hpp | 250 +++++++++--------- .../extension/dynamic_image/dynamic_at_c.hpp | 1 - .../gil/extension/dynamic_image/variant.hpp | 1 - .../gil/extension/io/bmp/detail/read.hpp | 7 +- .../gil/extension/io/png/detail/base.hpp | 6 +- .../gil/extension/io/tiff/detail/read.hpp | 10 +- .../boost/gil/extension/numeric/algorithm.hpp | 5 +- .../boost/gil/extension/numeric/convolve.hpp | 7 +- .../boost/gil/extension/numeric/kernel.hpp | 39 ++- include/boost/gil/image_view_factory.hpp | 8 +- include/boost/gil/io/device.hpp | 10 +- include/boost/gil/io/reader_base.hpp | 4 +- include/boost/gil/iterator_from_2d.hpp | 10 +- include/boost/gil/locator.hpp | 10 +- include/boost/gil/packed_pixel.hpp | 32 ++- include/boost/gil/pixel_iterator.hpp | 1 - include/boost/gil/planar_pixel_iterator.hpp | 1 - include/boost/gil/virtual_locator.hpp | 16 +- numeric/test/numeric.cpp | 35 +-- test/pixel.cpp | 2 +- test/pixel_iterator.cpp | 18 +- toolbox/test/indexed_image_test.cpp | 14 +- 29 files changed, 425 insertions(+), 397 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 719093775..d6bf35b02 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -81,6 +81,7 @@ before_build: ## Direct - git submodule --quiet update --init libs/algorithm - git submodule --quiet update --init libs/array + - git submodule --quiet update --init libs/assert - git submodule --quiet update --init libs/bind - git submodule --quiet update --init libs/concept_check - git submodule --quiet update --init libs/config @@ -91,15 +92,12 @@ before_build: - git submodule --quiet update --init libs/integer - git submodule --quiet update --init libs/iterator - git submodule --quiet update --init libs/lambda - - git submodule --quiet update --init libs/lexical_cast - git submodule --quiet update --init libs/mpl - git submodule --quiet update --init libs/numeric/conversion - git submodule --quiet update --init libs/preprocessor - - git submodule --quiet update --init libs/smart_ptr - git submodule --quiet update --init libs/test - git submodule --quiet update --init libs/type_traits ## Transitive - - git submodule --quiet update --init libs/assert - git submodule --quiet update --init libs/atomic - git submodule --quiet update --init libs/chrono - git submodule --quiet update --init libs/container @@ -120,6 +118,7 @@ before_build: - git submodule --quiet update --init libs/rational - git submodule --quiet update --init libs/regex - git submodule --quiet update --init libs/static_assert + - git submodule --quiet update --init libs/smart_ptr - git submodule --quiet update --init libs/system - git submodule --quiet update --init libs/throw_exception - git submodule --quiet update --init libs/timer diff --git a/.travis.yml b/.travis.yml index ed4ab386b..64cfb16f8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -199,6 +199,8 @@ install: - git submodule --quiet update --init libs/headers ## Direct - git submodule --quiet update --init libs/algorithm + - git submodule --quiet update --init libs/assert + - git submodule --quiet update --init libs/array - git submodule --quiet update --init libs/bind - git submodule --quiet update --init libs/concept_check - git submodule --quiet update --init libs/config @@ -215,8 +217,6 @@ install: - git submodule --quiet update --init libs/test - git submodule --quiet update --init libs/type_traits ## Transitive - - git submodule --quiet update --init libs/assert - - git submodule --quiet update --init libs/array - git submodule --quiet update --init libs/atomic - git submodule --quiet update --init libs/chrono - git submodule --quiet update --init libs/container diff --git a/include/boost/gil/algorithm.hpp b/include/boost/gil/algorithm.hpp index faada5ccc..5c46dc31d 100644 --- a/include/boost/gil/algorithm.hpp +++ b/include/boost/gil/algorithm.hpp @@ -14,13 +14,13 @@ #include #include +#include #include -#include #include #include +#include #include -#include #include #include #include @@ -267,8 +267,9 @@ namespace boost { namespace gil { /// \ingroup ImageViewSTLAlgorithmsCopyPixels /// \brief std::copy for image views template BOOST_FORCEINLINE -void copy_pixels(const View1& src, const View2& dst) { - assert(src.dimensions()==dst.dimensions()); +void copy_pixels(const View1& src, const View2& dst) +{ + BOOST_ASSERT(src.dimensions() == dst.dimensions()); detail::copy_with_2d_iterators(src.begin(),src.end(),dst.begin()); } @@ -704,7 +705,7 @@ void uninitialized_copy_aux(It1 first1, It1 last1, template void uninitialized_copy_pixels(const View1& view1, const View2& view2) { using is_planar = mpl::bool_::value && is_planar::value>; - assert(view1.dimensions()==view2.dimensions()); + BOOST_ASSERT(view1.dimensions() == view2.dimensions()); if (view1.is_1d_traversable() && view2.is_1d_traversable()) detail::uninitialized_copy_aux(view1.begin().x(), view1.end().x(), view2.begin().x(), @@ -935,7 +936,7 @@ namespace boost { namespace gil { /// \brief std::equal for image views template BOOST_FORCEINLINE bool equal_pixels(const View1& v1, const View2& v2) { - assert(v1.dimensions()==v2.dimensions()); + BOOST_ASSERT(v1.dimensions() == v2.dimensions()); return std::equal(v1.begin(),v1.end(),v2.begin()); // std::equal has overloads with GIL iterators for optimal performance } @@ -953,7 +954,7 @@ bool equal_pixels(const View1& v1, const View2& v2) { /// \brief std::transform for image views template BOOST_FORCEINLINE F transform_pixels(const View1& src,const View2& dst, F fun) { - assert(src.dimensions()==dst.dimensions()); + BOOST_ASSERT(src.dimensions() == dst.dimensions()); for (std::ptrdiff_t y=0; y BOOST_FORCEINLINE F transform_pixel_positions(const View1& src,const View2& dst, F fun) { - assert(src.dimensions()==dst.dimensions()); + BOOST_ASSERT(src.dimensions() == dst.dimensions()); typename View1::xy_locator loc=src.xy_at(0,0); for (std::ptrdiff_t y=0; y BOOST_FORCEINLINE F transform_pixel_positions(const View1& src1,const View2& src2,const View3& dst, F fun) { - assert(src1.dimensions()==dst.dimensions()); - assert(src2.dimensions()==dst.dimensions()); + BOOST_ASSERT(src1.dimensions() == dst.dimensions()); + BOOST_ASSERT(src2.dimensions() == dst.dimensions()); typename View1::xy_locator loc1=src1.xy_at(0,0); typename View2::xy_locator loc2=src2.xy_at(0,0); for (std::ptrdiff_t y=0; y #include +#include #include #include #include @@ -45,7 +46,12 @@ private: public: bit_range() : _current_byte(nullptr), _bit_offset(0) {} - bit_range(byte_t* current_byte, int bit_offset) : _current_byte(current_byte), _bit_offset(bit_offset) { assert(bit_offset>=0 && bit_offset<8); } + bit_range(byte_t* current_byte, int bit_offset) + : _current_byte(current_byte) + , _bit_offset(bit_offset) + { + BOOST_ASSERT(bit_offset >= 0 && bit_offset < 8); + } bit_range(const bit_range& br) : _current_byte(br._current_byte), _bit_offset(br._bit_offset) {} template bit_range(const bit_range& br) : _current_byte(br._current_byte), _bit_offset(br._bit_offset) {} @@ -76,34 +82,32 @@ public: int bit_offset() const { return _bit_offset; } }; - /// \defgroup ColorBaseModelNonAlignedPixel bit_aligned_pixel_reference /// \ingroup ColorBaseModel /// \brief A heterogeneous color base representing pixel that may not be byte aligned, i.e. it may correspond to a bit range that does not start/end at a byte boundary. Models ColorBaseConcept. - -/** -\defgroup PixelModelNonAlignedPixel bit_aligned_pixel_reference -\ingroup PixelModel -\brief A heterogeneous pixel reference used to represent non-byte-aligned pixels. Models PixelConcept - -Example: -\code -unsigned char data=0; - -// A mutable reference to a 6-bit BGR pixel in "123" format (1 bit for red, 2 bits for green, 3 bits for blue) -using rgb123_ref_t = bit_aligned_pixel_reference, rgb_layout_t, true> const; - -// create the pixel reference at bit offset 2 -// (i.e. red = [2], green = [3,4], blue = [5,6,7] bits) -rgb123_ref_t ref(&data, 2); -get_color(ref, red_t()) = 1; -assert(data == 0x04); -get_color(ref, green_t()) = 3; -assert(data == 0x1C); -get_color(ref, blue_t()) = 7; -assert(data == 0xFC); -\endcode -*/ +/// +/// \defgroup PixelModelNonAlignedPixel bit_aligned_pixel_reference +/// \ingroup PixelModel +/// \brief A heterogeneous pixel reference used to represent non-byte-aligned pixels. Models PixelConcept +/// +/// Example: +/// \code +/// unsigned char data=0; +/// +/// // A mutable reference to a 6-bit BGR pixel in "123" format (1 bit for red, 2 bits for green, 3 bits for blue) +/// using rgb123_ref_t = bit_aligned_pixel_reference, rgb_layout_t, true> const; +/// +/// // create the pixel reference at bit offset 2 +/// // (i.e. red = [2], green = [3,4], blue = [5,6,7] bits) +/// rgb123_ref_t ref(&data, 2); +/// get_color(ref, red_t()) = 1; +/// assert(data == 0x04); +/// get_color(ref, green_t()) = 3; +/// assert(data == 0x1C); +/// get_color(ref, blue_t()) = 7; +/// assert(data == 0xFC); +/// \endcode +/// /// \ingroup ColorBaseModelNonAlignedPixel PixelModelNonAlignedPixel PixelBasedModel /// \brief Heterogeneous pixel reference corresponding to non-byte-aligned bit range. Models ColorBaseConcept, PixelConcept, PixelBasedConcept template +#include #include #include #include #include -#include #include #include @@ -143,25 +143,23 @@ template struct channel_traits : public channel_traits //// /////////////////////////////////////////// -/** -\defgroup ScopedChannelValue scoped_channel_value -\ingroup ChannelModel -\brief A channel adaptor that modifies the range of the source channel. Models: ChannelValueConcept - -Example: -\code -// Create a double channel with range [-0.5 .. 0.5] -struct double_minus_half { static double apply() { return -0.5; } }; -struct double_plus_half { static double apply() { return 0.5; } }; -using bits64custom_t = scoped_channel_value; - -// channel_convert its maximum should map to the maximum -bits64custom_t x = channel_traits::max_value(); -assert(x == 0.5); -uint16_t y = channel_convert(x); -assert(y == 65535); -\endcode -*/ +/// \defgroup ScopedChannelValue scoped_channel_value +/// \ingroup ChannelModel +/// \brief A channel adaptor that modifies the range of the source channel. Models: ChannelValueConcept +/// +/// Example: +/// \code +/// // Create a double channel with range [-0.5 .. 0.5] +/// struct double_minus_half { static double apply() { return -0.5; } }; +/// struct double_plus_half { static double apply() { return 0.5; } }; +/// using bits64custom_t = scoped_channel_value; +/// +/// // channel_convert its maximum should map to the maximum +/// bits64custom_t x = channel_traits::max_value(); +/// assert(x == 0.5); +/// uint16_t y = channel_convert(x); +/// assert(y == 65535); +/// \endcode /// \ingroup ScopedChannelValue /// \brief A channel adaptor that modifies the range of the source channel. Models: ChannelValueConcept @@ -250,21 +248,19 @@ namespace detail { > {}; } -/** -\defgroup PackedChannelValueModel packed_channel_value -\ingroup ChannelModel -\brief Represents the value of an unsigned integral channel operating over a bit range. Models: ChannelValueConcept -Example: -\code -// A 4-bit unsigned integral channel. -using bits4 = packed_channel_value<4>; - -assert(channel_traits::min_value()==0); -assert(channel_traits::max_value()==15); -assert(sizeof(bits4)==1); -static_assert(boost::is_integral::value, ""); -\endcode -*/ +/// \defgroup PackedChannelValueModel packed_channel_value +/// \ingroup ChannelModel +/// \brief Represents the value of an unsigned integral channel operating over a bit range. Models: ChannelValueConcept +/// Example: +/// \code +/// // A 4-bit unsigned integral channel. +/// using bits4 = packed_channel_value<4>; +/// +/// assert(channel_traits::min_value()==0); +/// assert(channel_traits::max_value()==15); +/// assert(sizeof(bits4)==1); +/// static_assert(boost::is_integral::value, ""); +/// \endcode /// \ingroup PackedChannelValueModel /// \brief The value of a subbyte channel. Models: ChannelValueConcept @@ -380,21 +376,19 @@ private: }; } // namespace detail -/** -\defgroup PackedChannelReferenceModel packed_channel_reference -\ingroup ChannelModel -\brief Represents a reference proxy to a channel operating over a bit range whose offset is fixed at compile time. Models ChannelConcept -Example: -\code -// Reference to a 2-bit channel starting at bit 1 (i.e. the second bit) -using bits2_1_ref_t = packed_channel_reference const; - -uint16_t data=0; -bits2_1_ref_t channel_ref(&data); -channel_ref = channel_traits::max_value(); // == 3 -assert(data == 6); // == 3<<1 == 6 -\endcode -*/ +/// \defgroup PackedChannelReferenceModel packed_channel_reference +/// \ingroup ChannelModel +/// \brief Represents a reference proxy to a channel operating over a bit range whose offset is fixed at compile time. Models ChannelConcept +/// Example: +/// \code +/// // Reference to a 2-bit channel starting at bit 1 (i.e. the second bit) +/// using bits2_1_ref_t = packed_channel_reference const; +/// +/// uint16_t data=0; +/// bits2_1_ref_t channel_ref(&data); +/// channel_ref = channel_traits::max_value(); // == 3 +/// assert(data == 6); // == 3<<1 == 6 +/// \endcode template x, const boost: namespace boost { namespace gil { -/** -\defgroup PackedChannelDynamicReferenceModel packed_dynamic_channel_reference -\ingroup ChannelModel -\brief Represents a reference proxy to a channel operating over a bit range whose offset is specified at run time. Models ChannelConcept - -Example: -\code -// Reference to a 2-bit channel whose offset is specified at construction time -using bits2_dynamic_ref_t = packed_dynamic_channel_reference const; - -uint16_t data=0; -bits2_dynamic_ref_t channel_ref(&data,1); -channel_ref = channel_traits::max_value(); // == 3 -assert(data == 6); // == (3<<1) == 6 -\endcode -*/ +/// \defgroup PackedChannelDynamicReferenceModel packed_dynamic_channel_reference +/// \ingroup ChannelModel +/// \brief Represents a reference proxy to a channel operating over a bit range whose offset is specified at run time. Models ChannelConcept +/// +/// Example: +/// \code +/// // Reference to a 2-bit channel whose offset is specified at construction time +/// using bits2_dynamic_ref_t = packed_dynamic_channel_reference const; +/// +/// uint16_t data=0; +/// bits2_dynamic_ref_t channel_ref(&data,1); +/// channel_ref = channel_traits::max_value(); // == 3 +/// assert(data == 6); // == (3<<1) == 6 +/// \endcode /// \brief Models a constant subbyte channel reference whose bit offset is a runtime parameter. Models ChannelConcept /// Same as packed_channel_reference, except that the offset is a runtime parameter @@ -567,7 +565,13 @@ public: packed_dynamic_channel_reference(void* data_ptr, unsigned first_bit) : parent_t(data_ptr), _first_bit(first_bit) {} packed_dynamic_channel_reference(const packed_dynamic_channel_reference& ref) : parent_t(ref._data_ptr), _first_bit(ref._first_bit) {} - const packed_dynamic_channel_reference& operator=(integer_t value) const { assert(value<=parent_t::max_val); set_unsafe(value); return *this; } + packed_dynamic_channel_reference const& operator=(integer_t value) const + { + BOOST_ASSERT(value <= parent_t::max_val); + set_unsafe(value); + return *this; + } + const packed_dynamic_channel_reference& operator=(const mutable_reference& ref) const { set_unsafe(ref.get()); return *this; } const packed_dynamic_channel_reference& operator=(const const_reference& ref) const { set_unsafe(ref.get()); return *this; } diff --git a/include/boost/gil/channel_algorithm.hpp b/include/boost/gil/channel_algorithm.hpp index a9c70213a..80acf18f2 100644 --- a/include/boost/gil/channel_algorithm.hpp +++ b/include/boost/gil/channel_algorithm.hpp @@ -64,31 +64,30 @@ struct unsigned_integral_num_bits > } // namespace detail -/** -\defgroup ChannelConvertAlgorithm channel_convert -\brief Converting from one channel type to another -\ingroup ChannelAlgorithm +/// \defgroup ChannelConvertAlgorithm channel_convert +/// \brief Converting from one channel type to another +/// \ingroup ChannelAlgorithm +/// +/// Conversion is done as a simple linear mapping of one channel range to the other, +/// such that the minimum/maximum value of the source maps to the minimum/maximum value of the destination. +/// One implication of this is that the value 0 of signed channels may not be preserved! +/// +/// When creating new channel models, it is often a good idea to provide specializations for the channel conversion algorithms, for +/// example, for performance optimizations. If the new model is an integral type that can be signed, it is easier to define the conversion +/// only for the unsigned type (\p channel_converter_unsigned) and provide specializations of \p detail::channel_convert_to_unsigned +/// and \p detail::channel_convert_from_unsigned to convert between the signed and unsigned type. +/// +/// Example: +/// \code +/// // float32_t is a floating point channel with range [0.0f ... 1.0f] +/// float32_t src_channel = channel_traits::max_value(); +/// assert(src_channel == 1); +/// +/// // uint8_t is 8-bit unsigned integral channel (aliased from unsigned char) +/// uint8_t dst_channel = channel_convert(src_channel); +/// assert(dst_channel == 255); // max value goes to max value +/// \endcode -Conversion is done as a simple linear mapping of one channel range to the other, -such that the minimum/maximum value of the source maps to the minimum/maximum value of the destination. -One implication of this is that the value 0 of signed channels may not be preserved! - -When creating new channel models, it is often a good idea to provide specializations for the channel conversion algorithms, for -example, for performance optimizations. If the new model is an integral type that can be signed, it is easier to define the conversion -only for the unsigned type (\p channel_converter_unsigned) and provide specializations of \p detail::channel_convert_to_unsigned -and \p detail::channel_convert_from_unsigned to convert between the signed and unsigned type. - -Example: -\code -// float32_t is a floating point channel with range [0.0f ... 1.0f] -float32_t src_channel = channel_traits::max_value(); -assert(src_channel == 1); - -// uint8_t is 8-bit unsigned integral channel (aliased from unsigned char) -uint8_t dst_channel = channel_convert(src_channel); -assert(dst_channel == 255); // max value goes to max value -\endcode -*/ /** \defgroup ChannelConvertUnsignedAlgorithm channel_converter_unsigned @@ -419,19 +418,17 @@ namespace detail { inline uint32_t div32768(uint32_t in) { return (in+16384)>>15; } } -/** -\defgroup ChannelMultiplyAlgorithm channel_multiply -\ingroup ChannelAlgorithm -\brief Multiplying unsigned channel values of the same type. Performs scaled multiplication result = a * b / max_value - -Example: -\code -uint8_t x=128; -uint8_t y=128; -uint8_t mul = channel_multiply(x,y); -assert(mul == 64); // 64 = 128 * 128 / 255 -\endcode -*/ +/// \defgroup ChannelMultiplyAlgorithm channel_multiply +/// \ingroup ChannelAlgorithm +/// \brief Multiplying unsigned channel values of the same type. Performs scaled multiplication result = a * b / max_value +/// +/// Example: +/// \code +/// uint8_t x=128; +/// uint8_t y=128; +/// uint8_t mul = channel_multiply(x,y); +/// assert(mul == 64); // 64 = 128 * 128 / 255 +/// \endcode /// @{ /// \brief This is the default implementation. Performance specializatons are provided @@ -490,19 +487,17 @@ inline typename channel_traits::value_type channel_multiply(Channel a, } /// @} -/** -\defgroup ChannelInvertAlgorithm channel_invert -\ingroup ChannelAlgorithm -\brief Returns the inverse of a channel. result = max_value - x + min_value - -Example: -\code -// uint8_t == uint8_t == unsigned char -uint8_t x=255; -uint8_t inv = channel_invert(x); -assert(inv == 0); -\endcode -*/ +/// \defgroup ChannelInvertAlgorithm channel_invert +/// \ingroup ChannelAlgorithm +/// \brief Returns the inverse of a channel. result = max_value - x + min_value +/// +/// Example: +/// \code +/// // uint8_t == uint8_t == unsigned char +/// uint8_t x=255; +/// uint8_t inv = channel_invert(x); +/// assert(inv == 0); +/// \endcode /// \brief Default implementation. Provide overloads for performance /// \ingroup ChannelInvertAlgorithm channel_invert diff --git a/include/boost/gil/color_base.hpp b/include/boost/gil/color_base.hpp index d36d9f486..18382078a 100644 --- a/include/boost/gil/color_base.hpp +++ b/include/boost/gil/color_base.hpp @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -18,8 +19,6 @@ #include #include -#include - namespace boost { namespace gil { // Forward-declare @@ -334,29 +333,30 @@ public: template typename element_reference_type >::type -dynamic_at_c(homogeneous_color_base& cb, std::size_t i) { - assert(i& cb, std::size_t i) +{ + BOOST_ASSERT(i < K); return (gil_reinterpret_cast(&cb))[i]; } template typename element_const_reference_type >::type dynamic_at_c(const homogeneous_color_base& cb, std::size_t i) { - assert(i(&cb))[i]; } template typename element_reference_type >::type dynamic_at_c(const homogeneous_color_base& cb, std::size_t i) { - assert(i typename element_const_reference_type >::type dynamic_at_c(const homogeneous_color_base& cb, std::size_t i) { - assert(i { }; } // namespace detail - -/** -\defgroup ColorBaseAlgorithmMinMax static_min, static_max -\ingroup ColorBaseAlgorithm -\brief Equivalents to std::min_element and std::max_element for homogeneous color bases - -Example: -\code -rgb8_pixel_t pixel(10,20,30); -assert(pixel[2] == 30); -static_max(pixel) = static_min(pixel); -assert(pixel[2] == 10); -\endcode -\{ -*/ +/// \defgroup ColorBaseAlgorithmMinMax static_min, static_max +/// \ingroup ColorBaseAlgorithm +/// \brief Equivalents to std::min_element and std::max_element for homogeneous color bases +/// +/// Example: +/// \code +/// rgb8_pixel_t pixel(10,20,30); +/// assert(pixel[2] == 30); +/// static_max(pixel) = static_min(pixel); +/// assert(pixel[2] == 10); +/// \endcode +/// \{ template BOOST_FORCEINLINE @@ -479,22 +476,20 @@ BOOST_FORCEINLINE typename element_reference_type

::type static_min( P& p) { return detail::min_max_recur::value>::min_(p); } /// \} -/** -\defgroup ColorBaseAlgorithmEqual static_equal -\ingroup ColorBaseAlgorithm -\brief Equivalent to std::equal. Pairs the elements semantically - -Example: -\code -rgb8_pixel_t rgb_red(255,0,0); -bgr8_pixel_t bgr_red(0,0,255); -assert(rgb_red[0]==255 && bgr_red[0]==0); - -assert(static_equal(rgb_red,bgr_red)); -assert(rgb_red==bgr_red); // operator== invokes static_equal -\endcode -\{ -*/ +/// \defgroup ColorBaseAlgorithmEqual static_equal +/// \ingroup ColorBaseAlgorithm +/// \brief Equivalent to std::equal. Pairs the elements semantically +/// +/// Example: +/// \code +/// rgb8_pixel_t rgb_red(255,0,0); +/// bgr8_pixel_t bgr_red(0,0,255); +/// assert(rgb_red[0]==255 && bgr_red[0]==0); +/// +/// assert(static_equal(rgb_red,bgr_red)); +/// assert(rgb_red==bgr_red); // operator== invokes static_equal +/// \endcode +/// \{ template BOOST_FORCEINLINE @@ -502,22 +497,20 @@ bool static_equal(const P1& p1, const P2& p2) { return detail::element_recursion /// \} -/** -\defgroup ColorBaseAlgorithmCopy static_copy -\ingroup ColorBaseAlgorithm -\brief Equivalent to std::copy. Pairs the elements semantically - -Example: -\code -rgb8_pixel_t rgb_red(255,0,0); -bgr8_pixel_t bgr_red; -static_copy(rgb_red, bgr_red); // same as bgr_red = rgb_red - -assert(rgb_red[0] == 255 && bgr_red[0] == 0); -assert(rgb_red == bgr_red); -\endcode -\{ -*/ +/// \defgroup ColorBaseAlgorithmCopy static_copy +/// \ingroup ColorBaseAlgorithm +/// \brief Equivalent to std::copy. Pairs the elements semantically +/// +/// Example: +/// \code +/// rgb8_pixel_t rgb_red(255,0,0); +/// bgr8_pixel_t bgr_red; +/// static_copy(rgb_red, bgr_red); // same as bgr_red = rgb_red +/// +/// assert(rgb_red[0] == 255 && bgr_red[0] == 0); +/// assert(rgb_red == bgr_red); +/// \endcode +/// \{ template BOOST_FORCEINLINE @@ -525,77 +518,72 @@ void static_copy(const Src& src, Dst& dst) { detail::element_recursion BOOST_FORCEINLINE void static_fill(P& p, const V& v) { detail::element_recursion::value>::static_fill(p,v); } /// \} -/** -\defgroup ColorBaseAlgorithmGenerate static_generate -\ingroup ColorBaseAlgorithm -\brief Equivalent to std::generate. - -Example: Set each channel of a pixel to its semantic index. The channels must be assignable from an integer. -\code -struct consecutive_fn { - int& _current; - consecutive_fn(int& start) : _current(start) {} - int operator()() { return _current++; } -}; -rgb8_pixel_t p; -int start=0; -static_generate(p, consecutive_fn(start)); -assert(p == rgb8_pixel_t(0,1,2)); -\endcode - -\{ -*/ +/// \defgroup ColorBaseAlgorithmGenerate static_generate +/// \ingroup ColorBaseAlgorithm +/// \brief Equivalent to std::generate. +/// +/// Example: Set each channel of a pixel to its semantic index. The channels must be assignable from an integer. +/// \code +/// struct consecutive_fn { +/// int& _current; +/// consecutive_fn(int& start) : _current(start) {} +/// int operator()() { return _current++; } +/// }; +/// rgb8_pixel_t p; +/// int start=0; +/// static_generate(p, consecutive_fn(start)); +/// assert(p == rgb8_pixel_t(0,1,2)); +/// \endcode +/// +/// \{ template BOOST_FORCEINLINE void static_generate(P1& dst,Op op) { detail::element_recursion::value>::static_generate(dst,op); } /// \} -/** -\defgroup ColorBaseAlgorithmTransform static_transform -\ingroup ColorBaseAlgorithm -\brief Equivalent to std::transform. Pairs the elements semantically - -Example: Write a generic function that adds two pixels into a homogeneous result pixel. -\code -template -struct my_plus { - template - Result operator()(T1 f1, T2 f2) const { return f1+f2; } -}; - -template -void sum_channels(const Pixel1& p1, const Pixel2& p2, Pixel3& result) { - using result_channel_t = typename channel_type::type; - static_transform(p1,p2,result,my_plus()); -} - -rgb8_pixel_t p1(1,2,3); -bgr8_pixel_t p2(3,2,1); -rgb8_pixel_t result; -sum_channels(p1,p2,result); -assert(result == rgb8_pixel_t(2,4,6)); -\endcode -\{ -*/ +/// \defgroup ColorBaseAlgorithmTransform static_transform +/// \ingroup ColorBaseAlgorithm +/// \brief Equivalent to std::transform. Pairs the elements semantically +/// +/// Example: Write a generic function that adds two pixels into a homogeneous result pixel. +/// \code +/// template +/// struct my_plus { +/// template +/// Result operator()(T1 f1, T2 f2) const { return f1+f2; } +/// }; +/// +/// template +/// void sum_channels(const Pixel1& p1, const Pixel2& p2, Pixel3& result) { +/// using result_channel_t = typename channel_type::type; +/// static_transform(p1,p2,result,my_plus()); +/// } +/// +/// rgb8_pixel_t p1(1,2,3); +/// bgr8_pixel_t p2(3,2,1); +/// rgb8_pixel_t result; +/// sum_channels(p1,p2,result); +/// assert(result == rgb8_pixel_t(2,4,6)); +/// \endcode +/// \{ //static_transform with one source template @@ -619,32 +607,30 @@ BOOST_FORCEINLINE Op static_transform(const P2& p2,const P3& p3,Dst& dst,Op op) { return detail::element_recursion::value>::static_transform(p2,p3,dst,op); } /// \} -/** -\defgroup ColorBaseAlgorithmForEach static_for_each -\ingroup ColorBaseAlgorithm -\brief Equivalent to std::for_each. Pairs the elements semantically - -Example: Use static_for_each to increment a planar pixel iterator -\code -struct increment { - template - void operator()(Incrementable& x) const { ++x; } -}; - -template -void increment_elements(ColorBase& cb) { - static_for_each(cb, increment()); -} - -uint8_t red[2], green[2], blue[2]; -rgb8c_planar_ptr_t p1(red,green,blue); -rgb8c_planar_ptr_t p2=p1; -increment_elements(p1); -++p2; -assert(p1 == p2); -\endcode -\{ -*/ +/// \defgroup ColorBaseAlgorithmForEach static_for_each +/// \ingroup ColorBaseAlgorithm +/// \brief Equivalent to std::for_each. Pairs the elements semantically +/// +/// Example: Use static_for_each to increment a planar pixel iterator +/// \code +/// struct increment { +/// template +/// void operator()(Incrementable& x) const { ++x; } +/// }; +/// +/// template +/// void increment_elements(ColorBase& cb) { +/// static_for_each(cb, increment()); +/// } +/// +/// uint8_t red[2], green[2], blue[2]; +/// rgb8c_planar_ptr_t p1(red,green,blue); +/// rgb8c_planar_ptr_t p2=p1; +/// increment_elements(p1); +/// ++p2; +/// assert(p1 == p2); +/// \endcode +/// \{ //static_for_each with one source template diff --git a/include/boost/gil/extension/dynamic_image/dynamic_at_c.hpp b/include/boost/gil/extension/dynamic_image/dynamic_at_c.hpp index 1de9f248f..863968e4f 100644 --- a/include/boost/gil/extension/dynamic_image/dynamic_at_c.hpp +++ b/include/boost/gil/extension/dynamic_image/dynamic_at_c.hpp @@ -11,7 +11,6 @@ #include #include -#include #include namespace boost { namespace gil { diff --git a/include/boost/gil/extension/dynamic_image/variant.hpp b/include/boost/gil/extension/dynamic_image/variant.hpp index ecd817aef..d99bca38d 100644 --- a/include/boost/gil/extension/dynamic_image/variant.hpp +++ b/include/boost/gil/extension/dynamic_image/variant.hpp @@ -23,7 +23,6 @@ #include #include -#include #include #include diff --git a/include/boost/gil/extension/io/bmp/detail/read.hpp b/include/boost/gil/extension/io/bmp/detail/read.hpp index 657daa0b7..9bd790bf5 100644 --- a/include/boost/gil/extension/io/bmp/detail/read.hpp +++ b/include/boost/gil/extension/io/bmp/detail/read.hpp @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -450,9 +451,9 @@ private: template< typename View_Dst > void read_palette_image_rle( const View_Dst& view ) { - assert( this->_info._compression == bmp_compression::_rle4 - || this->_info._compression == bmp_compression::_rle8 - ); + BOOST_ASSERT( + this->_info._compression == bmp_compression::_rle4 || + this->_info._compression == bmp_compression::_rle8); this->read_palette(); diff --git a/include/boost/gil/extension/io/png/detail/base.hpp b/include/boost/gil/extension/io/png/detail/base.hpp index 55d0abdc6..7af4ef1f2 100644 --- a/include/boost/gil/extension/io/png/detail/base.hpp +++ b/include/boost/gil/extension/io/png/detail/base.hpp @@ -10,6 +10,8 @@ #include +#include + #include namespace boost { namespace gil { namespace detail { @@ -60,7 +62,7 @@ private: { if( png_ptr ) { - assert( png_ptr->_struct && png_ptr->_info ); + BOOST_ASSERT(png_ptr->_struct && png_ptr->_info); png_destroy_read_struct( &png_ptr->_struct , &png_ptr->_info @@ -76,7 +78,7 @@ private: { if( png_ptr ) { - assert( png_ptr->_struct && png_ptr->_info ); + BOOST_ASSERT(png_ptr->_struct && png_ptr->_info); png_destroy_write_struct( &png_ptr->_struct , &png_ptr->_info diff --git a/include/boost/gil/extension/io/tiff/detail/read.hpp b/include/boost/gil/extension/io/tiff/detail/read.hpp index 2a790610e..617a83b4e 100644 --- a/include/boost/gil/extension/io/tiff/detail/read.hpp +++ b/include/boost/gil/extension/io/tiff/detail/read.hpp @@ -20,6 +20,8 @@ #include #include +#include + #include #include #include @@ -495,9 +497,9 @@ private: std::ptrdiff_t tile_x1 = img_x1 - x; std::ptrdiff_t tile_y1 = img_y1 - y; - assert( tile_x0 >= 0 && tile_y0 >= 0 && tile_x1 >= 0 && tile_y1 >= 0 ); - assert( tile_x0 <= img_x1 && tile_y0 <= img_y1 ); - assert( tile_x0 < tile_width && tile_y0 < tile_height && tile_x1 < tile_width && tile_y1 < tile_height ); + BOOST_ASSERT(tile_x0 >= 0 && tile_y0 >= 0 && tile_x1 >= 0 && tile_y1 >= 0); + BOOST_ASSERT(tile_x0 <= img_x1 && tile_y0 <= img_y1); + BOOST_ASSERT(tile_x0 < tile_width && tile_y0 < tile_height && tile_x1 < tile_width && tile_y1 < tile_height); std::ptrdiff_t tile_subimage_view_width = tile_x1 - tile_x0 + 1; std::ptrdiff_t tile_subimage_view_height = tile_y1 - tile_y0 + 1; @@ -505,7 +507,7 @@ private: // convert to dst_view coordinates std::ptrdiff_t dst_x0 = img_x0 - subimage_x; std::ptrdiff_t dst_y0 = img_y0 - subimage_y; - assert( dst_x0 >= 0 && dst_y0 >= 0 ); + BOOST_ASSERT(dst_x0 >= 0 && dst_y0 >= 0); View dst_subimage_view = subimage_view( dst_view , (int) dst_x0 diff --git a/include/boost/gil/extension/numeric/algorithm.hpp b/include/boost/gil/extension/numeric/algorithm.hpp index 912e6391d..56ab8df16 100644 --- a/include/boost/gil/extension/numeric/algorithm.hpp +++ b/include/boost/gil/extension/numeric/algorithm.hpp @@ -13,8 +13,9 @@ #include #include +#include + #include -#include #include #include @@ -126,7 +127,7 @@ inline DstIterator correlate_pixels_k(SrcIterator src_begin,SrcIterator src_end, /// \brief destination is set to be product of the source and a scalar template inline void view_multiplies_scalar(const SrcView& src,const Scalar& scalar,const DstView& dst) { - assert(src.dimensions()==dst.dimensions()); + BOOST_ASSERT(src.dimensions() == dst.dimensions()); using PIXEL_SRC_REF = typename pixel_proxy::type; using PIXEL_DST_REF = typename pixel_proxy::type; int height=src.height(); diff --git a/include/boost/gil/extension/numeric/convolve.hpp b/include/boost/gil/extension/numeric/convolve.hpp index 7c0cfd535..4970cfd82 100644 --- a/include/boost/gil/extension/numeric/convolve.hpp +++ b/include/boost/gil/extension/numeric/convolve.hpp @@ -16,8 +16,9 @@ #include #include +#include + #include -#include #include #include #include @@ -43,8 +44,8 @@ template ::type; using PIXEL_DST_REF = typename pixel_proxy::type; diff --git a/include/boost/gil/extension/numeric/kernel.hpp b/include/boost/gil/extension/numeric/kernel.hpp index ecedc6f50..da75176aa 100644 --- a/include/boost/gil/extension/numeric/kernel.hpp +++ b/include/boost/gil/extension/numeric/kernel.hpp @@ -10,9 +10,10 @@ #include +#include + #include #include -#include #include #include #include @@ -32,19 +33,41 @@ private: std::size_t _center; public: kernel_1d_adaptor() : _center(0) {} - explicit kernel_1d_adaptor(std::size_t center_in) : _center(center_in) {assert(_centersize());} - kernel_1d_adaptor(std::size_t size_in,std::size_t center_in) : - Core(size_in), _center(center_in) {assert(_centersize());} - kernel_1d_adaptor(const kernel_1d_adaptor& k_in) : Core(k_in), _center(k_in._center) {} + + explicit kernel_1d_adaptor(std::size_t center_in) + : _center(center_in) + { + BOOST_ASSERT(_center < this->size()); + } + + kernel_1d_adaptor(std::size_t size_in, std::size_t center_in) + : Core(size_in) + , _center(center_in) + { + BOOST_ASSERT(_center < this->size()); + } + + kernel_1d_adaptor(kernel_1d_adaptor const& k_in) : Core(k_in), _center(k_in._center) {} kernel_1d_adaptor& operator=(const kernel_1d_adaptor& k_in) { Core::operator=(k_in); _center=k_in._center; return *this; } - std::size_t left_size() const {assert(_centersize());return _center;} - std::size_t right_size() const {assert(_centersize());return this->size()-_center-1;} - std::size_t& center() {return _center;} + + std::size_t left_size() const + { + BOOST_ASSERT(_center < this->size()); + return _center; + } + + std::size_t right_size() const + { + BOOST_ASSERT(_center < this->size()); + return this->size() - _center - 1; + } + + std::size_t& center() {return _center;} const std::size_t& center() const {return _center;} }; diff --git a/include/boost/gil/image_view_factory.hpp b/include/boost/gil/image_view_factory.hpp index 599ca4229..b0cfc9c8a 100644 --- a/include/boost/gil/image_view_factory.hpp +++ b/include/boost/gil/image_view_factory.hpp @@ -13,7 +13,8 @@ #include #include -#include +#include + #include /// Methods for creating shallow image views from raw pixel data or from other image views - @@ -262,8 +263,9 @@ inline View subimage_view(const View& src, int xMin, int yMin, int width, int he /// \ingroup ImageViewTransformationsSubsampled template -inline typename dynamic_xy_step_type::type subsampled_view(const View& src, typename View::coord_t xStep, typename View::coord_t yStep) { - assert(xStep>0 && yStep>0); +inline typename dynamic_xy_step_type::type subsampled_view(const View& src, typename View::coord_t xStep, typename View::coord_t yStep) +{ + BOOST_ASSERT(xStep > 0 && yStep > 0); using RView = typename dynamic_xy_step_type::type; return RView((src.width()+(xStep-1))/xStep,(src.height()+(yStep-1))/yStep, typename RView::xy_locator(src.xy_at(0,0),xStep,yStep)); diff --git a/include/boost/gil/io/device.hpp b/include/boost/gil/io/device.hpp index cff1bcb62..663068da1 100644 --- a/include/boost/gil/io/device.hpp +++ b/include/boost/gil/io/device.hpp @@ -10,6 +10,7 @@ #include +#include #include #include @@ -171,12 +172,12 @@ public: ///@todo: add compiler symbol to turn error checking on and off. if(ferror( get() )) { - assert( false ); + BOOST_ASSERT(false); } //libjpeg sometimes reads blocks in 4096 bytes even when the file is smaller than that. //assert( num_elements == count ); - assert( num_elements > 0 ); + BOOST_ASSERT(num_elements > 0 ); return num_elements; } @@ -230,8 +231,7 @@ public: , get() ); - assert( num_elements == count ); - + BOOST_ASSERT(num_elements == count); return num_elements; } @@ -310,7 +310,7 @@ public: , get() ); - assert( num_elements == line.size() ); + BOOST_ASSERT(num_elements == line.size()); boost::ignore_unused(num_elements); } diff --git a/include/boost/gil/io/reader_base.hpp b/include/boost/gil/io/reader_base.hpp index 32e9389c1..309331b76 100644 --- a/include/boost/gil/io/reader_base.hpp +++ b/include/boost/gil/io/reader_base.hpp @@ -10,6 +10,8 @@ #include +#include + namespace boost { namespace gil { /// Reader Base Class @@ -54,7 +56,7 @@ public: { //setup( backend._settings._dim ); - assert( settings._dim.x && settings._dim.y ); + BOOST_ASSERT(settings._dim.x && settings._dim.y); img.recreate( settings._dim.x , settings._dim.y diff --git a/include/boost/gil/iterator_from_2d.hpp b/include/boost/gil/iterator_from_2d.hpp index d9266a376..1b9e8d7b0 100644 --- a/include/boost/gil/iterator_from_2d.hpp +++ b/include/boost/gil/iterator_from_2d.hpp @@ -13,10 +13,9 @@ #include #include +#include #include -#include - namespace boost { namespace gil { /// pixel step iterator, pixel image iterator and pixel dereference iterator @@ -116,9 +115,10 @@ private: return (it.y_pos()-_coords.y)*_width + (it.x_pos()-_coords.x); } - bool equal(const iterator_from_2d& it) const { - assert(_width==it.width()); // they must belong to the same image - return _coords==it._coords && _p==it._p; + bool equal(iterator_from_2d const& it) const + { + BOOST_ASSERT(_width == it.width()); // they must belong to the same image + return _coords == it._coords && _p == it._p; } point_t _coords; diff --git a/include/boost/gil/locator.hpp b/include/boost/gil/locator.hpp index 66d435d9b..75fd19d37 100644 --- a/include/boost/gil/locator.hpp +++ b/include/boost/gil/locator.hpp @@ -11,7 +11,8 @@ #include #include -#include +#include + #include namespace boost { namespace gil { @@ -287,9 +288,10 @@ public: bool is_1d_traversable(x_coord_t width) const { return row_size()-pixel_size()*width==0; } // is there no gap at the end of each row? // Returns the vertical distance (it2.y-it1.y) between two x_iterators given the difference of their x positions - std::ptrdiff_t y_distance_to(const this_t& p2, x_coord_t xDiff) const { - std::ptrdiff_t rowDiff=memunit_distance(x(),p2.x())-pixel_size()*xDiff; - assert(( rowDiff % row_size())==0); + std::ptrdiff_t y_distance_to(this_t const& p2, x_coord_t xDiff) const + { + std::ptrdiff_t rowDiff = memunit_distance(x(), p2.x()) - pixel_size() * xDiff; + BOOST_ASSERT((rowDiff % row_size()) == 0); return rowDiff / row_size(); } diff --git a/include/boost/gil/packed_pixel.hpp b/include/boost/gil/packed_pixel.hpp index 8874c6b58..d6c8f09af 100644 --- a/include/boost/gil/packed_pixel.hpp +++ b/include/boost/gil/packed_pixel.hpp @@ -26,23 +26,21 @@ namespace boost { namespace gil { /// \ingroup ColorBaseModel /// \brief A heterogeneous color base whose elements are reference proxies to channels in a pixel. Models ColorBaseValueConcept. This class is used to model packed pixels, such as 16-bit packed RGB. -/** -\defgroup PixelModelPackedPixel packed_pixel -\ingroup PixelModel -\brief A heterogeneous pixel used to represent packed pixels with non-byte-aligned channels. Models PixelValueConcept - -Example: -\code -using rgb565_pixel_t = packed_pixel_type, rgb_layout_t>::type; -static_assert(sizeof(rgb565_pixel_t) == 2, ""); - -rgb565_pixel_t r565; -get_color(r565,red_t()) = 31; -get_color(r565,green_t()) = 63; -get_color(r565,blue_t()) = 31; -assert(r565 == rgb565_pixel_t((uint16_t)0xFFFF)); -\endcode -*/ +/// \defgroup PixelModelPackedPixel packed_pixel +/// \ingroup PixelModel +/// \brief A heterogeneous pixel used to represent packed pixels with non-byte-aligned channels. Models PixelValueConcept +/// +/// Example: +/// \code +/// using rgb565_pixel_t = packed_pixel_type, rgb_layout_t>::type; +/// static_assert(sizeof(rgb565_pixel_t) == 2, ""); +/// +/// rgb565_pixel_t r565; +/// get_color(r565,red_t()) = 31; +/// get_color(r565,green_t()) = 63; +/// get_color(r565,blue_t()) = 31; +/// assert(r565 == rgb565_pixel_t((uint16_t)0xFFFF)); +/// \endcode /// \ingroup ColorBaseModelPackedPixel PixelModelPackedPixel PixelBasedModel /// \brief Heterogeneous pixel value whose channel references can be constructed from the pixel bitfield and their index. Models ColorBaseValueConcept, PixelValueConcept, PixelBasedConcept diff --git a/include/boost/gil/pixel_iterator.hpp b/include/boost/gil/pixel_iterator.hpp index 9fc2dbacf..a74cb2270 100644 --- a/include/boost/gil/pixel_iterator.hpp +++ b/include/boost/gil/pixel_iterator.hpp @@ -12,7 +12,6 @@ #include #include -#include #include namespace boost { namespace gil { diff --git a/include/boost/gil/planar_pixel_iterator.hpp b/include/boost/gil/planar_pixel_iterator.hpp index 6c3cc66bd..a4c49a4f8 100644 --- a/include/boost/gil/planar_pixel_iterator.hpp +++ b/include/boost/gil/planar_pixel_iterator.hpp @@ -13,7 +13,6 @@ #include -#include #include namespace boost { namespace gil { diff --git a/include/boost/gil/virtual_locator.hpp b/include/boost/gil/virtual_locator.hpp index 2df1689f9..25736e692 100644 --- a/include/boost/gil/virtual_locator.hpp +++ b/include/boost/gil/virtual_locator.hpp @@ -10,6 +10,7 @@ #include +#include #include namespace boost { namespace gil { @@ -45,10 +46,17 @@ public: virtual_2d_locator(const point_t& p=point_t(0,0), const point_t& step=point_t(1,1), const deref_fn_t& d=deref_fn_t()) : _p(p,step,d) {} template virtual_2d_locator(const virtual_2d_locator& loc, coord_t y_step) : _p(loc.pos(), point_t(loc.step().x,loc.step().y*y_step), loc.deref_fn()) {} - template virtual_2d_locator(const virtual_2d_locator& loc, coord_t x_step, coord_t y_step, bool transpose=false) - : _p(loc.pos(), transpose ? - point_t(loc.step().x*y_step,loc.step().y*x_step) : - point_t(loc.step().x*x_step,loc.step().y*y_step), loc.deref_fn()) { assert(transpose==(IsTransposed!=TR));} + + template + virtual_2d_locator(virtual_2d_locator const& loc, coord_t x_step, coord_t y_step, bool transpose = false) + : _p(loc.pos() + , transpose ? + point_t(loc.step().x * y_step, loc.step().y * x_step) : + point_t(loc.step().x * x_step, loc.step().y * y_step) + , loc.deref_fn()) + { + BOOST_ASSERT(transpose == (IsTransposed != TR)); + } template virtual_2d_locator(const virtual_2d_locator& pl) : _p(pl._p) {} virtual_2d_locator(const virtual_2d_locator& pl) : _p(pl._p) {} diff --git a/numeric/test/numeric.cpp b/numeric/test/numeric.cpp index 68920a9a3..946d00e5f 100644 --- a/numeric/test/numeric.cpp +++ b/numeric/test/numeric.cpp @@ -13,6 +13,7 @@ #include #include +#include #define BOOST_TEST_MAIN #include @@ -151,27 +152,27 @@ BOOST_AUTO_TEST_CASE(bilinear_sampler_test) TestMapFn mf; - resample_pixels( const_view(img), view(dimg), mf, bilinear_sampler() ); + resample_pixels(const_view(img), view(dimg), mf, bilinear_sampler()); - assert( rgb8_pixel_t(128,0,0) == dv(0,0) ); - assert( rgb8_pixel_t(64,64,0) == dv(0,1) ); - assert( rgb8_pixel_t(0,64,64) == dv(0,2) ); - assert( rgb8_pixel_t(0,0,128) == dv(0,3) ); + BOOST_ASSERT(rgb8_pixel_t(128,0,0) == dv(0,0)); + BOOST_ASSERT(rgb8_pixel_t(64,64,0) == dv(0,1)); + BOOST_ASSERT(rgb8_pixel_t(0,64,64) == dv(0,2)); + BOOST_ASSERT(rgb8_pixel_t(0,0,128) == dv(0,3)); - assert( rgb8_pixel_t(64,64,0) == dv(1,0) ); - assert( rgb8_pixel_t(64,96,32) == dv(1,1) ); - assert( rgb8_pixel_t(64,64,64) == dv(1,2) ); - assert( rgb8_pixel_t(64,0,64) == dv(1,3) ); + BOOST_ASSERT(rgb8_pixel_t(64,64,0) == dv(1,0)); + BOOST_ASSERT(rgb8_pixel_t(64,96,32) == dv(1,1)); + BOOST_ASSERT(rgb8_pixel_t(64,64,64) == dv(1,2)); + BOOST_ASSERT(rgb8_pixel_t(64,0,64) == dv(1,3)); - assert( rgb8_pixel_t(0,64,64) == dv(2,0) ); - assert( rgb8_pixel_t(64,64,64) == dv(2,1) ); - assert( rgb8_pixel_t(96,64,32) == dv(2,2) ); - assert( rgb8_pixel_t(64,64,0) == dv(2,3) ); + BOOST_ASSERT(rgb8_pixel_t(0,64,64) == dv(2,0)); + BOOST_ASSERT(rgb8_pixel_t(64,64,64) == dv(2,1)); + BOOST_ASSERT(rgb8_pixel_t(96,64,32) == dv(2,2)); + BOOST_ASSERT(rgb8_pixel_t(64,64,0) == dv(2,3)); - assert( rgb8_pixel_t(0,0,128) == dv(3,0) ); - assert( rgb8_pixel_t(64,0,64) == dv(3,1) ); - assert( rgb8_pixel_t(64,64,0) == dv(3,2) ); - assert( rgb8_pixel_t(0,128,0) == dv(3,3) ); + BOOST_ASSERT(rgb8_pixel_t(0,0,128) == dv(3,0)); + BOOST_ASSERT(rgb8_pixel_t(64,0,64) == dv(3,1)); + BOOST_ASSERT(rgb8_pixel_t(64,64,0) == dv(3,2)); + BOOST_ASSERT(rgb8_pixel_t(0,128,0) == dv(3,3)); } BOOST_AUTO_TEST_SUITE_END() diff --git a/test/pixel.cpp b/test/pixel.cpp index 0b82db766..77b0ae17d 100644 --- a/test/pixel.cpp +++ b/test/pixel.cpp @@ -251,7 +251,7 @@ void test_packed_pixel() rgb565_pixel_t r565;//((uint16_t)0); rgb8_pixel_t rgb_full(255,255,255); - // Convert all channels of the unpacked pixel to the packed one & assert the packed one is full + // Convert all channels of the unpacked pixel to the packed one & ensure the packed one is full get_color(r565,red_t()) = channel_convert::type>(get_color(rgb_full,red_t())); get_color(r565,green_t()) = channel_convert::type>(get_color(rgb_full,green_t())); get_color(r565,blue_t()) = channel_convert::type>(get_color(rgb_full,blue_t())); diff --git a/test/pixel_iterator.cpp b/test/pixel_iterator.cpp index 9fd54ab3b..1f92c333c 100644 --- a/test/pixel_iterator.cpp +++ b/test/pixel_iterator.cpp @@ -7,9 +7,9 @@ // #include +#include #include -#include #include #include #include @@ -146,14 +146,14 @@ void test_pixel_iterator() unsigned char v8 = get_color( p8, gray_color_t() ); // all values should be 110b ( 6 ); - assert( v1 == 6 ); - assert( v2 == 6 ); - assert( v3 == 6 ); - assert( v4 == 6 ); - assert( v5 == 6 ); - assert( v6 == 6 ); - assert( v7 == 6 ); - assert( v8 == 6 ); + BOOST_ASSERT(v1 == 6); + BOOST_ASSERT(v2 == 6); + BOOST_ASSERT(v3 == 6); + BOOST_ASSERT(v4 == 6); + BOOST_ASSERT(v5 == 6); + BOOST_ASSERT(v6 == 6); + BOOST_ASSERT(v7 == 6); + BOOST_ASSERT(v8 == 6); } // TODO: Make better tests. Use some code from below. diff --git a/toolbox/test/indexed_image_test.cpp b/toolbox/test/indexed_image_test.cpp index 885ba65c8..993dc8fee 100644 --- a/toolbox/test/indexed_image_test.cpp +++ b/toolbox/test/indexed_image_test.cpp @@ -8,13 +8,13 @@ #include #include +#include #include using namespace std; using namespace boost; using namespace gil; - BOOST_AUTO_TEST_SUITE( toolbox_tests ) BOOST_AUTO_TEST_CASE( index_image_test ) @@ -129,13 +129,13 @@ BOOST_AUTO_TEST_CASE(index_image_view_test) auto p = ii_view(point_t(0, 0)); auto q = *ii_view.at(point_t(0, 0)); - assert(get_color(p, red_t()) == 70); - assert(get_color(p, green_t()) == 80); - assert(get_color(p, blue_t()) == 90); + BOOST_ASSERT(get_color(p, red_t()) == 70); + BOOST_ASSERT(get_color(p, green_t()) == 80); + BOOST_ASSERT(get_color(p, blue_t()) == 90); - assert(get_color(q, red_t()) == 70); - assert(get_color(q, green_t()) == 80); - assert(get_color(q, blue_t()) == 90); + BOOST_ASSERT(get_color(q, red_t()) == 70); + BOOST_ASSERT(get_color(q, green_t()) == 80); + BOOST_ASSERT(get_color(q, blue_t()) == 90); } BOOST_AUTO_TEST_SUITE_END()