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 static cairo_path_data_t arc_data
[] = {
27 { .header
= { CPML_MOVE
, 2 }},
30 { .header
= { CPML_ARC
, 3 }},
43 _cpml_sanity_info(gint i
)
47 cpml_arc_info(NULL
, NULL
, NULL
, NULL
, NULL
);
50 g_test_trap_assert_failed();
56 _cpml_sanity_to_cairo(gint i
)
60 cr
= adg_test_cairo_context();
64 cpml_arc_to_cairo(NULL
, cr
);
67 cpml_arc_to_cairo(&arc
, NULL
);
70 g_test_trap_assert_failed();
78 _cpml_sanity_to_curves(int i
)
84 cpml_arc_to_curves(NULL
, &segment
, 1);
87 cpml_arc_to_curves(&arc
, NULL
, 1);
90 cpml_arc_to_curves(&arc
, &segment
, 0);
93 g_test_trap_assert_failed();
99 _cpml_method_info(void)
102 double r
, start
, end
;
104 /* Passing NULL to the output arguments is valid */
105 g_assert_true(cpml_arc_info(&arc
, NULL
, NULL
, NULL
, NULL
));
107 g_assert_true(cpml_arc_info(&arc
, ¢er
, &r
, &start
, &end
));
109 adg_assert_isapprox(center
.x
, 0);
110 adg_assert_isapprox(center
.y
, 0);
111 adg_assert_isapprox(r
, 3);
112 adg_assert_isapprox(start
, M_PI_2
);
113 adg_assert_isapprox(end
, -M_PI_2
);
119 main(int argc
, char *argv
[])
121 adg_test_init(&argc
, &argv
);
123 adg_test_add_traps("/cpml/arc/sanity/info", _cpml_sanity_info
, 1);
124 adg_test_add_traps("/cpml/arc/sanity/to-cairo", _cpml_sanity_to_cairo
, 2);
125 adg_test_add_traps("/cpml/arc/sanity/to-curves", _cpml_sanity_to_curves
, 3);
127 g_test_add_func("/cpml/arc/method/info", _cpml_method_info
);