Rename GP_Context -> GP_Pixmap
[gfxprim.git] / tests / gfx / APICoverage.gen.c.t
blob09a8ccf4fc7edfc838fc45f722867d73591daa0f
1 @ include source.t
2 /*
3  * The purpose of this test is to exercise as much codepaths as possible
4  * without checking for result corectness.
5  *
6  * Copyright (C) 2009-2014 Cyril Hrubis <metan@ucw.cz>
7  */
9 #include <stdio.h>
11 #include <core/GP_Pixmap.h>
12 #include <gfx/GP_Gfx.h>
14 #include "tst_test.h"
16 @ API_List = [
17 @    ['Fill', 'GP_Pixmap:in', 'int:pixel'],
19 @    ['HLine', 'GP_Pixmap:in', 'int:x0', 'int:x1', 'int:y', 'int:pixel'],
20 @    ['VLine', 'GP_Pixmap:in', 'int:x', 'int:y0', 'int:y1', 'int:pixel'],
22 @    ['Line', 'GP_Pixmap:in', 'int:x0', 'int:y0',
23 @     'int:x1', 'int:y1', 'int:pixel'],
25 @    ['Circle', 'GP_Pixmap:in', 'int:xcenter', 'int:ycenter',
26 @     'int:r', 'int:pixel'],
27 @    ['FillCircle', 'GP_Pixmap:in', 'int:xcenter', 'int:ycenter',
28 @     'int:r', 'int:pixel'],
30 @    ['Ellipse', 'GP_Pixmap:in', 'int:xcenter', 'int:ycenter',
31 @     'int:a', 'int:b', 'int:pixel'],
32 @    ['FillEllipse', 'GP_Pixmap:in', 'int:xcenter', 'int:ycenter',
33 @     'int:a', 'int:b', 'int:pixel'],
35 @    ['Ring', 'GP_Pixmap:in', 'int:xc', 'int:yc',
36 @     'int:r1', 'int:r2', 'int:pixel'],
37 @    ['FillRing', 'GP_Pixmap:in', 'int:xc', 'int:yc',
38 @     'int:r1', 'int:r2', 'int:pixel'],
40 @    ['Rect', 'GP_Pixmap:in', 'int:x0', 'int:y0',
41 @     'int:x1', 'int:y1', 'int:pixel'],
42 @    ['FillRect', 'GP_Pixmap:in', 'int:x0', 'int:y0',
43 @     'int:x1', 'int:y1', 'int:pixel'],
45 @    ['Triangle', 'GP_Pixmap:in', 'int:x0', 'int:y0',
46 @     'int:x1', 'int:y1', 'int:x2', 'int:y2', 'int:pixel'],
47 @    ['FillTriangle', 'GP_Pixmap:in', 'int:x0', 'int:y0',
48 @     'int:x1', 'int:y1', 'int:x2', 'int:y2', 'int:pixel'],
50 @    ['Tetragon', 'GP_Pixmap:in', 'int:x0', 'int:y0', 'int:x1', 'int:y1',
51 @     'int:x2', 'int:y2', 'int:x3', 'int:y3', 'int:pixel'],
52 @    ['FillTetragon', 'GP_Pixmap:in', 'int:x0', 'int:y0', 'int:x1', 'int:y1',
53 @     'int:x2', 'int:y2', 'int:x3', 'int:y3', 'int:pixel'],
54 @ ]
56 @ def prep_pixmap(id, pt):
57 GP_Pixmap *{{ id }} = GP_PixmapAlloc(331, 331, GP_PIXEL_{{ pt.name }});
58 @ end
60 @ def prep_int(id):
61 int {{ id }} = 2;
62 @ end
64 @ def prep_param(param, pt):
65 @     if (param.split(':', 1)[0] == 'GP_Pixmap'):
66 {@ prep_pixmap(param.split(':', 1)[1], pt) @}
67 @     if (param.split(':', 1)[0] == 'float'):
68 {@ prep_float(param.split(':', 1)[1]) @}
69 @     if (param.split(':', 1)[0] == 'int'):
70 {@ prep_int(param.split(':', 1)[1]) @}
71 @ end
73 @ def get_param(param):
74 @    if len(param.split(':', 1)) == 1:
75 @         return 'NULL'
76 @    else:
77 @         return param.split(':', 1)[1]
78 @ end
80 @ for fn in API_List:
81 @     for pt in pixeltypes:
82 @         if not pt.is_unknown():
83 static int Gfx_{{ fn[0]}}_{{ pt.name }}(void)
85 @             for param in fn[1:]:
86         {@ prep_param(param, pt) @}
87 @             end
89         GP_{{ fn[0] }}({{ ', '.join(map(get_param, fn[1:])) }});
91         return TST_SUCCESS;
94 @ end
96 const struct tst_suite tst_suite = {
97         .suite_name = "Gfx API Coverage",
98         .tests = {
99 @ for fn in API_List:
100 @     for pt in pixeltypes:
101 @         if not pt.is_unknown():
102                 {.name = "{{ fn[0] }} {{ pt.name }}",
103                  .tst_fn = Gfx_{{ fn[0] }}_{{ pt.name }}},
104 @ end
105                 {.name = NULL}
106         }