gil/test/extension/io/tiff_tiled_write_macros.hpp
Mateusz Łoskot 4ed7701b47
Move tests of extensions inside test/ directory (#302)
Split header tests accordingly i.e. test core headers as part of
core tests, numeric extension headers as part of numeric tests, etc.

It extends the convention of sub-directories already established in
`include/boost/gil` directory. It is sensible to follow it in other
areas of the source tree (i.e. `test/`, `doc/` and `benchmark/`).

Another important reason to move the tests is to enable removal of
the top-level `Jamfile` with all its definitions of test-specific
requirements.
The top-level `Jamfile` is not advised, especially if it specifies
build requirements like C++ language version.
Those affect non-tests builds e.g. documentation, causing failures
during generation of HTML documentation (leads to missing docs).
2019-05-28 18:58:22 +02:00

166 lines
6.7 KiB
C++

//
// Copyright 2013 Christian Henning
//
// 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
//
#ifndef BOOST_GIL_TIFF_TILED_WRITE_MACROS_HPP
#define BOOST_GIL_TIFF_TILED_WRITE_MACROS_HPP
#include <boost/gil.hpp>
#include <boost/gil/extension/io/tiff.hpp>
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/stringize.hpp>
#include <boost/preprocessor/tuple/elem.hpp>
#include <boost/preprocessor/comparison/less.hpp>
#include <boost/preprocessor/repetition/repeat_from_to.hpp>
#include "paths.hpp"
using tag_t = boost::gil::tiff_tag;
// TODO: Rename the macros to BOOST_GIL_*
#ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
#define GENERATE_WRITE_TILE_BIT_ALIGNED_RGB(z, n, data)\
BOOST_AUTO_TEST_CASE( BOOST_PP_CAT(BOOST_PP_CAT(BOOST_PP_CAT(BOOST_PP_CAT(write_rgb_tile_and_compare_with_,data),_strip_),n), bit_bit_aligned) )\
{ \
using namespace std; \
using namespace boost; \
using namespace gil; \
string filename( string( "tiger-" ) + BOOST_PP_STRINGIZE(data) + "-strip-contig-" ); \
string path( tiff_in_GM ); \
string padding(""); \
if(BOOST_PP_LESS(n, 10)==1) \
padding = "0"; \
filename += padding + BOOST_PP_STRINGIZE(n) + ".tif"; \
path += filename; \
bit_aligned_image3_type< n, n, n, rgb_layout_t >::type img_strip, img_saved; \
read_image( path, img_strip, tag_t() ); \
image_write_info<tag_t> info; \
info._is_tiled = true; \
info._tile_width = info._tile_length = 16; \
write_view( tiff_out + filename, view(img_strip), info ); \
read_image( tiff_out + filename, img_saved, tag_t() ); \
BOOST_CHECK_EQUAL( equal_pixels( const_view(img_strip), const_view(img_saved) ), true); \
} \
// Special case for minisblack images
#define GENERATE_WRITE_TILE_BIT_ALIGNED_MINISBLACK(z, n, data)\
BOOST_AUTO_TEST_CASE( BOOST_PP_CAT(BOOST_PP_CAT(BOOST_PP_CAT(BOOST_PP_CAT(write_minisblack_tile_and_compare_with_,data),_strip_),n), bit_bit_aligned) )\
{ \
using namespace std; \
using namespace boost; \
using namespace gil; \
string filename( string( "tiger-" ) + BOOST_PP_STRINGIZE(data) + "-strip-" ); \
string path( tiff_in_GM ); \
string padding(""); \
if(BOOST_PP_LESS(n, 10)==1) \
padding = "0"; \
filename = filename + padding + BOOST_PP_STRINGIZE(n) + ".tif"; \
path += filename; \
bit_aligned_image1_type< n, gray_layout_t >::type img_strip, img_saved; \
read_image( path, img_strip, tag_t() ); \
image_write_info<tag_t> info; \
info._is_tiled = true; \
info._tile_width = info._tile_length = 16; \
write_view( tiff_out + filename, view(img_strip), info ); \
read_image( tiff_out + filename, img_saved, tag_t() ); \
BOOST_CHECK_EQUAL( equal_pixels( const_view(img_strip), const_view(img_saved) ), true); \
} \
// Special case for palette images
#define GENERATE_WRITE_TILE_BIT_ALIGNED_PALETTE(z, n, data)\
BOOST_AUTO_TEST_CASE( BOOST_PP_CAT(BOOST_PP_CAT(BOOST_PP_CAT(BOOST_PP_CAT(write_palette_tile_and_compare_with_,data),_strip_),n), bit) )\
{ \
using namespace std; \
using namespace boost; \
using namespace gil; \
string filename( string( "tiger-" ) + BOOST_PP_STRINGIZE(data) + "-strip-" ); \
string path( tiff_in_GM ); \
string padding(""); \
if(BOOST_PP_LESS(n, 10)==1) \
padding = "0"; \
filename = filename + padding + BOOST_PP_STRINGIZE(n) + ".tif"; \
path += filename; \
rgb16_image_t img_strip, img_saved; \
read_image( path, img_strip, tag_t() ); \
image_write_info<tag_t> info; \
info._is_tiled = true; \
info._tile_width = info._tile_length = 16; \
write_view( tiff_out + filename, view(img_strip), info ); \
read_image( tiff_out + filename, img_saved, tag_t() ); \
BOOST_CHECK_EQUAL( equal_pixels( const_view(img_strip), const_view(img_saved) ), true); \
} \
#else
#define GENERATE_WRITE_TILE_BIT_ALIGNED_RGB(z, n, data)\
BOOST_AUTO_TEST_CASE( BOOST_PP_CAT(BOOST_PP_CAT(BOOST_PP_CAT(BOOST_PP_CAT(write_rgb_tile_and_compare_with_,data),_strip_),n), bit_bit_aligned) )\
{ \
using namespace std; \
using namespace boost; \
using namespace gil; \
string filename( string( "tiger-" ) + BOOST_PP_STRINGIZE(data) + "-strip-contig-" ); \
string path( tiff_in_GM ); \
string padding(""); \
if(BOOST_PP_LESS(n, 10)==1) \
padding = "0"; \
filename += padding + BOOST_PP_STRINGIZE(n) + ".tif"; \
path += filename; \
bit_aligned_image3_type< n, n, n, rgb_layout_t >::type img_strip, img_saved; \
read_image( path, img_strip, tag_t() ); \
image_write_info<tag_t> info; \
info._is_tiled = true; \
info._tile_width = info._tile_length = 16; \
} \
// Special case for minisblack images
#define GENERATE_WRITE_TILE_BIT_ALIGNED_MINISBLACK(z, n, data)\
BOOST_AUTO_TEST_CASE( BOOST_PP_CAT(BOOST_PP_CAT(BOOST_PP_CAT(BOOST_PP_CAT(write_minisblack_tile_and_compare_with_,data),_strip_),n), bit_bit_aligned) )\
{ \
using namespace std; \
using namespace boost; \
using namespace gil; \
string filename( string( "tiger-" ) + BOOST_PP_STRINGIZE(data) + "-strip-" ); \
string path( tiff_in_GM ); \
string padding(""); \
if(BOOST_PP_LESS(n, 10)==1) \
padding = "0"; \
filename = filename + padding + BOOST_PP_STRINGIZE(n) + ".tif"; \
path += filename; \
bit_aligned_image1_type< n, gray_layout_t >::type img_strip, img_saved; \
read_image( path, img_strip, tag_t() ); \
image_write_info<tag_t> info; \
info._is_tiled = true; \
info._tile_width = info._tile_length = 16; \
} \
// Special case for palette images
#define GENERATE_WRITE_TILE_BIT_ALIGNED_PALETTE(z, n, data)\
BOOST_AUTO_TEST_CASE( BOOST_PP_CAT(BOOST_PP_CAT(BOOST_PP_CAT(BOOST_PP_CAT(write_palette_tile_and_compare_with_,data),_strip_),n), bit) )\
{ \
using namespace std; \
using namespace boost; \
using namespace gil; \
string filename( string( "tiger-" ) + BOOST_PP_STRINGIZE(data) + "-strip-" ); \
string path( tiff_in_GM ); \
string padding(""); \
if(BOOST_PP_LESS(n, 10)==1) \
padding = "0"; \
filename = filename + padding + BOOST_PP_STRINGIZE(n) + ".tif"; \
path += filename; \
rgb16_image_t img_strip, img_saved; \
read_image( path, img_strip, tag_t() ); \
image_write_info<tag_t> info; \
info._is_tiled = true; \
info._tile_width = info._tile_length = 16; \
} \
#endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
#endif // BOOST_GIL_TIFF_TILED_READ_MACROS_HPP