tiff_old_test.cpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 tiff_old_test_module
  9. #include <boost/gil.hpp>
  10. #include <boost/gil/extension/io/tiff/old.hpp>
  11. #include <boost/mp11.hpp>
  12. #include <boost/test/unit_test.hpp>
  13. #include "paths.hpp"
  14. // This test file will only test the old library's interface.
  15. // It's more of a compile time test than a runtime test.
  16. using namespace std;
  17. using namespace boost;
  18. using namespace gil;
  19. BOOST_AUTO_TEST_SUITE( gil_io_tiff_tests )
  20. #ifdef BOOST_GIL_IO_TEST_ALLOW_READING_IMAGES
  21. BOOST_AUTO_TEST_CASE( old_read_dimensions_test )
  22. {
  23. boost::gil::point_t dim = tiff_read_dimensions(tiff_filename);
  24. BOOST_CHECK_EQUAL( dim.x, 1000 );
  25. BOOST_CHECK_EQUAL( dim.y, 600 );
  26. }
  27. BOOST_AUTO_TEST_CASE( old_read_image_test )
  28. {
  29. rgba8_image_t img;
  30. tiff_read_image( tiff_filename, img );
  31. BOOST_CHECK_EQUAL( img.width() , 1000 );
  32. BOOST_CHECK_EQUAL( img.height(), 600 );
  33. }
  34. BOOST_AUTO_TEST_CASE( old_read_and_convert_image_test )
  35. {
  36. rgb8_image_t img;
  37. tiff_read_and_convert_image( tiff_filename, img );
  38. BOOST_CHECK_EQUAL( img.width() , 1000 );
  39. BOOST_CHECK_EQUAL( img.height(), 600 );
  40. }
  41. BOOST_AUTO_TEST_CASE( old_read_view_test )
  42. {
  43. rgba8_image_t img( 1000, 600 );
  44. tiff_read_view( tiff_filename, view( img ) );
  45. }
  46. BOOST_AUTO_TEST_CASE( old_read_and_convert_view_test )
  47. {
  48. rgb8_image_t img( 1000, 600 );
  49. tiff_read_and_convert_view( tiff_filename, view( img ) );
  50. }
  51. BOOST_AUTO_TEST_CASE( old_dynamic_image_test )
  52. {
  53. using my_img_types = mp11::mp_list
  54. <
  55. gray8_image_t,
  56. gray16_image_t,
  57. rgba8_image_t,
  58. gray1_image_t
  59. >;
  60. any_image< my_img_types > runtime_image;
  61. tiff_read_image( tiff_filename.c_str()
  62. , runtime_image
  63. );
  64. #ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
  65. tiff_write_view( tiff_out + "old_dynamic_image_test.tif"
  66. , view( runtime_image )
  67. );
  68. #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
  69. }
  70. #endif // BOOST_GIL_IO_TEST_ALLOW_READING_IMAGES
  71. BOOST_AUTO_TEST_SUITE_END()