Skip to content

Commit

Permalink
Update test using boost/lightweight_test.hpp
Browse files Browse the repository at this point in the history
  • Loading branch information
mloskot authored and sdebionne committed Mar 30, 2020
1 parent 986bfcc commit 698427a
Showing 1 changed file with 42 additions and 20 deletions.
62 changes: 42 additions & 20 deletions test/core/image/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <boost/core/lightweight_test.hpp>

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

namespace gil = boost::gil;
Expand Down Expand Up @@ -37,32 +38,53 @@ struct test_constructor_with_dimensions_pixel
}
};

int main()
{
test_constructor_with_dimensions_pixel::run();

return ::boost::report_errors();
}

BOOST_AUTO_TEST_CASE_TEMPLATE(move_constructor, Image, fixture::image_types)
struct test_move_constructor
{
gil::point_t const dimensions{256, 128};
template <typename Image>
void operator()(Image const&)
{
Image image(fixture::create_image<Image>(dimensions.x, dimensions.y, 0));
using image_t = Image;
gil::point_t const dimensions{256, 128};
{
image_t image(fixture::create_image<image_t>(dimensions.x, dimensions.y, 0));

Image image2(std::move(image));
BOOST_CHECK_EQUAL(image2.dimensions(), dimensions);
BOOST_CHECK_EQUAL(image.dimensions(), gil::point_t{});
image_t image2(std::move(image));
BOOST_TEST_EQ(image2.dimensions(), dimensions);
BOOST_TEST_EQ(image.dimensions(), gil::point_t{});
}
}
}
static void run()
{
boost::mp11::mp_for_each<fixture::image_types>(test_move_constructor{});
}
};

BOOST_AUTO_TEST_CASE_TEMPLATE(move_assignement, Image, fixture::image_types)
struct test_move_assignement
{
gil::point_t const dimensions{256, 128};
template <typename Image>
void operator()(Image const&)
{
Image image = fixture::create_image<Image>(dimensions.x, dimensions.y, 0);
Image image2 = std::move(image);
BOOST_CHECK_EQUAL(image2.dimensions(), dimensions);
BOOST_CHECK_EQUAL(image.dimensions(), gil::point_t{});
using image_t = Image;
gil::point_t const dimensions{256, 128};
{
image_t image = fixture::create_image<image_t>(dimensions.x, dimensions.y, 0);
image_t image2 = std::move(image);
BOOST_TEST_EQ(image2.dimensions(), dimensions);
BOOST_TEST_EQ(image.dimensions(), gil::point_t{});
}
}
static void run()
{
boost::mp11::mp_for_each<fixture::image_types>(test_move_assignement{});
}
};

int main()
{
test_constructor_with_dimensions_pixel::run();

test_move_constructor::run();
test_move_assignement::run();

return ::boost::report_errors();
}

0 comments on commit 698427a

Please sign in to comment.