1 /*****************************************************************************
2 * This file is part of gfxprim library. *
4 * Gfxprim is free software; you can redistribute it and/or *
5 * modify it under the terms of the GNU Lesser General Public *
6 * License as published by the Free Software Foundation; either *
7 * version 2.1 of the License, or (at your option) any later version. *
9 * Gfxprim is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
12 * Lesser General Public License for more details. *
14 * You should have received a copy of the GNU Lesser General Public *
15 * License along with gfxprim; if not, write to the Free Software *
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
17 * Boston, MA 02110-1301 USA *
19 * Copyright (C) 2009-2014 Cyril Hrubis <metan@ucw.cz> *
21 *****************************************************************************/
27 #include <core/GP_Pixmap.h>
28 #include <core/GP_GetPutPixel.h>
29 #include <loaders/GP_Loaders.h>
33 #define LOAD GP_LoadPGM
34 #define SAVE GP_SavePGM
35 #define READ GP_ReadPGM
39 struct testcase black_1x1_1bpp
= {
43 .path
= "black_1x1_1bpp.pgm",
46 struct testcase black_1x1_2bpp
= {
50 .path
= "black_1x1_2bpp.pgm",
53 struct testcase black_1x1_4bpp
= {
57 .path
= "black_1x1_4bpp.pgm",
60 struct testcase black_1x1_8bpp
= {
64 .path
= "black_1x1_8bpp.pgm",
67 struct testcase_save_load save_load_1bpp
= {
70 .pixel_type
= GP_PIXEL_G1
,
73 struct testcase_save_load save_load_2bpp
= {
76 .pixel_type
= GP_PIXEL_G2
,
79 struct testcase_save_load save_load_4bpp
= {
82 .pixel_type
= GP_PIXEL_G4
,
85 struct testcase_save_load save_load_8bpp
= {
88 .pixel_type
= GP_PIXEL_G8
,
91 const struct tst_suite tst_suite
= {
94 {.name
= "PGM Load 1x1 1bpp (black)",
96 .res_path
= "data/pgm/valid/black_1x1_1bpp.pgm",
97 .data
= &black_1x1_1bpp
,
98 .flags
= TST_TMPDIR
| TST_CHECK_MALLOC
},
100 {.name
= "PGM Load 1x1 2bpp (black)",
102 .res_path
= "data/pgm/valid/black_1x1_2bpp.pgm",
103 .data
= &black_1x1_2bpp
,
104 .flags
= TST_TMPDIR
| TST_CHECK_MALLOC
},
106 {.name
= "PGM Load 1x1 4bpp (black)",
108 .res_path
= "data/pgm/valid/black_1x1_4bpp.pgm",
109 .data
= &black_1x1_4bpp
,
110 .flags
= TST_TMPDIR
| TST_CHECK_MALLOC
},
112 {.name
= "PGM Load 1x1 8bpp (black)",
114 .res_path
= "data/pgm/valid/black_1x1_8bpp.pgm",
115 .data
= &black_1x1_8bpp
,
116 .flags
= TST_TMPDIR
| TST_CHECK_MALLOC
},
118 {.name
= "PGM Read 1x1 1bpp (black)",
120 .data
= &PGM_ascii_1x1_1bpp_black
,
121 .flags
= TST_CHECK_MALLOC
},
123 {.name
= "PGM Read 1x1 2bpp (black)",
125 .data
= &PGM_ascii_1x1_2bpp_black
,
126 .flags
= TST_CHECK_MALLOC
},
128 {.name
= "PGM Read 1x1 4bpp (black)",
130 .data
= &PGM_ascii_1x1_4bpp_black
,
131 .flags
= TST_CHECK_MALLOC
},
133 {.name
= "PGM Read 1x1 8bpp (black)",
135 .data
= &PGM_ascii_1x1_8bpp_black
,
136 .flags
= TST_CHECK_MALLOC
},
138 {.name
= "PGM Read 1x1 1bpp (white)",
140 .data
= &PGM_ascii_1x1_1bpp_white
,
141 .flags
= TST_CHECK_MALLOC
},
143 {.name
= "PGM Read 1x1 2bpp (white)",
145 .data
= &PGM_ascii_1x1_2bpp_white
,
146 .flags
= TST_CHECK_MALLOC
},
148 {.name
= "PGM Read 1x1 4bpp (white)",
150 .data
= &PGM_ascii_1x1_4bpp_white
,
151 .flags
= TST_CHECK_MALLOC
},
153 {.name
= "PGM Read 1x1 8bpp (white)",
155 .data
= &PGM_ascii_1x1_8bpp_white
,
156 .flags
= TST_CHECK_MALLOC
},
158 {.name
= "PGM Read 1x1 1bpp (white) Raw",
160 .data
= &PGM_bin_1x1_1bpp_white
,
161 .flags
= TST_CHECK_MALLOC
},
163 {.name
= "PGM Read 1x1 2bpp (white) Raw",
165 .data
= &PGM_bin_1x1_2bpp_white
,
166 .flags
= TST_CHECK_MALLOC
},
168 {.name
= "PGM Read 1x1 4bpp (white) Raw",
170 .data
= &PGM_bin_1x1_4bpp_white
,
171 .flags
= TST_CHECK_MALLOC
},
173 {.name
= "PGM Read 1x1 8bpp (white) Raw",
175 .data
= &PGM_bin_1x1_8bpp_white
,
176 .flags
= TST_CHECK_MALLOC
},
178 {.name
= "PGM Save Load 1bpp",
179 .tst_fn
= test_save_load
,
180 .data
= &save_load_1bpp
,
181 .flags
= TST_TMPDIR
| TST_CHECK_MALLOC
},
183 {.name
= "PGM Save Load 2bpp",
184 .tst_fn
= test_save_load
,
185 .data
= &save_load_2bpp
,
186 .flags
= TST_TMPDIR
| TST_CHECK_MALLOC
},
188 {.name
= "PGM Save Load 4bpp",
189 .tst_fn
= test_save_load
,
190 .data
= &save_load_4bpp
,
191 .flags
= TST_TMPDIR
| TST_CHECK_MALLOC
},
193 {.name
= "PGM Save Load 8bpp",
194 .tst_fn
= test_save_load
,
195 .data
= &save_load_8bpp
,
196 .flags
= TST_TMPDIR
| TST_CHECK_MALLOC
},
198 {.name
= "PGM Load wrong header",
199 .tst_fn
= test_load_fail
,
200 .res_path
= "data/pgm/corrupt/wrong_header.pgm",
201 .data
= "wrong_header.pgm",
202 .flags
= TST_TMPDIR
| TST_CHECK_MALLOC
},
204 {.name
= "PGM Load incomplete",
205 .tst_fn
= test_load_fail
,
206 .res_path
= "data/pgm/corrupt/incomplete.pgm",
207 .data
= "incomplete.pgm",
208 .flags
= TST_TMPDIR
| TST_CHECK_MALLOC
},