Skip to content

Commit

Permalink
Fix missing alignment default value in image constructor (#429)
Browse files Browse the repository at this point in the history
Fixes #424 blocking PR #423
  • Loading branch information
mloskot authored Feb 1, 2020
1 parent c6bbcfd commit 5f3c002
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 2 deletions.
2 changes: 1 addition & 1 deletion include/boost/gil/image.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class image {

image(const point_t& dimensions,
const Pixel& p_in,
std::size_t alignment,
std::size_t alignment = 0,
const Alloc alloc_in = Alloc()) : _memory(nullptr), _align_in_bytes(alignment), _alloc(alloc_in)
, _allocated_bytes( 0 ) {
allocate_and_fill(dimensions, p_in);
Expand Down
3 changes: 2 additions & 1 deletion test/core/image/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
# http://www.boost.org/LICENSE_1_0.txt)
#
foreach(_name
concepts)
concepts
image)
set(_test t_core_image_${_name})
set(_target test_core_image_${_name})

Expand Down
2 changes: 2 additions & 0 deletions test/core/image/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@
import testing ;

compile concepts.cpp ;

run image.cpp /boost/test//boost_unit_test_framework : : : <link>shared:<define>BOOST_TEST_DYN_LINK=1 ;
35 changes: 35 additions & 0 deletions test/core/image/image.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// Copyright 2019 Mateusz Loskot <mateusz at loskot dot net>
//
// Distributed under the Boost Software License, Version 1.0
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//
#define BOOST_TEST_MODULE gil/test/core/image/image
#include "unit_test.hpp"

#include <boost/gil.hpp>

#include "test_fixture.hpp"
#include "core/pixel/test_fixture.hpp"

namespace gil = boost::gil;
namespace fixture = boost::gil::test::fixture;

BOOST_AUTO_TEST_CASE_TEMPLATE(constructor_with_dimensions_pixel, Image, fixture::image_types)
{
gil::point_t const dimensions{256, 128};
{
using pixel_t = typename Image::view_t::value_type;
pixel_t const rnd_pixel = fixture::pixel_generator<pixel_t>::random();

Image image(dimensions, rnd_pixel);
BOOST_TEST(image.width() == dimensions.x);
BOOST_TEST(image.height() == dimensions.y);

for (pixel_t const& p : gil::view(image))
{
BOOST_TEST(p == rnd_pixel);
}
}
}

0 comments on commit 5f3c002

Please sign in to comment.