1 /* ADG - Automatic Drawing Generation
2 * Copyright (C) 2007,2008,2009,2010,2011,2012,2013 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_baseline_spacing(void)
27 AdgDimStyle
*dim_style
;
28 gdouble valid_baseline_spacing_1
, valid_baseline_spacing_2
, invalid_baseline_spacing
;
29 gdouble baseline_spacing
;
31 dim_style
= adg_dim_style_new();
32 valid_baseline_spacing_1
= 0;
33 valid_baseline_spacing_2
= 999;
34 invalid_baseline_spacing
= -1;
36 /* Using the public APIs */
37 adg_dim_style_set_baseline_spacing(dim_style
, valid_baseline_spacing_1
);
38 baseline_spacing
= adg_dim_style_get_baseline_spacing(dim_style
);
39 g_assert_cmpfloat(baseline_spacing
, ==, valid_baseline_spacing_1
);
41 adg_dim_style_set_baseline_spacing(dim_style
, invalid_baseline_spacing
);
42 baseline_spacing
= adg_dim_style_get_baseline_spacing(dim_style
);
43 g_assert_cmpfloat(baseline_spacing
, ==, valid_baseline_spacing_1
);
45 adg_dim_style_set_baseline_spacing(dim_style
, valid_baseline_spacing_2
);
46 baseline_spacing
= adg_dim_style_get_baseline_spacing(dim_style
);
47 g_assert_cmpfloat(baseline_spacing
, ==, valid_baseline_spacing_2
);
49 /* Using GObject property methods */
50 g_object_set(dim_style
, "baseline-spacing", valid_baseline_spacing_1
, NULL
);
51 g_object_get(dim_style
, "baseline-spacing", &baseline_spacing
, NULL
);
52 g_assert_cmpfloat(baseline_spacing
, ==, valid_baseline_spacing_1
);
54 g_object_set(dim_style
, "baseline-spacing", invalid_baseline_spacing
, NULL
);
55 g_object_get(dim_style
, "baseline-spacing", &baseline_spacing
, NULL
);
56 g_assert_cmpfloat(baseline_spacing
, ==, valid_baseline_spacing_1
);
58 g_object_set(dim_style
, "baseline-spacing", valid_baseline_spacing_2
, NULL
);
59 g_object_get(dim_style
, "baseline-spacing", &baseline_spacing
, NULL
);
60 g_assert_cmpfloat(baseline_spacing
, ==, valid_baseline_spacing_2
);
62 g_object_unref(dim_style
);
68 AdgDimStyle
*dim_style
;
69 gdouble valid_beyond_1
, valid_beyond_2
, invalid_beyond
;
72 dim_style
= adg_dim_style_new();
77 /* Using the public APIs */
78 adg_dim_style_set_beyond(dim_style
, valid_beyond_1
);
79 beyond
= adg_dim_style_get_beyond(dim_style
);
80 g_assert_cmpfloat(beyond
, ==, valid_beyond_1
);
82 adg_dim_style_set_beyond(dim_style
, invalid_beyond
);
83 beyond
= adg_dim_style_get_beyond(dim_style
);
84 g_assert_cmpfloat(beyond
, ==, valid_beyond_1
);
86 adg_dim_style_set_beyond(dim_style
, valid_beyond_2
);
87 beyond
= adg_dim_style_get_beyond(dim_style
);
88 g_assert_cmpfloat(beyond
, ==, valid_beyond_2
);
90 /* Using GObject property methods */
91 g_object_set(dim_style
, "beyond", valid_beyond_1
, NULL
);
92 g_object_get(dim_style
, "beyond", &beyond
, NULL
);
93 g_assert_cmpfloat(beyond
, ==, valid_beyond_1
);
95 g_object_set(dim_style
, "beyond", invalid_beyond
, NULL
);
96 g_object_get(dim_style
, "beyond", &beyond
, NULL
);
97 g_assert_cmpfloat(beyond
, ==, valid_beyond_1
);
99 g_object_set(dim_style
, "beyond", valid_beyond_2
, NULL
);
100 g_object_get(dim_style
, "beyond", &beyond
, NULL
);
101 g_assert_cmpfloat(beyond
, ==, valid_beyond_2
);
103 g_object_unref(dim_style
);
107 _adg_color_dress(void)
109 AdgDimStyle
*dim_style
;
110 AdgDress valid_dress_1
, valid_dress_2
, incompatible_dress
;
111 AdgDress color_dress
;
113 dim_style
= adg_dim_style_new();
114 valid_dress_1
= ADG_DRESS_COLOR_ANNOTATION
;
115 valid_dress_2
= ADG_DRESS_COLOR
;
116 incompatible_dress
= ADG_DRESS_FONT
;
118 /* Using the public APIs */
119 adg_dim_style_set_color_dress(dim_style
, valid_dress_1
);
120 color_dress
= adg_dim_style_get_color_dress(dim_style
);
121 g_assert_cmpint(color_dress
, ==, valid_dress_1
);
123 adg_dim_style_set_color_dress(dim_style
, incompatible_dress
);
124 color_dress
= adg_dim_style_get_color_dress(dim_style
);
125 g_assert_cmpint(color_dress
, ==, valid_dress_1
);
127 adg_dim_style_set_color_dress(dim_style
, valid_dress_2
);
128 color_dress
= adg_dim_style_get_color_dress(dim_style
);
129 g_assert_cmpint(color_dress
, ==, valid_dress_2
);
131 /* Using GObject property methods */
132 g_object_set(dim_style
, "color-dress", valid_dress_1
, NULL
);
133 g_object_get(dim_style
, "color-dress", &color_dress
, NULL
);
134 g_assert_cmpint(color_dress
, ==, valid_dress_1
);
136 g_object_set(dim_style
, "color-dress", incompatible_dress
, NULL
);
137 g_object_get(dim_style
, "color-dress", &color_dress
, NULL
);
138 g_assert_cmpint(color_dress
, ==, valid_dress_1
);
140 g_object_set(dim_style
, "color-dress", valid_dress_2
, NULL
);
141 g_object_get(dim_style
, "color-dress", &color_dress
, NULL
);
142 g_assert_cmpint(color_dress
, ==, valid_dress_2
);
144 g_object_unref(dim_style
);
148 _adg_from_offset(void)
150 AdgDimStyle
*dim_style
;
151 gdouble valid_from_offset_1
, valid_from_offset_2
, invalid_from_offset
;
154 dim_style
= adg_dim_style_new();
155 valid_from_offset_1
= 0;
156 valid_from_offset_2
= 999;
157 invalid_from_offset
= -1;
159 /* Using the public APIs */
160 adg_dim_style_set_from_offset(dim_style
, valid_from_offset_1
);
161 from_offset
= adg_dim_style_get_from_offset(dim_style
);
162 g_assert_cmpfloat(from_offset
, ==, valid_from_offset_1
);
164 adg_dim_style_set_from_offset(dim_style
, invalid_from_offset
);
165 from_offset
= adg_dim_style_get_from_offset(dim_style
);
166 g_assert_cmpfloat(from_offset
, ==, valid_from_offset_1
);
168 adg_dim_style_set_from_offset(dim_style
, valid_from_offset_2
);
169 from_offset
= adg_dim_style_get_from_offset(dim_style
);
170 g_assert_cmpfloat(from_offset
, ==, valid_from_offset_2
);
172 /* Using GObject property methods */
173 g_object_set(dim_style
, "from-offset", valid_from_offset_1
, NULL
);
174 g_object_get(dim_style
, "from-offset", &from_offset
, NULL
);
175 g_assert_cmpfloat(from_offset
, ==, valid_from_offset_1
);
177 g_object_set(dim_style
, "from-offset", invalid_from_offset
, NULL
);
178 g_object_get(dim_style
, "from-offset", &from_offset
, NULL
);
179 g_assert_cmpfloat(from_offset
, ==, valid_from_offset_1
);
181 g_object_set(dim_style
, "from-offset", valid_from_offset_2
, NULL
);
182 g_object_get(dim_style
, "from-offset", &from_offset
, NULL
);
183 g_assert_cmpfloat(from_offset
, ==, valid_from_offset_2
);
185 g_object_unref(dim_style
);
189 _adg_limits_shift(void)
191 AdgDimStyle
*dim_style
;
192 CpmlPair null_shift
, identity_shift
;
193 const CpmlPair
*shift
;
196 dim_style
= adg_dim_style_new();
199 identity_shift
.x
= 1;
200 identity_shift
.y
= 1;
202 /* Using the public APIs */
203 adg_dim_style_set_limits_shift(dim_style
, &identity_shift
);
204 shift
= adg_dim_style_get_limits_shift(dim_style
);
205 g_assert(cpml_pair_equal(shift
, &identity_shift
));
207 adg_dim_style_set_limits_shift(dim_style
, &null_shift
);
208 shift
= adg_dim_style_get_limits_shift(dim_style
);
209 g_assert(cpml_pair_equal(shift
, &null_shift
));
211 adg_dim_style_set_limits_shift(dim_style
, NULL
);
212 shift
= adg_dim_style_get_limits_shift(dim_style
);
213 g_assert(cpml_pair_equal(shift
, &null_shift
));
215 /* Using GObject property methods */
216 g_object_set(dim_style
, "limits-shift", &identity_shift
, NULL
);
217 g_object_get(dim_style
, "limits-shift", &shift_dup
, NULL
);
218 g_assert(cpml_pair_equal(shift_dup
, &identity_shift
));
221 g_object_set(dim_style
, "limits-shift", NULL
, NULL
);
222 g_object_get(dim_style
, "limits-shift", &shift_dup
, NULL
);
223 g_assert(cpml_pair_equal(shift_dup
, &identity_shift
));
226 g_object_set(dim_style
, "limits-shift", &null_shift
, NULL
);
227 g_object_get(dim_style
, "limits-shift", &shift_dup
, NULL
);
228 g_assert(cpml_pair_equal(shift_dup
, &null_shift
));
231 g_object_unref(dim_style
);
235 _adg_limits_spacing(void)
237 AdgDimStyle
*dim_style
;
238 gdouble valid_limits_spacing_1
, valid_limits_spacing_2
, invalid_limits_spacing
;
239 gdouble limits_spacing
;
241 dim_style
= adg_dim_style_new();
242 valid_limits_spacing_1
= 0;
243 valid_limits_spacing_2
= 999;
244 invalid_limits_spacing
= -1;
246 /* Using the public APIs */
247 adg_dim_style_set_limits_spacing(dim_style
, valid_limits_spacing_1
);
248 limits_spacing
= adg_dim_style_get_limits_spacing(dim_style
);
249 g_assert_cmpfloat(limits_spacing
, ==, valid_limits_spacing_1
);
251 adg_dim_style_set_limits_spacing(dim_style
, invalid_limits_spacing
);
252 limits_spacing
= adg_dim_style_get_limits_spacing(dim_style
);
253 g_assert_cmpfloat(limits_spacing
, ==, valid_limits_spacing_1
);
255 adg_dim_style_set_limits_spacing(dim_style
, valid_limits_spacing_2
);
256 limits_spacing
= adg_dim_style_get_limits_spacing(dim_style
);
257 g_assert_cmpfloat(limits_spacing
, ==, valid_limits_spacing_2
);
259 /* Using GObject property methods */
260 g_object_set(dim_style
, "limits-spacing", valid_limits_spacing_1
, NULL
);
261 g_object_get(dim_style
, "limits-spacing", &limits_spacing
, NULL
);
262 g_assert_cmpfloat(limits_spacing
, ==, valid_limits_spacing_1
);
264 g_object_set(dim_style
, "limits-spacing", invalid_limits_spacing
, NULL
);
265 g_object_get(dim_style
, "limits-spacing", &limits_spacing
, NULL
);
266 g_assert_cmpfloat(limits_spacing
, ==, valid_limits_spacing_1
);
268 g_object_set(dim_style
, "limits-spacing", valid_limits_spacing_2
, NULL
);
269 g_object_get(dim_style
, "limits-spacing", &limits_spacing
, NULL
);
270 g_assert_cmpfloat(limits_spacing
, ==, valid_limits_spacing_2
);
272 g_object_unref(dim_style
);
276 _adg_line_dress(void)
278 AdgDimStyle
*dim_style
;
279 AdgDress valid_dress_1
, valid_dress_2
, incompatible_dress
;
282 dim_style
= adg_dim_style_new();
283 valid_dress_1
= ADG_DRESS_LINE_FILL
;
284 valid_dress_2
= ADG_DRESS_LINE
;
285 incompatible_dress
= ADG_DRESS_COLOR
;
287 /* Using the public APIs */
288 adg_dim_style_set_line_dress(dim_style
, valid_dress_1
);
289 line_dress
= adg_dim_style_get_line_dress(dim_style
);
290 g_assert_cmpint(line_dress
, ==, valid_dress_1
);
292 adg_dim_style_set_line_dress(dim_style
, incompatible_dress
);
293 line_dress
= adg_dim_style_get_line_dress(dim_style
);
294 g_assert_cmpint(line_dress
, ==, valid_dress_1
);
296 adg_dim_style_set_line_dress(dim_style
, valid_dress_2
);
297 line_dress
= adg_dim_style_get_line_dress(dim_style
);
298 g_assert_cmpint(line_dress
, ==, valid_dress_2
);
300 /* Using GObject property methods */
301 g_object_set(dim_style
, "line-dress", valid_dress_1
, NULL
);
302 g_object_get(dim_style
, "line-dress", &line_dress
, NULL
);
303 g_assert_cmpint(line_dress
, ==, valid_dress_1
);
305 g_object_set(dim_style
, "line-dress", incompatible_dress
, NULL
);
306 g_object_get(dim_style
, "line-dress", &line_dress
, NULL
);
307 g_assert_cmpint(line_dress
, ==, valid_dress_1
);
309 g_object_set(dim_style
, "line-dress", valid_dress_2
, NULL
);
310 g_object_get(dim_style
, "line-dress", &line_dress
, NULL
);
311 g_assert_cmpint(line_dress
, ==, valid_dress_2
);
313 g_object_unref(dim_style
);
319 AdgDimStyle
*dim_style
;
320 AdgMarker
*valid_marker
, *invalid_marker
, *marker
;
322 dim_style
= adg_dim_style_new();
323 valid_marker
= ADG_MARKER(adg_arrow_new());
324 invalid_marker
= adg_test_invalid_pointer();
326 /* Using the public APIs */
327 adg_dim_style_set_marker1(dim_style
, valid_marker
);
328 marker
= adg_dim_style_marker1_new(dim_style
);
329 g_assert(marker
!= NULL
);
330 adg_entity_destroy(ADG_ENTITY(marker
));
332 adg_dim_style_set_marker1(dim_style
, invalid_marker
);
333 marker
= adg_dim_style_marker1_new(dim_style
);
334 g_assert(marker
!= NULL
);
335 adg_entity_destroy(ADG_ENTITY(marker
));
337 adg_dim_style_set_marker1(dim_style
, NULL
);
338 marker
= adg_dim_style_marker1_new(dim_style
);
339 g_assert(marker
== NULL
);
341 /* Using GObject property methods */
342 g_object_set(dim_style
, "marker1", valid_marker
, NULL
);
343 marker
= adg_dim_style_marker1_new(dim_style
);
344 g_assert(marker
!= NULL
);
345 adg_entity_destroy(ADG_ENTITY(marker
));
347 g_object_set(dim_style
, "marker1", invalid_marker
, NULL
);
348 marker
= adg_dim_style_marker1_new(dim_style
);
349 g_assert(marker
!= NULL
);
350 adg_entity_destroy(ADG_ENTITY(marker
));
352 g_object_set(dim_style
, "marker1", NULL
, NULL
);
353 marker
= adg_dim_style_marker1_new(dim_style
);
354 g_assert(marker
== NULL
);
356 g_object_unref(dim_style
);
357 adg_entity_destroy(ADG_ENTITY(valid_marker
));
363 AdgDimStyle
*dim_style
;
364 AdgMarker
*valid_marker
, *invalid_marker
, *marker
;
366 dim_style
= adg_dim_style_new();
367 valid_marker
= ADG_MARKER(adg_arrow_new());
368 invalid_marker
= adg_test_invalid_pointer();
370 /* Using the public APIs */
371 adg_dim_style_set_marker2(dim_style
, valid_marker
);
372 marker
= adg_dim_style_marker2_new(dim_style
);
373 g_assert(marker
!= NULL
);
374 adg_entity_destroy(ADG_ENTITY(marker
));
376 adg_dim_style_set_marker2(dim_style
, invalid_marker
);
377 marker
= adg_dim_style_marker2_new(dim_style
);
378 g_assert(marker
!= NULL
);
379 adg_entity_destroy(ADG_ENTITY(marker
));
381 adg_dim_style_set_marker2(dim_style
, NULL
);
382 marker
= adg_dim_style_marker2_new(dim_style
);
383 g_assert(marker
== NULL
);
385 /* Using GObject property methods */
386 g_object_set(dim_style
, "marker2", valid_marker
, NULL
);
387 marker
= adg_dim_style_marker2_new(dim_style
);
388 g_assert(marker
!= NULL
);
389 adg_entity_destroy(ADG_ENTITY(marker
));
391 g_object_set(dim_style
, "marker2", invalid_marker
, NULL
);
392 marker
= adg_dim_style_marker2_new(dim_style
);
393 g_assert(marker
!= NULL
);
394 adg_entity_destroy(ADG_ENTITY(marker
));
396 g_object_set(dim_style
, "marker2", NULL
, NULL
);
397 marker
= adg_dim_style_marker2_new(dim_style
);
398 g_assert(marker
== NULL
);
400 g_object_unref(dim_style
);
401 adg_entity_destroy(ADG_ENTITY(valid_marker
));
407 AdgDimStyle
*dim_style
;
408 AdgDress valid_dress_1
, valid_dress_2
, incompatible_dress
;
411 dim_style
= adg_dim_style_new();
412 valid_dress_1
= ADG_DRESS_FONT_QUOTE_ANNOTATION
;
413 valid_dress_2
= ADG_DRESS_FONT_ANNOTATION
;
414 incompatible_dress
= ADG_DRESS_FILL_HATCH
;
416 /* Using the public APIs */
417 adg_dim_style_set_max_dress(dim_style
, valid_dress_1
);
418 max_dress
= adg_dim_style_get_max_dress(dim_style
);
419 g_assert_cmpint(max_dress
, ==, valid_dress_1
);
421 adg_dim_style_set_max_dress(dim_style
, incompatible_dress
);
422 max_dress
= adg_dim_style_get_max_dress(dim_style
);
423 g_assert_cmpint(max_dress
, ==, valid_dress_1
);
425 adg_dim_style_set_max_dress(dim_style
, valid_dress_2
);
426 max_dress
= adg_dim_style_get_max_dress(dim_style
);
427 g_assert_cmpint(max_dress
, ==, valid_dress_2
);
429 /* Using GObject property methods */
430 g_object_set(dim_style
, "max-dress", valid_dress_1
, NULL
);
431 g_object_get(dim_style
, "max-dress", &max_dress
, NULL
);
432 g_assert_cmpint(max_dress
, ==, valid_dress_1
);
434 g_object_set(dim_style
, "max-dress", incompatible_dress
, NULL
);
435 g_object_get(dim_style
, "max-dress", &max_dress
, NULL
);
436 g_assert_cmpint(max_dress
, ==, valid_dress_1
);
438 g_object_set(dim_style
, "max-dress", valid_dress_2
, NULL
);
439 g_object_get(dim_style
, "max-dress", &max_dress
, NULL
);
440 g_assert_cmpint(max_dress
, ==, valid_dress_2
);
442 g_object_unref(dim_style
);
448 AdgDimStyle
*dim_style
;
449 AdgDress valid_dress_1
, valid_dress_2
, incompatible_dress
;
452 dim_style
= adg_dim_style_new();
453 valid_dress_1
= ADG_DRESS_FONT_QUOTE_TEXT
;
454 valid_dress_2
= ADG_DRESS_FONT_QUOTE_ANNOTATION
;
455 incompatible_dress
= ADG_DRESS_FILL_HATCH
;
457 /* Using the public APIs */
458 adg_dim_style_set_min_dress(dim_style
, valid_dress_1
);
459 min_dress
= adg_dim_style_get_min_dress(dim_style
);
460 g_assert_cmpint(min_dress
, ==, valid_dress_1
);
462 adg_dim_style_set_min_dress(dim_style
, incompatible_dress
);
463 min_dress
= adg_dim_style_get_min_dress(dim_style
);
464 g_assert_cmpint(min_dress
, ==, valid_dress_1
);
466 adg_dim_style_set_min_dress(dim_style
, valid_dress_2
);
467 min_dress
= adg_dim_style_get_min_dress(dim_style
);
468 g_assert_cmpint(min_dress
, ==, valid_dress_2
);
470 /* Using GObject property methods */
471 g_object_set(dim_style
, "min-dress", valid_dress_1
, NULL
);
472 g_object_get(dim_style
, "min-dress", &min_dress
, NULL
);
473 g_assert_cmpint(min_dress
, ==, valid_dress_1
);
475 g_object_set(dim_style
, "min-dress", incompatible_dress
, NULL
);
476 g_object_get(dim_style
, "min-dress", &min_dress
, NULL
);
477 g_assert_cmpint(min_dress
, ==, valid_dress_1
);
479 g_object_set(dim_style
, "min-dress", valid_dress_2
, NULL
);
480 g_object_get(dim_style
, "min-dress", &min_dress
, NULL
);
481 g_assert_cmpint(min_dress
, ==, valid_dress_2
);
483 g_object_unref(dim_style
);
487 _adg_number_format(void)
489 AdgDimStyle
*dim_style
;
490 const gchar
*valid_text_1
, *valid_text_2
;
491 const gchar
*number_format
;
492 gchar
*number_format_dup
;
494 dim_style
= adg_dim_style_new();
495 valid_text_1
= "%lf";
496 valid_text_2
= "%abc%";
498 /* Using the public APIs */
499 adg_dim_style_set_number_format(dim_style
, valid_text_1
);
500 number_format
= adg_dim_style_get_number_format(dim_style
);
501 g_assert_cmpstr(number_format
, ==, valid_text_1
);
503 adg_dim_style_set_number_format(dim_style
, valid_text_2
);
504 number_format
= adg_dim_style_get_number_format(dim_style
);
505 g_assert_cmpstr(number_format
, ==, valid_text_2
);
507 adg_dim_style_set_number_format(dim_style
, NULL
);
508 number_format
= adg_dim_style_get_number_format(dim_style
);
509 g_assert(number_format
== NULL
);
511 /* Using GObject property methods */
512 g_object_set(dim_style
, "number-format", valid_text_1
, NULL
);
513 g_object_get(dim_style
, "number-format", &number_format_dup
, NULL
);
514 g_assert_cmpstr(number_format_dup
, ==, valid_text_1
);
515 g_free(number_format_dup
);
517 g_object_set(dim_style
, "number-format", valid_text_2
, NULL
);
518 g_object_get(dim_style
, "number-format", &number_format_dup
, NULL
);
519 g_assert_cmpstr(number_format_dup
, ==, valid_text_2
);
520 g_free(number_format_dup
);
522 g_object_set(dim_style
, "number-format", NULL
, NULL
);
523 g_object_get(dim_style
, "number-format", &number_format_dup
, NULL
);
524 g_assert(number_format_dup
== NULL
);
526 g_object_unref(dim_style
);
530 _adg_number_tag(void)
532 AdgDimStyle
*dim_style
;
533 const gchar
*valid_text_1
, *valid_text_2
;
534 const gchar
*number_tag
;
535 gchar
*number_tag_dup
;
537 dim_style
= adg_dim_style_new();
539 valid_text_2
= "<รจ>";
541 /* Using the public APIs */
542 adg_dim_style_set_number_tag(dim_style
, valid_text_1
);
543 number_tag
= adg_dim_style_get_number_tag(dim_style
);
544 g_assert_cmpstr(number_tag
, ==, valid_text_1
);
546 adg_dim_style_set_number_tag(dim_style
, valid_text_2
);
547 number_tag
= adg_dim_style_get_number_tag(dim_style
);
548 g_assert_cmpstr(number_tag
, ==, valid_text_2
);
550 adg_dim_style_set_number_tag(dim_style
, NULL
);
551 number_tag
= adg_dim_style_get_number_tag(dim_style
);
552 g_assert(number_tag
== NULL
);
554 /* Using GObject property methods */
555 g_object_set(dim_style
, "number-tag", valid_text_1
, NULL
);
556 g_object_get(dim_style
, "number-tag", &number_tag_dup
, NULL
);
557 g_assert_cmpstr(number_tag_dup
, ==, valid_text_1
);
558 g_free(number_tag_dup
);
560 g_object_set(dim_style
, "number-tag", valid_text_2
, NULL
);
561 g_object_get(dim_style
, "number-tag", &number_tag_dup
, NULL
);
562 g_assert_cmpstr(number_tag_dup
, ==, valid_text_2
);
563 g_free(number_tag_dup
);
565 g_object_set(dim_style
, "number-tag", NULL
, NULL
);
566 g_object_get(dim_style
, "number-tag", &number_tag_dup
, NULL
);
567 g_assert(number_tag_dup
== NULL
);
569 g_object_unref(dim_style
);
573 _adg_quote_shift(void)
575 AdgDimStyle
*dim_style
;
576 CpmlPair null_shift
, identity_shift
;
577 const CpmlPair
*shift
;
580 dim_style
= adg_dim_style_new();
583 identity_shift
.x
= 1;
584 identity_shift
.y
= 1;
586 /* Using the public APIs */
587 adg_dim_style_set_quote_shift(dim_style
, &identity_shift
);
588 shift
= adg_dim_style_get_quote_shift(dim_style
);
589 g_assert(cpml_pair_equal(shift
, &identity_shift
));
591 adg_dim_style_set_quote_shift(dim_style
, &null_shift
);
592 shift
= adg_dim_style_get_quote_shift(dim_style
);
593 g_assert(cpml_pair_equal(shift
, &null_shift
));
595 adg_dim_style_set_quote_shift(dim_style
, NULL
);
596 shift
= adg_dim_style_get_quote_shift(dim_style
);
597 g_assert(cpml_pair_equal(shift
, &null_shift
));
599 /* Using GObject property methods */
600 g_object_set(dim_style
, "quote-shift", &identity_shift
, NULL
);
601 g_object_get(dim_style
, "quote-shift", &shift_dup
, NULL
);
602 g_assert(cpml_pair_equal(shift_dup
, &identity_shift
));
605 g_object_set(dim_style
, "quote-shift", NULL
, NULL
);
606 g_object_get(dim_style
, "quote-shift", &shift_dup
, NULL
);
607 g_assert(cpml_pair_equal(shift_dup
, &identity_shift
));
610 g_object_set(dim_style
, "quote-shift", &null_shift
, NULL
);
611 g_object_get(dim_style
, "quote-shift", &shift_dup
, NULL
);
612 g_assert(cpml_pair_equal(shift_dup
, &null_shift
));
615 g_object_unref(dim_style
);
621 AdgDimStyle
*dim_style
;
622 gdouble valid_to_offset_1
, valid_to_offset_2
, invalid_to_offset
;
625 dim_style
= adg_dim_style_new();
626 valid_to_offset_1
= 0;
627 valid_to_offset_2
= 999;
628 invalid_to_offset
= -1;
630 /* Using the public APIs */
631 adg_dim_style_set_to_offset(dim_style
, valid_to_offset_1
);
632 to_offset
= adg_dim_style_get_to_offset(dim_style
);
633 g_assert_cmpfloat(to_offset
, ==, valid_to_offset_1
);
635 adg_dim_style_set_to_offset(dim_style
, invalid_to_offset
);
636 to_offset
= adg_dim_style_get_to_offset(dim_style
);
637 g_assert_cmpfloat(to_offset
, ==, valid_to_offset_1
);
639 adg_dim_style_set_to_offset(dim_style
, valid_to_offset_2
);
640 to_offset
= adg_dim_style_get_to_offset(dim_style
);
641 g_assert_cmpfloat(to_offset
, ==, valid_to_offset_2
);
643 /* Using GObject property methods */
644 g_object_set(dim_style
, "to-offset", valid_to_offset_1
, NULL
);
645 g_object_get(dim_style
, "to-offset", &to_offset
, NULL
);
646 g_assert_cmpfloat(to_offset
, ==, valid_to_offset_1
);
648 g_object_set(dim_style
, "to-offset", invalid_to_offset
, NULL
);
649 g_object_get(dim_style
, "to-offset", &to_offset
, NULL
);
650 g_assert_cmpfloat(to_offset
, ==, valid_to_offset_1
);
652 g_object_set(dim_style
, "to-offset", valid_to_offset_2
, NULL
);
653 g_object_get(dim_style
, "to-offset", &to_offset
, NULL
);
654 g_assert_cmpfloat(to_offset
, ==, valid_to_offset_2
);
656 g_object_unref(dim_style
);
660 _adg_value_dress(void)
662 AdgDimStyle
*dim_style
;
663 AdgDress valid_dress_1
, valid_dress_2
, incompatible_dress
;
664 AdgDress value_dress
;
666 dim_style
= adg_dim_style_new();
667 valid_dress_1
= ADG_DRESS_FONT
;
668 valid_dress_2
= ADG_DRESS_FONT_QUOTE_ANNOTATION
;
669 incompatible_dress
= ADG_DRESS_FILL_HATCH
;
671 /* Using the public APIs */
672 adg_dim_style_set_value_dress(dim_style
, valid_dress_1
);
673 value_dress
= adg_dim_style_get_value_dress(dim_style
);
674 g_assert_cmpint(value_dress
, ==, valid_dress_1
);
676 adg_dim_style_set_value_dress(dim_style
, incompatible_dress
);
677 value_dress
= adg_dim_style_get_value_dress(dim_style
);
678 g_assert_cmpint(value_dress
, ==, valid_dress_1
);
680 adg_dim_style_set_value_dress(dim_style
, valid_dress_2
);
681 value_dress
= adg_dim_style_get_value_dress(dim_style
);
682 g_assert_cmpint(value_dress
, ==, valid_dress_2
);
684 /* Using GObject property methods */
685 g_object_set(dim_style
, "value-dress", valid_dress_1
, NULL
);
686 g_object_get(dim_style
, "value-dress", &value_dress
, NULL
);
687 g_assert_cmpint(value_dress
, ==, valid_dress_1
);
689 g_object_set(dim_style
, "value-dress", incompatible_dress
, NULL
);
690 g_object_get(dim_style
, "value-dress", &value_dress
, NULL
);
691 g_assert_cmpint(value_dress
, ==, valid_dress_1
);
693 g_object_set(dim_style
, "value-dress", valid_dress_2
, NULL
);
694 g_object_get(dim_style
, "value-dress", &value_dress
, NULL
);
695 g_assert_cmpint(value_dress
, ==, valid_dress_2
);
697 g_object_unref(dim_style
);
702 main(int argc
, char *argv
[])
704 adg_test_init(&argc
, &argv
);
706 adg_test_add_func("/adg/dim-style/baseline-spacing", _adg_baseline_spacing
);
707 adg_test_add_func("/adg/dim-style/beyond", _adg_beyond
);
708 adg_test_add_func("/adg/dim-style/color-dress", _adg_color_dress
);
709 adg_test_add_func("/adg/dim-style/from-offset", _adg_from_offset
);
710 adg_test_add_func("/adg/dim-style/limits-shift", _adg_limits_shift
);
711 adg_test_add_func("/adg/dim-style/limits-spacing", _adg_limits_spacing
);
712 adg_test_add_func("/adg/dim-style/line-dress", _adg_line_dress
);
713 adg_test_add_func("/adg/dim-style/marker1", _adg_marker1
);
714 adg_test_add_func("/adg/dim-style/marker2", _adg_marker2
);
715 adg_test_add_func("/adg/dim-style/max-dress", _adg_max_dress
);
716 adg_test_add_func("/adg/dim-style/min-dress", _adg_min_dress
);
717 adg_test_add_func("/adg/dim-style/number-format", _adg_number_format
);
718 adg_test_add_func("/adg/dim-style/number-tag", _adg_number_tag
);
719 adg_test_add_func("/adg/dim-style/quote-shift", _adg_quote_shift
);
720 adg_test_add_func("/adg/dim-style/to-offset", _adg_to_offset
);
721 adg_test_add_func("/adg/dim-style/value-dress", _adg_value_dress
);