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_LoadPBM
34 #define SAVE GP_SavePBM
35 #define READ GP_ReadPBM
39 struct testcase black_1x1_1
= {
43 .path
= "black_1x1_1.pbm",
46 struct testcase black_1x1_2
= {
50 .path
= "black_1x1_2.pbm",
53 struct testcase black_1x1_3
= {
57 .path
= "black_1x1_3.pbm",
60 struct testcase black_1x1_4
= {
64 .path
= "black_1x1_4.pbm",
67 struct testcase white_1x1
= {
71 .path
= "white_1x1.pbm",
74 struct testcase black_1x1_bin
= {
78 .path
= "black_1x1_bin.pbm",
81 struct testcase black_2x2_bin
= {
85 .path
= "black_2x2_bin.pbm",
88 struct testcase black_3x9_bin
= {
92 .path
= "black_3x9_bin.pbm",
95 struct testcase_save_load save_load
= {
98 .pixel_type
= GP_PIXEL_G1
,
101 const struct tst_suite tst_suite
= {
104 {.name
= "PBM Load 1x1 (black)",
106 //TODO: Add copy to to res path
107 .res_path
= "data/pbm/valid/black_1x1_1.pbm",
108 .data
= &black_1x1_1
,
109 .flags
= TST_TMPDIR
| TST_CHECK_MALLOC
},
111 {.name
= "PBM Load 1x1 (white)",
113 .res_path
= "data/pbm/valid/white_1x1.pbm",
115 .flags
= TST_TMPDIR
| TST_CHECK_MALLOC
},
117 {.name
= "PBM Load 1x1 +comments",
119 .res_path
= "data/pbm/valid/black_1x1_2.pbm",
120 .data
= &black_1x1_2
,
121 .flags
= TST_TMPDIR
| TST_CHECK_MALLOC
},
123 {.name
= "PBM Load 1x1 +comments +whitespaces",
125 .res_path
= "data/pbm/valid/black_1x1_3.pbm",
126 .data
= &black_1x1_3
,
127 .flags
= TST_TMPDIR
| TST_CHECK_MALLOC
},
129 {.name
= "PBM Load 1x1 (invalid loadable)",
131 .res_path
= "data/pbm/valid/black_1x1_4.pbm",
132 .data
= &black_1x1_4
,
133 .flags
= TST_TMPDIR
| TST_CHECK_MALLOC
},
135 {.name
= "PBM Load 1x1 (black) Raw",
137 .res_path
= "data/pbm/valid/black_1x1_bin.pbm",
138 .data
= &black_1x1_bin
,
139 .flags
= TST_TMPDIR
| TST_CHECK_MALLOC
},
141 {.name
= "PBM Load 2x2 (black) Raw",
143 .res_path
= "data/pbm/valid/black_2x2_bin.pbm",
144 .data
= &black_2x2_bin
,
145 .flags
= TST_TMPDIR
| TST_CHECK_MALLOC
},
147 {.name
= "PBM Load 3x9 (black) Raw",
149 .res_path
= "data/pbm/valid/black_3x9_bin.pbm",
150 .data
= &black_3x9_bin
,
151 .flags
= TST_TMPDIR
| TST_CHECK_MALLOC
},
153 {.name
= "PBM Read 1x1 (black)",
155 .data
= &PBM_ascii_1x1_black
,
156 .flags
= TST_CHECK_MALLOC
},
158 {.name
= "PBM Read 1x1 (white)",
160 .data
= &PBM_ascii_1x1_white
,
161 .flags
= TST_CHECK_MALLOC
},
163 {.name
= "PBM Read 1x1 (black) Raw",
165 .data
= &PBM_bin_1x1_black
,
166 .flags
= TST_CHECK_MALLOC
},
168 {.name
= "PBM Read 1x1 (white) Raw",
170 .data
= &PBM_bin_1x1_white
,
171 .flags
= TST_CHECK_MALLOC
},
173 {.name
= "PBM Load corrupt",
174 .tst_fn
= test_load_fail
,
175 .res_path
= "data/pbm/corrupt/short.pbm",
177 .flags
= TST_TMPDIR
| TST_CHECK_MALLOC
},
179 {.name
= "PBM Load wrong header",
180 .tst_fn
= test_load_fail
,
181 .res_path
= "data/pbm/corrupt/wrong_header.pbm",
182 .data
= "wrong_header.pbm",
183 .flags
= TST_TMPDIR
| TST_CHECK_MALLOC
},
185 {.name
= "PBM Load empty",
186 .tst_fn
= test_load_fail
,
187 .res_path
= "data/pbm/corrupt/empty.pbm",
189 .flags
= TST_TMPDIR
| TST_CHECK_MALLOC
},
191 {.name
= "PBM Save Load",
192 .tst_fn
= test_save_load
,
194 .flags
= TST_TMPDIR
| TST_CHECK_MALLOC
},