1 /* ADG - Automatic Drawing Generation
2 * Copyright (C) 2007-2017 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.
26 _adg_property_detached(void)
29 AdgThreeState valid_three_state_1
, valid_three_state_2
, invalid_three_state
;
30 AdgThreeState detached
;
32 dim
= ADG_DIM(adg_ldim_new());
33 valid_three_state_1
= ADG_THREE_STATE_UNKNOWN
;
34 valid_three_state_2
= ADG_THREE_STATE_OFF
;
35 invalid_three_state
= 1234;
37 /* Using the public APIs */
38 adg_dim_set_detached(dim
, valid_three_state_1
);
39 detached
= adg_dim_get_detached(dim
);
40 g_assert_cmpint(detached
, ==, valid_three_state_1
);
42 adg_dim_set_detached(dim
, invalid_three_state
);
43 detached
= adg_dim_get_detached(dim
);
44 g_assert_cmpint(detached
, ==, valid_three_state_1
);
46 adg_dim_set_detached(dim
, valid_three_state_2
);
47 detached
= adg_dim_get_detached(dim
);
48 g_assert_cmpint(detached
, ==, valid_three_state_2
);
50 /* Using GObject property methods */
51 g_object_set(dim
, "detached", valid_three_state_1
, NULL
);
52 g_object_get(dim
, "detached", &detached
, NULL
);
53 g_assert_cmpint(detached
, ==, valid_three_state_1
);
55 g_object_set(dim
, "detached", invalid_three_state
, NULL
);
56 g_object_get(dim
, "detached", &detached
, NULL
);
57 g_assert_cmpint(detached
, ==, valid_three_state_1
);
59 g_object_set(dim
, "detached", valid_three_state_2
, NULL
);
60 g_object_get(dim
, "detached", &detached
, NULL
);
61 g_assert_cmpint(detached
, ==, valid_three_state_2
);
63 adg_entity_destroy(ADG_ENTITY(dim
));
67 _adg_property_dim_dress(void)
70 AdgDress valid_dress
, incompatible_dress
;
73 dim
= ADG_DIM(adg_ldim_new());
74 valid_dress
= ADG_DRESS_DIMENSION
;
75 incompatible_dress
= ADG_DRESS_LINE
;
77 /* Using the public APIs */
78 adg_dim_set_dim_dress(dim
, valid_dress
);
79 dim_dress
= adg_dim_get_dim_dress(dim
);
80 g_assert_cmpint(dim_dress
, ==, valid_dress
);
82 adg_dim_set_dim_dress(dim
, incompatible_dress
);
83 dim_dress
= adg_dim_get_dim_dress(dim
);
84 g_assert_cmpint(dim_dress
, ==, valid_dress
);
86 /* Using GObject property methods */
87 g_object_set(dim
, "dim-dress", valid_dress
, NULL
);
88 g_object_get(dim
, "dim-dress", &dim_dress
, NULL
);
89 g_assert_cmpint(dim_dress
, ==, valid_dress
);
91 g_object_set(dim
, "dim-dress", incompatible_dress
, NULL
);
92 g_object_get(dim
, "dim-dress", &dim_dress
, NULL
);
93 g_assert_cmpint(dim_dress
, ==, valid_dress
);
95 adg_entity_destroy(ADG_ENTITY(dim
));
99 _adg_property_level(void)
102 gdouble valid_value_1
, valid_value_2
;
105 dim
= ADG_DIM(adg_ldim_new());
106 valid_value_1
= 4321;
107 valid_value_2
= 1234;
109 /* Using the public APIs */
110 adg_dim_set_level(dim
, valid_value_1
);
111 level
= adg_dim_get_level(dim
);
112 adg_assert_isapprox(level
, valid_value_1
);
114 adg_dim_set_level(dim
, valid_value_2
);
115 level
= adg_dim_get_level(dim
);
116 adg_assert_isapprox(level
, valid_value_2
);
118 /* Using GObject property methods */
119 g_object_set(dim
, "level", valid_value_1
, NULL
);
120 g_object_get(dim
, "level", &level
, NULL
);
121 adg_assert_isapprox(level
, valid_value_1
);
123 g_object_set(dim
, "level", valid_value_2
, NULL
);
124 g_object_get(dim
, "level", &level
, NULL
);
125 adg_assert_isapprox(level
, valid_value_2
);
127 adg_entity_destroy(ADG_ENTITY(dim
));
131 _adg_property_max(void)
134 const gchar
*valid_text
, *latin1_text
;
138 dim
= ADG_DIM(adg_ldim_new());
139 valid_text
= "This is some text...";
140 latin1_text
= "This is some àèìòù Latin1 text...";
142 /* Using the public APIs */
143 adg_dim_set_max(dim
, valid_text
);
144 max
= adg_dim_get_max(dim
);
145 g_assert_cmpstr(max
, ==, valid_text
);
147 adg_dim_set_max(dim
, latin1_text
);
148 max
= adg_dim_get_max(dim
);
149 g_assert_cmpstr(max
, ==, latin1_text
);
151 adg_dim_set_max(dim
, NULL
);
152 max
= adg_dim_get_max(dim
);
155 /* Using GObject property methods */
156 g_object_set(dim
, "max", valid_text
, NULL
);
157 g_object_get(dim
, "max", &max_dup
, NULL
);
158 g_assert_cmpstr(max_dup
, ==, valid_text
);
161 g_object_set(dim
, "max", latin1_text
, NULL
);
162 g_object_get(dim
, "max", &max_dup
, NULL
);
163 g_assert_cmpstr(max_dup
, ==, latin1_text
);
166 g_object_set(dim
, "max", NULL
, NULL
);
167 g_object_get(dim
, "max", &max_dup
, NULL
);
168 g_assert_null(max_dup
);
170 adg_entity_destroy(ADG_ENTITY(dim
));
174 _adg_property_min(void)
177 const gchar
*valid_text
, *latin1_text
;
181 dim
= ADG_DIM(adg_ldim_new());
182 valid_text
= "This is some text...";
183 latin1_text
= "This is some àèìòù Latin1 text...";
185 /* Using the public APIs */
186 adg_dim_set_min(dim
, valid_text
);
187 min
= adg_dim_get_min(dim
);
188 g_assert_cmpstr(min
, ==, valid_text
);
190 adg_dim_set_min(dim
, latin1_text
);
191 min
= adg_dim_get_min(dim
);
192 g_assert_cmpstr(min
, ==, latin1_text
);
194 adg_dim_set_min(dim
, NULL
);
195 min
= adg_dim_get_min(dim
);
198 /* Using GObject property methods */
199 g_object_set(dim
, "min", valid_text
, NULL
);
200 g_object_get(dim
, "min", &min_dup
, NULL
);
201 g_assert_cmpstr(min_dup
, ==, valid_text
);
204 g_object_set(dim
, "min", latin1_text
, NULL
);
205 g_object_get(dim
, "min", &min_dup
, NULL
);
206 g_assert_cmpstr(min_dup
, ==, latin1_text
);
209 g_object_set(dim
, "min", NULL
, NULL
);
210 g_object_get(dim
, "min", &min_dup
, NULL
);
211 g_assert_null(min_dup
);
213 adg_entity_destroy(ADG_ENTITY(dim
));
217 _adg_property_outside(void)
220 AdgThreeState valid_three_state_1
, valid_three_state_2
, invalid_three_state
;
221 AdgThreeState outside
;
223 dim
= ADG_DIM(adg_rdim_new());
224 valid_three_state_1
= ADG_THREE_STATE_UNKNOWN
;
225 valid_three_state_2
= ADG_THREE_STATE_OFF
;
226 invalid_three_state
= 1234;
228 /* Using the public APIs */
229 adg_dim_set_outside(dim
, valid_three_state_1
);
230 outside
= adg_dim_get_outside(dim
);
231 g_assert_cmpint(outside
, ==, valid_three_state_1
);
233 adg_dim_set_outside(dim
, invalid_three_state
);
234 outside
= adg_dim_get_outside(dim
);
235 g_assert_cmpint(outside
, ==, valid_three_state_1
);
237 adg_dim_set_outside(dim
, valid_three_state_2
);
238 outside
= adg_dim_get_outside(dim
);
239 g_assert_cmpint(outside
, ==, valid_three_state_2
);
241 /* Using GObject property methods */
242 g_object_set(dim
, "outside", valid_three_state_1
, NULL
);
243 g_object_get(dim
, "outside", &outside
, NULL
);
244 g_assert_cmpint(outside
, ==, valid_three_state_1
);
246 g_object_set(dim
, "outside", invalid_three_state
, NULL
);
247 g_object_get(dim
, "outside", &outside
, NULL
);
248 g_assert_cmpint(outside
, ==, valid_three_state_1
);
250 g_object_set(dim
, "outside", valid_three_state_2
, NULL
);
251 g_object_get(dim
, "outside", &outside
, NULL
);
252 g_assert_cmpint(outside
, ==, valid_three_state_2
);
254 adg_entity_destroy(ADG_ENTITY(dim
));
258 _adg_property_pos(void)
262 AdgPoint
*origin
, *explicit_point
, *model_point
;
265 dim
= ADG_DIM(adg_rdim_new());
266 model
= ADG_MODEL(adg_path_new());
267 origin
= adg_point_new();
268 explicit_point
= adg_point_new();
269 model_point
= adg_point_new();
271 adg_point_set_pair_explicit(origin
, 0, 0);
272 adg_point_set_pair_explicit(explicit_point
, 123, 321);
273 adg_model_set_named_pair(model
, "named-pair", (CpmlPair
*) explicit_point
);
274 adg_point_set_pair_from_model(model_point
, model
, "named-pair");
276 /* Ensure ADG does not consider an explicit point equals to
277 * a point bound to a named pair with the same coordinates */
278 g_assert_false(adg_point_equal(explicit_point
, model_point
));
280 pos
= adg_dim_get_pos(dim
);
283 /* Using the public APIs */
284 adg_dim_set_pos_explicit(dim
, 0, 0);
285 pos
= adg_dim_get_pos(dim
);
286 g_assert_true(adg_point_equal(pos
, origin
));
288 adg_dim_set_pos(dim
, NULL
);
289 pos
= adg_dim_get_pos(dim
);
292 adg_dim_set_pos(dim
, explicit_point
);
293 pos
= adg_dim_get_pos(dim
);
294 g_assert_true(adg_point_equal(pos
, explicit_point
));
296 adg_dim_set_pos_from_model(dim
, model
, "dummy");
297 pos
= adg_dim_get_pos(dim
);
298 g_assert_nonnull(pos
);
300 adg_dim_set_pos_from_model(dim
, model
, "named-pair");
301 pos
= adg_dim_get_pos(dim
);
302 g_assert_true(adg_point_equal(pos
, model_point
));
304 /* Using GObject property methods */
305 g_object_set(dim
, "pos", origin
, NULL
);
306 g_object_get(dim
, "pos", &pos
, NULL
);
307 g_assert_true(adg_point_equal(pos
, origin
));
308 adg_point_destroy(pos
);
310 g_object_set(dim
, "pos", NULL
, NULL
);
311 g_object_get(dim
, "pos", &pos
, NULL
);
314 g_object_set(dim
, "pos", explicit_point
, NULL
);
315 g_object_get(dim
, "pos", &pos
, NULL
);
316 g_assert_true(adg_point_equal(pos
, explicit_point
));
317 adg_point_destroy(pos
);
319 adg_dim_set_pos_from_model(dim
, model
, "dummy");
320 g_object_get(dim
, "pos", &pos
, NULL
);
321 g_assert_nonnull(pos
);
322 adg_point_destroy(pos
);
324 g_object_set(dim
, "pos", model_point
, NULL
);
325 g_object_get(dim
, "pos", &pos
, NULL
);
326 g_assert_true(adg_point_equal(pos
, model_point
));
327 adg_point_destroy(pos
);
329 adg_point_destroy(origin
);
330 adg_point_destroy(explicit_point
);
331 adg_point_destroy(model_point
);
332 adg_entity_destroy(ADG_ENTITY(dim
));
333 g_object_unref(model
);
337 _adg_property_ref1(void)
341 AdgPoint
*origin
, *explicit_point
, *model_point
;
344 dim
= ADG_DIM(adg_rdim_new());
345 model
= ADG_MODEL(adg_path_new());
346 origin
= adg_point_new();
347 explicit_point
= adg_point_new();
348 model_point
= adg_point_new();
350 adg_point_set_pair_explicit(origin
, 0, 0);
351 adg_point_set_pair_explicit(explicit_point
, 123, 321);
352 adg_model_set_named_pair(model
, "named-pair", (CpmlPair
*) explicit_point
);
353 adg_point_set_pair_from_model(model_point
, model
, "named-pair");
355 /* Ensure ADG does not consider an explicit point equals to
356 * a point bound to a named pair with the same coordinates */
357 g_assert_false(adg_point_equal(explicit_point
, model_point
));
359 ref1
= adg_dim_get_ref1(dim
);
362 /* Using the public APIs */
363 adg_dim_set_ref1_explicit(dim
, 0, 0);
364 ref1
= adg_dim_get_ref1(dim
);
365 g_assert_true(adg_point_equal(ref1
, origin
));
367 adg_dim_set_ref1(dim
, NULL
);
368 ref1
= adg_dim_get_ref1(dim
);
371 adg_dim_set_ref1(dim
, explicit_point
);
372 ref1
= adg_dim_get_ref1(dim
);
373 g_assert_true(adg_point_equal(ref1
, explicit_point
));
375 adg_dim_set_ref1_from_model(dim
, model
, "dummy");
376 ref1
= adg_dim_get_ref1(dim
);
377 g_assert_nonnull(ref1
);
379 adg_dim_set_ref1_from_model(dim
, model
, "named-pair");
380 ref1
= adg_dim_get_ref1(dim
);
381 g_assert_true(adg_point_equal(ref1
, model_point
));
383 /* Using GObject property methods */
384 g_object_set(dim
, "ref1", origin
, NULL
);
385 g_object_get(dim
, "ref1", &ref1
, NULL
);
386 g_assert_true(adg_point_equal(ref1
, origin
));
387 adg_point_destroy(ref1
);
389 g_object_set(dim
, "ref1", NULL
, NULL
);
390 g_object_get(dim
, "ref1", &ref1
, NULL
);
393 g_object_set(dim
, "ref1", explicit_point
, NULL
);
394 g_object_get(dim
, "ref1", &ref1
, NULL
);
395 g_assert_true(adg_point_equal(ref1
, explicit_point
));
396 adg_point_destroy(ref1
);
398 adg_dim_set_ref1_from_model(dim
, model
, "dummy");
399 g_object_get(dim
, "ref1", &ref1
, NULL
);
400 g_assert_nonnull(ref1
);
401 adg_point_destroy(ref1
);
403 g_object_set(dim
, "ref1", model_point
, NULL
);
404 g_object_get(dim
, "ref1", &ref1
, NULL
);
405 g_assert_true(adg_point_equal(ref1
, model_point
));
406 adg_point_destroy(ref1
);
408 adg_point_destroy(origin
);
409 adg_point_destroy(explicit_point
);
410 adg_point_destroy(model_point
);
411 adg_entity_destroy(ADG_ENTITY(dim
));
412 g_object_unref(model
);
416 _adg_property_ref2(void)
420 AdgPoint
*origin
, *explicit_point
, *model_point
;
423 dim
= ADG_DIM(adg_rdim_new());
424 model
= ADG_MODEL(adg_path_new());
425 origin
= adg_point_new();
426 explicit_point
= adg_point_new();
427 model_point
= adg_point_new();
429 adg_point_set_pair_explicit(origin
, 0, 0);
430 adg_point_set_pair_explicit(explicit_point
, 123, 321);
431 adg_model_set_named_pair(model
, "named-pair", (CpmlPair
*) explicit_point
);
432 adg_point_set_pair_from_model(model_point
, model
, "named-pair");
434 /* Ensure ADG does not consider an explicit point equals to
435 * a point bound to a named pair with the same coordinates */
436 g_assert_false(adg_point_equal(explicit_point
, model_point
));
438 ref2
= adg_dim_get_ref2(dim
);
441 /* Using the public APIs */
442 adg_dim_set_ref2_explicit(dim
, 0, 0);
443 ref2
= adg_dim_get_ref2(dim
);
444 g_assert_true(adg_point_equal(ref2
, origin
));
446 adg_dim_set_ref2(dim
, NULL
);
447 ref2
= adg_dim_get_ref2(dim
);
450 adg_dim_set_ref2(dim
, explicit_point
);
451 ref2
= adg_dim_get_ref2(dim
);
452 g_assert_true(adg_point_equal(ref2
, explicit_point
));
454 adg_dim_set_ref2_from_model(dim
, model
, "dummy");
455 ref2
= adg_dim_get_ref2(dim
);
456 g_assert_nonnull(ref2
);
458 adg_dim_set_ref2_from_model(dim
, model
, "named-pair");
459 ref2
= adg_dim_get_ref2(dim
);
460 g_assert_true(adg_point_equal(ref2
, model_point
));
462 /* Using GObject property methods */
463 g_object_set(dim
, "ref2", origin
, NULL
);
464 g_object_get(dim
, "ref2", &ref2
, NULL
);
465 g_assert_true(adg_point_equal(ref2
, origin
));
466 adg_point_destroy(ref2
);
468 g_object_set(dim
, "ref2", NULL
, NULL
);
469 g_object_get(dim
, "ref2", &ref2
, NULL
);
472 g_object_set(dim
, "ref2", explicit_point
, NULL
);
473 g_object_get(dim
, "ref2", &ref2
, NULL
);
474 g_assert_true(adg_point_equal(ref2
, explicit_point
));
475 adg_point_destroy(ref2
);
477 adg_dim_set_ref2_from_model(dim
, model
, "dummy");
478 g_object_get(dim
, "ref2", &ref2
, NULL
);
479 g_assert_nonnull(ref2
);
480 adg_point_destroy(ref2
);
482 g_object_set(dim
, "ref2", model_point
, NULL
);
483 g_object_get(dim
, "ref2", &ref2
, NULL
);
484 g_assert_true(adg_point_equal(ref2
, model_point
));
485 adg_point_destroy(ref2
);
487 adg_point_destroy(origin
);
488 adg_point_destroy(explicit_point
);
489 adg_point_destroy(model_point
);
490 adg_entity_destroy(ADG_ENTITY(dim
));
491 g_object_unref(model
);
495 _adg_property_value(void)
498 const gchar
*valid_text
, *latin1_text
;
502 dim
= ADG_DIM(adg_ldim_new());
503 valid_text
= "This is some text...";
504 latin1_text
= "This is some àèìòù Latin1 text...";
506 /* Using the public APIs */
507 adg_dim_set_value(dim
, valid_text
);
508 value
= adg_dim_get_value(dim
);
509 g_assert_cmpstr(value
, ==, valid_text
);
511 adg_dim_set_value(dim
, latin1_text
);
512 value
= adg_dim_get_value(dim
);
513 g_assert_cmpstr(value
, ==, latin1_text
);
515 adg_dim_set_value(dim
, NULL
);
516 value
= adg_dim_get_value(dim
);
517 g_assert_null(value
);
519 /* Using GObject property methods */
520 g_object_set(dim
, "value", valid_text
, NULL
);
521 g_object_get(dim
, "value", &value_dup
, NULL
);
522 g_assert_cmpstr(value_dup
, ==, valid_text
);
525 g_object_set(dim
, "value", latin1_text
, NULL
);
526 g_object_get(dim
, "value", &value_dup
, NULL
);
527 g_assert_cmpstr(value_dup
, ==, latin1_text
);
530 g_object_set(dim
, "value", NULL
, NULL
);
531 g_object_get(dim
, "value", &value_dup
, NULL
);
532 g_assert_null(value_dup
);
534 adg_entity_destroy(ADG_ENTITY(dim
));
538 _adg_method_get_text(void)
541 AdgDimStyle
*dim_style
;
544 dim
= ADG_DIM(adg_ldim_new());
545 dim_style
= ADG_DIM_STYLE(adg_entity_style(ADG_ENTITY(dim
), ADG_DRESS_DIMENSION
));
547 /* Checking predefined dresses */
549 /* Default dress: ADG_DRESS_DIMENSION */
550 text
= adg_dim_get_text(dim
, 7.891);
551 g_assert_cmpstr(text
, ==, "7.89");
554 adg_dim_set_dim_dress(dim
, ADG_DRESS_DIMENSION_ANGULAR
);
555 text
= adg_dim_get_text(dim
, 7.891);
556 g_assert_cmpstr(text
, ==, "7°53'");
559 adg_dim_set_dim_dress(dim
, ADG_DRESS_DIMENSION_RADIUS
);
560 text
= adg_dim_get_text(dim
, 7.891);
561 g_assert_cmpstr(text
, ==, "R7.89");
564 adg_dim_set_dim_dress(dim
, ADG_DRESS_DIMENSION_DIAMETER
);
565 text
= adg_dim_get_text(dim
, 7.891);
566 g_assert_cmpstr(text
, ==, ADG_UTF8_DIAMETER
"7.89");
569 /* Restore the default dress */
570 adg_dim_set_dim_dress(dim
, ADG_DRESS_DIMENSION
);
571 text
= adg_dim_get_text(dim
, 3.456);
572 g_assert_cmpstr(text
, ==, "3.46");
575 /* Decrease the decimals */
576 adg_dim_style_set_decimals(dim_style
, 1);
577 text
= adg_dim_get_text(dim
, 7.891);
578 g_assert_cmpstr(text
, ==, "7.9");
581 /* Change the argument type */
582 adg_dim_style_set_number_arguments(dim_style
, "a");
583 text
= adg_dim_get_text(dim
, 7.891);
584 g_assert_cmpstr(text
, ==, "7.891");
587 adg_dim_style_set_number_arguments(dim_style
, "D");
588 text
= adg_dim_get_text(dim
, 7.891);
589 g_assert_cmpstr(text
, ==, "7");
592 adg_dim_style_set_number_arguments(dim_style
, "d");
593 text
= adg_dim_get_text(dim
, 7.891);
594 g_assert_cmpstr(text
, ==, "7.9");
597 /* Change the number format */
598 adg_dim_style_set_number_format(dim_style
, "%.3f");
599 text
= adg_dim_get_text(dim
, 7.891);
600 g_assert_cmpstr(text
, ==, "7.900");
603 /* Trying a complex formatting with multiple fields */
604 adg_dim_style_set_decimals(dim_style
, 2);
605 adg_dim_style_set_number_arguments(dim_style
, "aieDMSdms");
606 adg_dim_style_set_number_format(dim_style
, "%%Raw: \\(%g, %g, %g\\); Truncated: \\(%g, %g, %g\\); Rounded: \\(%g, %g, %g\\)");
607 text
= adg_dim_get_text(dim
, 7.891);
608 g_assert_cmpstr(text
, ==, "%Raw: (7.891, 53.46, 27.6); Truncated: (7, 53, 27); Rounded: (7.89, 53.46, 27.6)");
611 text
= adg_dim_get_text(dim
, 5.432);
612 g_assert_cmpstr(text
, ==, "%Raw: (5.432, 25.92, 55.2); Truncated: (5, 25, 55); Rounded: (5.43, 25.92, 55.2)");
615 /* Testing simple disappearing of unvalorized values */
616 adg_dim_style_set_number_arguments(dim_style
, "a");
617 adg_dim_style_set_number_format(dim_style
, "(%g)");
619 text
= adg_dim_get_text(dim
, 123);
620 g_assert_cmpstr(text
, ==, "123");
623 text
= adg_dim_get_text(dim
, 0);
624 g_assert_cmpstr(text
, ==, "");
627 adg_dim_style_set_number_arguments(dim_style
, "aD");
628 adg_dim_style_set_number_format(dim_style
, ">(%g)--(%g)<");
630 text
= adg_dim_get_text(dim
, 0);
631 g_assert_cmpstr(text
, ==, ">--<");
634 text
= adg_dim_get_text(dim
, 0.42);
635 g_assert_cmpstr(text
, ==, ">0.42--<");
638 text
= adg_dim_get_text(dim
, 2.34);
639 g_assert_cmpstr(text
, ==, ">2.34--2<");
642 /* Testing nested parenthesis */
643 adg_dim_style_set_number_arguments(dim_style
, "DMs");
644 adg_dim_style_set_number_format(dim_style
, "%g°(%g'(%g\"))");
646 text
= adg_dim_get_text(dim
, 0);
647 g_assert_cmpstr(text
, ==, "0°");
650 text
= adg_dim_get_text(dim
, 1.5);
651 g_assert_cmpstr(text
, ==, "1°30'");
654 text
= adg_dim_get_text(dim
, 2.002777);
655 g_assert_cmpstr(text
, ==, "2°0'10\"");
658 /* Test errors on unmatched parenthesis */
659 adg_dim_style_set_number_format(dim_style
, "%g°(%g'(%g\")");
660 g_assert_null(adg_dim_get_text(dim
, 0));
662 adg_dim_style_set_number_format(dim_style
, "%g°%g'(%g\"))");
663 g_assert_null(adg_dim_get_text(dim
, 0));
665 adg_entity_destroy(ADG_ENTITY(dim
));
669 _adg_method_set_limits(void)
673 dim
= ADG_DIM(adg_ldim_new());
676 adg_dim_set_limits(NULL
, "", "");
677 adg_dim_set_limits(dim
, NULL
, "");
678 adg_dim_set_limits(dim
, "", NULL
);
680 adg_dim_set_limits(dim
, "min", "max");
681 g_assert_cmpstr(adg_dim_get_min(dim
), ==, "min");
682 g_assert_cmpstr(adg_dim_get_max(dim
), ==, "max");
684 adg_entity_destroy(ADG_ENTITY(dim
));
689 main(int argc
, char *argv
[])
691 adg_test_init(&argc
, &argv
);
693 adg_test_add_object_checks("/adg/dim/type/object", ADG_TYPE_DIM
);
694 adg_test_add_entity_checks("/adg/dim/type/entity", ADG_TYPE_DIM
);
696 g_test_add_func("/adg/dim/property/detached", _adg_property_detached
);
697 g_test_add_func("/adg/dim/property/dim-dress", _adg_property_dim_dress
);
698 g_test_add_func("/adg/dim/property/level", _adg_property_level
);
699 g_test_add_func("/adg/dim/property/max", _adg_property_max
);
700 g_test_add_func("/adg/dim/property/min", _adg_property_min
);
701 g_test_add_func("/adg/dim/property/outside", _adg_property_outside
);
702 g_test_add_func("/adg/dim/property/pos", _adg_property_pos
);
703 g_test_add_func("/adg/dim/property/ref1", _adg_property_ref1
);
704 g_test_add_func("/adg/dim/property/ref2", _adg_property_ref2
);
705 g_test_add_func("/adg/dim/property/value", _adg_property_value
);
707 g_test_add_func("/adg/dim/method/get_text", _adg_method_get_text
);
708 g_test_add_func("/adg/dim/method/set_limits", _adg_method_set_limits
);