File: pnm_old_test.cpp

package info (click to toggle)
boost1.88 1.88.0-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 576,932 kB
  • sloc: cpp: 4,149,234; xml: 136,789; ansic: 35,092; python: 33,910; asm: 5,698; sh: 4,604; ada: 1,681; makefile: 1,633; pascal: 1,139; perl: 1,124; sql: 640; yacc: 478; ruby: 271; java: 77; lisp: 24; csh: 6
file content (99 lines) | stat: -rw-r--r-- 2,314 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
//
// 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
//
#include <boost/gil.hpp>
#include <boost/gil/extension/io/pnm/old.hpp>

#include <boost/mp11.hpp>
#include <boost/core/lightweight_test.hpp>

#include "paths.hpp"

namespace gil  = boost::gil;
namespace mp11 = boost::mp11;

#ifdef BOOST_GIL_IO_TEST_ALLOW_READING_IMAGES
void test_old_read_dimensions()
{
    boost::gil::point_t dim = gil::pnm_read_dimensions(pnm_filename);
    BOOST_TEST_EQ(dim.x, 256);
    BOOST_TEST_EQ(dim.y, 256);
}

void test_old_read_image()
{
    gil::rgb8_image_t img;
    gil::pnm_read_image(pnm_filename, img);

    BOOST_TEST_EQ(img.width(), 256);
    BOOST_TEST_EQ(img.height(), 256);
}

void test_old_read_and_convert_image()
{
    gil::rgb8_image_t img;
    gil::pnm_read_and_convert_image(pnm_filename, img);

    BOOST_TEST_EQ(img.width(), 256);
    BOOST_TEST_EQ(img.height(), 256);
}

void test_old_read_view()
{
    gil::rgb8_image_t img(256, 256);
    gil::pnm_read_view(pnm_filename, gil::view(img));
}

void test_old_read_and_convert_view()
{
    gil::rgb8_image_t img(256, 256);
    gil::pnm_read_and_convert_view(pnm_filename, gil::view(img));
}

void test_old_write_view()
{
    std::string filename(pnm_out + "test5.pnm");
    gil::gray8_image_t img(256, 256);

#ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
    gil::pnm_write_view(filename, gil::view(img));
#endif  // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
}

void test_old_dynamic_image()
{
    gil::any_image
    <
        gil::gray8_image_t,
        gil::gray16_image_t,
        gil::rgb8_image_t,
        gil::gray1_image_t
    > image;

    gil::pnm_read_image(pnm_filename.c_str(), image);

#ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
    gil::pnm_write_view(pnm_out + "old_dynamic_image_test.pnm", gil::view(image));
#endif  // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
}

int main()
{
    test_old_read_dimensions();
    test_old_read_image();
    test_old_read_and_convert_image();
    test_old_read_view();
    test_old_read_and_convert_view();
    test_old_write_view();
    test_old_dynamic_image();

    return boost::report_errors();
}

#else
int main() {}
#endif  // BOOST_GIL_IO_TEST_ALLOW_READING_IMAGES