1 /* ADG - Automatic Drawing Generation
2 * Copyright (C) 2010,2011 Nicola Fontana <ntd at entidi.it>
4 * This library 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 of the License, or (at your option) any later version.
9 * This library 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 this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
21 #include "test-internal.h"
25 _adg_test_author(void)
27 AdgTitleBlock
*title_block
;
28 const gchar
*valid_text
, *latin1_text
;
32 title_block
= adg_title_block_new();
33 valid_text
= "This is some text...";
34 latin1_text
= "This is some àèìòù Latin1 text...";
36 /* Using the public APIs */
37 adg_title_block_set_author(title_block
, valid_text
);
38 author
= adg_title_block_get_author(title_block
);
39 g_assert_cmpstr(author
, ==, valid_text
);
41 adg_title_block_set_author(title_block
, latin1_text
);
42 author
= adg_title_block_get_author(title_block
);
43 g_assert_cmpstr(author
, ==, latin1_text
);
45 adg_title_block_set_author(title_block
, NULL
);
46 author
= adg_title_block_get_author(title_block
);
47 g_assert(author
== NULL
);
49 /* Using GObject property methods */
50 g_object_set(title_block
, "author", valid_text
, NULL
);
51 g_object_get(title_block
, "author", &author_dup
, NULL
);
52 g_assert_cmpstr(author_dup
, ==, valid_text
);
55 g_object_set(title_block
, "author", latin1_text
, NULL
);
56 g_object_get(title_block
, "author", &author_dup
, NULL
);
57 g_assert_cmpstr(author_dup
, ==, latin1_text
);
60 g_object_set(title_block
, "author", NULL
, NULL
);
61 g_object_get(title_block
, "author", &author_dup
, NULL
);
62 g_assert(author_dup
== NULL
);
64 adg_entity_destroy(ADG_ENTITY(title_block
));
70 AdgTitleBlock
*title_block
;
71 const gchar
*valid_text
, *latin1_text
;
75 title_block
= adg_title_block_new();
76 valid_text
= "This is some text...";
77 latin1_text
= "This is some àèìòù Latin1 text...";
79 /* Using the public APIs */
80 adg_title_block_set_date(title_block
, valid_text
);
81 date
= adg_title_block_get_date(title_block
);
82 g_assert_cmpstr(date
, ==, valid_text
);
84 adg_title_block_set_date(title_block
, latin1_text
);
85 date
= adg_title_block_get_date(title_block
);
86 g_assert_cmpstr(date
, ==, latin1_text
);
88 adg_title_block_set_date(title_block
, NULL
);
89 date
= adg_title_block_get_date(title_block
);
90 g_assert(date
!= NULL
);
92 /* Using GObject property methods */
93 g_object_set(title_block
, "date", valid_text
, NULL
);
94 g_object_get(title_block
, "date", &date_dup
, NULL
);
95 g_assert_cmpstr(date_dup
, ==, valid_text
);
98 g_object_set(title_block
, "date", latin1_text
, NULL
);
99 g_object_get(title_block
, "date", &date_dup
, NULL
);
100 g_assert_cmpstr(date_dup
, ==, latin1_text
);
103 g_object_set(title_block
, "date", NULL
, NULL
);
104 g_object_get(title_block
, "date", &date_dup
, NULL
);
105 g_assert(date_dup
!= NULL
);
108 adg_entity_destroy(ADG_ENTITY(title_block
));
112 _adg_test_drawing(void)
114 AdgTitleBlock
*title_block
;
115 const gchar
*valid_text
, *latin1_text
;
116 const gchar
*drawing
;
119 title_block
= adg_title_block_new();
120 valid_text
= "This is some text...";
121 latin1_text
= "This is some àèìòù Latin1 text...";
123 /* Using the public APIs */
124 adg_title_block_set_drawing(title_block
, valid_text
);
125 drawing
= adg_title_block_get_drawing(title_block
);
126 g_assert_cmpstr(drawing
, ==, valid_text
);
128 adg_title_block_set_drawing(title_block
, latin1_text
);
129 drawing
= adg_title_block_get_drawing(title_block
);
130 g_assert_cmpstr(drawing
, ==, latin1_text
);
132 adg_title_block_set_drawing(title_block
, NULL
);
133 drawing
= adg_title_block_get_drawing(title_block
);
134 g_assert(drawing
== NULL
);
136 /* Using GObject property methods */
137 g_object_set(title_block
, "drawing", valid_text
, NULL
);
138 g_object_get(title_block
, "drawing", &drawing_dup
, NULL
);
139 g_assert_cmpstr(drawing_dup
, ==, valid_text
);
142 g_object_set(title_block
, "drawing", latin1_text
, NULL
);
143 g_object_get(title_block
, "drawing", &drawing_dup
, NULL
);
144 g_assert_cmpstr(drawing_dup
, ==, latin1_text
);
147 g_object_set(title_block
, "drawing", NULL
, NULL
);
148 g_object_get(title_block
, "drawing", &drawing_dup
, NULL
);
149 g_assert(drawing_dup
== NULL
);
151 adg_entity_destroy(ADG_ENTITY(title_block
));
157 AdgTitleBlock
*title_block
;
158 AdgEntity
*valid_entity
, *invalid_entity
, *logo
;
160 title_block
= adg_title_block_new();
161 valid_entity
= ADG_ENTITY(adg_hatch_new(NULL
));
162 invalid_entity
= adg_test_invalid_pointer();
164 /* Using the public APIs */
165 adg_title_block_set_logo(title_block
, valid_entity
);
166 logo
= adg_title_block_logo(title_block
);
167 g_assert(logo
== valid_entity
);
169 adg_title_block_set_logo(title_block
, invalid_entity
);
170 logo
= adg_title_block_logo(title_block
);
171 g_assert(logo
== valid_entity
);
173 adg_title_block_set_logo(title_block
, NULL
);
174 logo
= adg_title_block_logo(title_block
);
175 g_assert(logo
== NULL
);
177 /* Using GObject property methods */
178 g_object_set(title_block
, "logo", valid_entity
, NULL
);
179 g_object_get(title_block
, "logo", &logo
, NULL
);
180 g_assert(logo
== valid_entity
);
181 adg_entity_destroy(logo
);
183 g_object_set(title_block
, "logo", invalid_entity
, NULL
);
184 g_object_get(title_block
, "logo", &logo
, NULL
);
185 g_assert(logo
== valid_entity
);
186 adg_entity_destroy(logo
);
188 g_object_set(title_block
, "logo", NULL
, NULL
);
189 g_object_get(title_block
, "logo", &logo
, NULL
);
190 g_assert(logo
== NULL
);
192 adg_entity_destroy(ADG_ENTITY(title_block
));
193 adg_entity_destroy(valid_entity
);
197 _adg_test_projection(void)
199 AdgTitleBlock
*title_block
;
200 AdgEntity
*valid_entity
, *invalid_entity
, *projection
;
202 title_block
= adg_title_block_new();
203 valid_entity
= ADG_ENTITY(adg_hatch_new(NULL
));
204 invalid_entity
= adg_test_invalid_pointer();
206 /* Using the public APIs */
207 adg_title_block_set_projection(title_block
, valid_entity
);
208 projection
= adg_title_block_projection(title_block
);
209 g_assert(projection
== valid_entity
);
211 adg_title_block_set_projection(title_block
, invalid_entity
);
212 projection
= adg_title_block_projection(title_block
);
213 g_assert(projection
== valid_entity
);
215 adg_title_block_set_projection(title_block
, NULL
);
216 projection
= adg_title_block_projection(title_block
);
217 g_assert(projection
== NULL
);
219 /* Using GObject property methods */
220 g_object_set(title_block
, "projection", valid_entity
, NULL
);
221 g_object_get(title_block
, "projection", &projection
, NULL
);
222 g_assert(projection
== valid_entity
);
223 adg_entity_destroy(projection
);
225 g_object_set(title_block
, "projection", invalid_entity
, NULL
);
226 g_object_get(title_block
, "projection", &projection
, NULL
);
227 g_assert(projection
== valid_entity
);
228 adg_entity_destroy(projection
);
230 g_object_set(title_block
, "projection", NULL
, NULL
);
231 g_object_get(title_block
, "projection", &projection
, NULL
);
232 g_assert(projection
== NULL
);
234 adg_entity_destroy(ADG_ENTITY(title_block
));
235 adg_entity_destroy(valid_entity
);
239 _adg_test_scale(void)
241 AdgTitleBlock
*title_block
;
242 const gchar
*valid_text
, *latin1_text
;
246 title_block
= adg_title_block_new();
247 valid_text
= "This is some text...";
248 latin1_text
= "This is some àèìòù Latin1 text...";
250 /* Using the public APIs */
251 adg_title_block_set_scale(title_block
, valid_text
);
252 scale
= adg_title_block_get_scale(title_block
);
253 g_assert_cmpstr(scale
, ==, valid_text
);
255 adg_title_block_set_scale(title_block
, latin1_text
);
256 scale
= adg_title_block_get_scale(title_block
);
257 g_assert_cmpstr(scale
, ==, latin1_text
);
259 adg_title_block_set_scale(title_block
, NULL
);
260 scale
= adg_title_block_get_scale(title_block
);
261 g_assert(scale
== NULL
);
263 /* Using GObject property methods */
264 g_object_set(title_block
, "scale", valid_text
, NULL
);
265 g_object_get(title_block
, "scale", &scale_dup
, NULL
);
266 g_assert_cmpstr(scale_dup
, ==, valid_text
);
269 g_object_set(title_block
, "scale", latin1_text
, NULL
);
270 g_object_get(title_block
, "scale", &scale_dup
, NULL
);
271 g_assert_cmpstr(scale_dup
, ==, latin1_text
);
274 g_object_set(title_block
, "scale", NULL
, NULL
);
275 g_object_get(title_block
, "scale", &scale_dup
, NULL
);
276 g_assert(scale_dup
== NULL
);
278 adg_entity_destroy(ADG_ENTITY(title_block
));
284 AdgTitleBlock
*title_block
;
285 const gchar
*valid_text
, *latin1_text
;
289 title_block
= adg_title_block_new();
290 valid_text
= "This is some text...";
291 latin1_text
= "This is some àèìòù Latin1 text...";
293 /* Using the public APIs */
294 adg_title_block_set_size(title_block
, valid_text
);
295 size
= adg_title_block_get_size(title_block
);
296 g_assert_cmpstr(size
, ==, valid_text
);
298 adg_title_block_set_size(title_block
, latin1_text
);
299 size
= adg_title_block_get_size(title_block
);
300 g_assert_cmpstr(size
, ==, latin1_text
);
302 adg_title_block_set_size(title_block
, NULL
);
303 size
= adg_title_block_get_size(title_block
);
304 g_assert(size
== NULL
);
306 /* Using GObject property methods */
307 g_object_set(title_block
, "size", valid_text
, NULL
);
308 g_object_get(title_block
, "size", &size_dup
, NULL
);
309 g_assert_cmpstr(size_dup
, ==, valid_text
);
312 g_object_set(title_block
, "size", latin1_text
, NULL
);
313 g_object_get(title_block
, "size", &size_dup
, NULL
);
314 g_assert_cmpstr(size_dup
, ==, latin1_text
);
317 g_object_set(title_block
, "size", NULL
, NULL
);
318 g_object_get(title_block
, "size", &size_dup
, NULL
);
319 g_assert(size_dup
== NULL
);
321 adg_entity_destroy(ADG_ENTITY(title_block
));
325 _adg_test_title(void)
327 AdgTitleBlock
*title_block
;
328 const gchar
*valid_text
, *latin1_text
;
332 title_block
= adg_title_block_new();
333 valid_text
= "This is some text...";
334 latin1_text
= "This is some àèìòù Latin1 text...";
336 /* Using the public APIs */
337 adg_title_block_set_title(title_block
, valid_text
);
338 title
= adg_title_block_get_title(title_block
);
339 g_assert_cmpstr(title
, ==, valid_text
);
341 adg_title_block_set_title(title_block
, latin1_text
);
342 title
= adg_title_block_get_title(title_block
);
343 g_assert_cmpstr(title
, ==, latin1_text
);
345 adg_title_block_set_title(title_block
, NULL
);
346 title
= adg_title_block_get_title(title_block
);
347 g_assert(title
== NULL
);
349 /* Using GObject property methods */
350 g_object_set(title_block
, "title", valid_text
, NULL
);
351 g_object_get(title_block
, "title", &title_dup
, NULL
);
352 g_assert_cmpstr(title_dup
, ==, valid_text
);
355 g_object_set(title_block
, "title", latin1_text
, NULL
);
356 g_object_get(title_block
, "title", &title_dup
, NULL
);
357 g_assert_cmpstr(title_dup
, ==, latin1_text
);
360 g_object_set(title_block
, "title", NULL
, NULL
);
361 g_object_get(title_block
, "title", &title_dup
, NULL
);
362 g_assert(title_dup
== NULL
);
364 adg_entity_destroy(ADG_ENTITY(title_block
));
369 main(int argc
, char *argv
[])
371 adg_test_init(&argc
, &argv
);
373 adg_test_add_func("/adg/title-block/author", _adg_test_author
);
374 adg_test_add_func("/adg/title-block/date", _adg_test_date
);
375 adg_test_add_func("/adg/title-block/drawing", _adg_test_drawing
);
376 adg_test_add_func("/adg/title-block/logo", _adg_test_logo
);
377 adg_test_add_func("/adg/title-block/projection", _adg_test_projection
);
378 adg_test_add_func("/adg/title-block/scale", _adg_test_scale
);
379 adg_test_add_func("/adg/title-block/size", _adg_test_size
);
380 adg_test_add_func("/adg/title-block/title", _adg_test_title
);