• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2013 Christian Henning
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 //#define BOOST_TEST_MODULE pnm_old_test_module
9 #include <boost/test/unit_test.hpp>
10 
11 #include <boost/gil.hpp>
12 #include <boost/gil/extension/io/pnm/old.hpp>
13 
14 #include "paths.hpp"
15 
16 using namespace std;
17 using namespace boost;
18 using namespace gil;
19 
20 BOOST_AUTO_TEST_SUITE( gil_io_pnm_tests )
21 
22 #ifdef BOOST_GIL_IO_TEST_ALLOW_READING_IMAGES
23 
BOOST_AUTO_TEST_CASE(old_read_dimensions_test)24 BOOST_AUTO_TEST_CASE( old_read_dimensions_test )
25 {
26     boost::gil::point_t dim = pnm_read_dimensions(pnm_filename);
27     BOOST_CHECK_EQUAL( dim.x, 256 );
28     BOOST_CHECK_EQUAL( dim.y, 256 );
29 }
30 
BOOST_AUTO_TEST_CASE(old_read_image_test)31 BOOST_AUTO_TEST_CASE( old_read_image_test )
32 {
33     {
34         rgb8_image_t img;
35         pnm_read_image( pnm_filename, img );
36 
37         BOOST_CHECK_EQUAL( img.width() , 256 );
38         BOOST_CHECK_EQUAL( img.height(), 256 );
39     }
40 }
41 
BOOST_AUTO_TEST_CASE(old_read_and_convert_image_test)42 BOOST_AUTO_TEST_CASE( old_read_and_convert_image_test )
43 {
44     {
45         rgb8_image_t img;
46         pnm_read_and_convert_image( pnm_filename, img );
47 
48         BOOST_CHECK_EQUAL( img.width() , 256 );
49         BOOST_CHECK_EQUAL( img.height(), 256 );
50     }
51 }
52 
BOOST_AUTO_TEST_CASE(old_read_view_test)53 BOOST_AUTO_TEST_CASE( old_read_view_test )
54 {
55     {
56         rgb8_image_t img( 256, 256 );
57         pnm_read_view( pnm_filename, view( img ) );
58     }
59 }
60 
BOOST_AUTO_TEST_CASE(old_read_and_convert_view_test)61 BOOST_AUTO_TEST_CASE( old_read_and_convert_view_test )
62 {
63     {
64         rgb8_image_t img( 256, 256 );
65         pnm_read_and_convert_view( pnm_filename, view( img ) );
66     }
67 }
68 
BOOST_AUTO_TEST_CASE(old_write_view_test)69 BOOST_AUTO_TEST_CASE( old_write_view_test )
70 {
71     {
72         string filename( pnm_out + "test5.pnm" );
73         gray8_image_t img( 256, 256);
74 
75 #ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
76         pnm_write_view( filename, view( img ) );
77 #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
78     }
79 }
80 
BOOST_AUTO_TEST_CASE(old_dynamic_image_test)81 BOOST_AUTO_TEST_CASE( old_dynamic_image_test )
82 {
83     using my_img_types = mp11::mp_list
84         <
85             gray8_image_t,
86             gray16_image_t,
87             rgb8_image_t,
88             gray1_image_t
89         >;
90 
91     any_image< my_img_types > runtime_image;
92 
93     pnm_read_image( pnm_filename.c_str()
94                   , runtime_image
95                   );
96 
97 #ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
98     pnm_write_view( pnm_out + "old_dynamic_image_test.pnm"
99                   , view( runtime_image )
100                   );
101 #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
102 }
103 
104 #endif // BOOST_GIL_IO_TEST_ALLOW_READING_IMAGES
105 
106 BOOST_AUTO_TEST_SUITE_END()
107