作図ソフト dia の改良版
Revision | 7932160c3ef0ca14f3c77587e06f007540b67cb6 (tree) |
---|---|
Zeit | 2014-09-27 02:29:04 |
Autor | Hans Breuer <hans@breu...> |
Commiter | Hans Breuer |
[unit test] add more bounding box tests
which helped debugging the recent fix
@@ -78,6 +78,37 @@ static BezPoint _bz7[5] = { | ||
78 | 78 | { BEZ_CURVE_TO, {0,0}, {2,0}, {1,1} }, |
79 | 79 | { BEZ_CURVE_TO, {0,2}, {2,2}, {1,1} }, |
80 | 80 | }; |
81 | +static BezPoint _bz8[] = { /* ying: wrong bbox {-0.05,-0.05,3.05,5.0} */ | |
82 | + { BEZ_MOVE_TO, {2,0} }, | |
83 | + { BEZ_CURVE_TO, {1.2855,0}, {0.6252,0.3812}, {0.2679,1} }, | |
84 | + { BEZ_CURVE_TO, {-0.0893,1.6188}, {-0.0893,2.3812}, {0.2679,3} }, | |
85 | + { BEZ_CURVE_TO, {0.6252,3.6188}, {1.2855,4}, {2,4} }, | |
86 | + { BEZ_CURVE_TO, {1.6427,4}, {1.3126,3.8094}, {1.134,3.5} }, | |
87 | + { BEZ_CURVE_TO, {0.9553,3.1906}, {0.9553,2.8094}, {1.134,2.5} }, | |
88 | + { BEZ_CURVE_TO, {1.3126,2.1906}, {1.6427,2}, {2,2} }, | |
89 | + { BEZ_CURVE_TO, {2.3573,2}, {2.6874,1.8094}, {2.866,1.5} }, | |
90 | + { BEZ_CURVE_TO, {3.0447,1.1906}, {3.0447,0.8094}, {2.866,0.5} }, | |
91 | + { BEZ_CURVE_TO, {2.6874,0.1906}, {2.3573,0}, {2,0} }, | |
92 | + { BEZ_MOVE_TO, {2,2.6} }, | |
93 | + { BEZ_CURVE_TO, {2.22,2.6}, {2.4,2.78}, {2.4,3} }, | |
94 | + { BEZ_CURVE_TO, {2.4,3.22}, {2.22,3.4}, {2,3.4} }, | |
95 | + { BEZ_CURVE_TO, {1.78,3.4}, {1.6,3.22}, {1.6,3} }, | |
96 | + { BEZ_CURVE_TO, {1.6,2.78}, {1.78,2.6}, {2,2.6} }, | |
97 | + { BEZ_MOVE_TO, {2,0.6} }, | |
98 | + { BEZ_CURVE_TO, {2.22,0.6}, {2.4,0.78}, {2.4,1} }, | |
99 | + { BEZ_CURVE_TO, {2.4,1.22}, {2.22,1.4}, {2,1.4} }, | |
100 | + { BEZ_CURVE_TO, {1.78,1.4}, {1.6,1.22}, {1.6,1} }, | |
101 | + { BEZ_CURVE_TO, {1.6,0.78}, {1.78,0.6}, {2,0.6} } | |
102 | +}; | |
103 | + | |
104 | +static BezPoint _bz9[] = { /* heart from assorted shapes */ | |
105 | + { BEZ_MOVE_TO, {0.219064,0.919322} }, | |
106 | + { BEZ_CURVE_TO, {-0.563306,-0.0586407}, {1.00143,-0.449826}, {1.00143,0.723729} }, | |
107 | + { BEZ_CURVE_TO, {1.00143,0.723729}, {1.00143,0.723729}, {1.00143,0.723729} }, | |
108 | + { BEZ_CURVE_TO, {1.00143,-0.449826}, {2.56617,-0.0586407}, {1.7838,0.919322} }, | |
109 | + { BEZ_CURVE_TO, {1.7838,0.919322}, {1.00143,1.89728}, {1.00143,1.89728} }, | |
110 | + { BEZ_CURVE_TO, {1.00143,1.89728}, {0.219064,0.919322}, {0.219064,0.919322} }, | |
111 | +}; | |
81 | 112 | |
82 | 113 | #define T (0.1) |
83 | 114 | #define BEZ(x) sizeof(_bz ##x)/sizeof(BezPoint), _bz ##x |
@@ -86,7 +117,7 @@ static struct _TestBeziers { | ||
86 | 117 | int num; |
87 | 118 | BezPoint *pts; |
88 | 119 | Rectangle box; |
89 | -} _test_beziers[] = { /* top, left, bottom, right */ | |
120 | +} _test_beziers[] = { /* left, top, right, bottom */ | |
90 | 121 | { BEZ(1), { 0.0-T, 0.5-T, 2.0+T, 2.0+T } }, |
91 | 122 | { BEZ(2), {-2.0-T, 0.5-T, 0.0+T, 2.0+T } }, |
92 | 123 | { BEZ(3), {-2.0-T,-1.5-T, 0.0+T, 0.0+T } }, |
@@ -95,6 +126,8 @@ static struct _TestBeziers { | ||
95 | 126 | { BEZ(5), { 0.0-T, 0.5-T, 2.0+T, 2.0+T } }, |
96 | 127 | { BEZ(6), { 0.2-T, 0.0-T, 1.8+T, 2.0+T } }, |
97 | 128 | { BEZ(7), { 0.25-T,0.25-T, 1.75+T, 1.75+T} }, |
129 | + { BEZ(8), { 0-T, 0-T, 3+T, 4+T} }, | |
130 | + { BEZ(9), { 0-T, 0-T, 2.052+T, 1.897+T } }, | |
98 | 131 | }; |
99 | 132 | #undef BEZ |
100 | 133 |
@@ -122,11 +155,21 @@ _add_bezier_tests (void) | ||
122 | 155 | } |
123 | 156 | } |
124 | 157 | |
158 | +#ifdef G_OS_WIN32 | |
159 | +#define Rectangle win32Rectangle | |
160 | +#include <windows.h> | |
161 | +#endif | |
162 | + | |
125 | 163 | int |
126 | 164 | main (int argc, char** argv) |
127 | 165 | { |
128 | 166 | int ret; |
129 | 167 | |
168 | +#ifdef G_OS_WIN32 | |
169 | + /* No dialog if it fails, please. */ | |
170 | + SetErrorMode(SetErrorMode(0) | SEM_NOGPFAULTERRORBOX); | |
171 | +#endif | |
172 | + | |
130 | 173 | g_test_init (&argc, &argv, NULL); |
131 | 174 | /* not really needed - or are there message_warnings in the bbox code? */ |
132 | 175 | libdia_init (DIA_MESSAGE_STDERR); |