1
#include <glib/gmacros.h>
3
#include "utest/utest.h"
4
#include "attributes.h"
7
/* Extracted mechanically from http://www.w3.org/TR/SVG11/attindex.html:
9
tidy -wrap 999 -asxml < attindex.html 2>/dev/null |
13
sed 's,</td>.*,,;s,^<td>,,;1,/^%/d;/^%/d;s,^, {",;s/$/", false},/' |
16
attindex.html lacks attributeName, begin, additive, font, marker;
17
I've added these manually.
19
static struct {char const *attr; bool supported;} const all_attrs[] = {
20
{"attributeName", true},
25
{"line-height", true},
27
{"accent-height", false},
29
{"alignment-baseline", true},
30
{"alphabetic", false},
33
{"arabic-form", false},
35
{"attributeType", true},
37
{"baseFrequency", false},
38
{"baseline-shift", true},
39
{"baseProfile", false},
42
{"block-progression", true},
45
{"cap-height", false},
50
{"clipPathUnits", true},
52
{"color-interpolation", true},
53
{"color-interpolation-filters", true},
54
{"color-profile", true},
55
{"color-rendering", true},
56
{"contentScriptType", false},
57
{"contentStyleType", false},
63
{"diffuseConstant", false},
67
{"dominant-baseline", true},
73
{"enable-background", true},
76
{"externalResourcesRequired", false},
77
{"feColorMatrix", false},
78
{"feComposite", false},
79
{"feGaussianBlur", false},
80
{"feMorphology", false},
83
{"fill-opacity", true},
87
{"filterUnits", false},
88
{"flood-color", true},
89
{"flood-opacity", true},
90
{"font-family", true},
92
{"font-size-adjust", true},
93
{"font-stretch", true},
95
{"font-variant", true},
96
{"font-weight", true},
103
{"glyph-name", false},
104
{"glyph-orientation-horizontal", true},
105
{"glyph-orientation-vertical", true},
107
{"gradientTransform", true},
108
{"gradientUnits", true},
111
{"horiz-adv-x", false},
112
{"horiz-origin-x", false},
113
{"horiz-origin-y", false},
114
{"ideographic", false},
115
{"image-rendering", true},
118
{"intercept", false},
124
{"kernelMatrix", false},
125
{"kernelUnitLength", false},
127
{"keyPoints", false},
128
{"keySplines", true},
131
{"lengthAdjust", false},
132
{"letter-spacing", true},
133
{"lighting-color", true},
134
{"limitingConeAngle", false},
136
{"marker-end", true},
137
{"marker-mid", true},
138
{"marker-start", true},
139
{"markerHeight", true},
140
{"markerUnits", true},
141
{"markerWidth", true},
143
{"maskContentUnits", true},
145
{"mathematical", false},
152
{"numOctaves", false},
155
{"onactivate", false},
160
{"onfocusin", false},
161
{"onfocusout", false},
163
{"onmousedown", false},
164
{"onmousemove", false},
165
{"onmouseout", false},
166
{"onmouseover", false},
167
{"onmouseup", false},
177
{"orientation", true},
180
{"overline-position", false},
181
{"overline-thickness", false},
184
{"pathLength", false},
185
{"patternContentUnits", true},
186
{"patternTransform", true},
187
{"patternUnits", true},
188
{"pointer-events", true},
190
{"pointsAtX", false},
191
{"pointsAtY", false},
192
{"pointsAtZ", false},
193
{"preserveAlpha", false},
194
{"preserveAspectRatio", true},
195
{"primitiveUnits", false},
200
{"rendering-intent", false},
201
{"repeatCount", true},
203
{"requiredExtensions", false},
211
{"shape-rendering", true},
214
{"specularConstant", false},
215
{"specularExponent", false},
216
{"spreadMethod", true},
217
{"startOffset", true},
218
{"stdDeviation", false},
221
{"stitchTiles", false},
222
{"stop-color", true},
223
{"stop-opacity", true},
224
{"strikethrough-position", false},
225
{"strikethrough-thickness", false},
227
{"stroke-dasharray", true},
228
{"stroke-dashoffset", true},
229
{"stroke-linecap", true},
230
{"stroke-linejoin", true},
231
{"stroke-miterlimit", true},
232
{"stroke-opacity", true},
233
{"stroke-width", true},
235
{"surfaceScale", false},
236
{"systemLanguage", false},
237
{"tableValues", false},
241
{"text-align", true},
242
{"text-anchor", true},
243
{"text-decoration", true},
244
{"text-indent", true},
245
{"text-rendering", true},
246
{"text-transform", true},
247
{"textLength", false},
254
{"underline-position", false},
255
{"underline-thickness", false},
257
{"unicode-bidi", true},
258
{"unicode-range", false},
259
{"units-per-em", false},
260
{"v-alphabetic", false},
261
{"v-hanging", false},
262
{"v-ideographic", false},
263
{"v-mathematical", false},
266
{"vert-adv-y", false},
267
{"vert-origin-x", false},
268
{"vert-origin-y", false},
270
{"viewTarget", false},
271
{"visibility", true},
274
{"word-spacing", true},
275
{"writing-mode", true},
280
{"xChannelSelector", false},
281
{"xlink:actuate", true},
282
{"xlink:arcrole", true},
283
{"xlink:href", true},
284
{"xlink:role", true},
285
{"xlink:show", true},
286
{"xlink:title", true},
287
{"xlink:type", true},
291
{"xmlns:xlink", false},
295
{"yChannelSelector", false},
297
{"zoomAndPan", false},
299
/* Extra attributes. */
301
{"inkscape:collect", true},
302
{"inkscape:document-units", true},
303
{"inkscape:label", true},
304
{"sodipodi:insensitive", true},
305
{"sodipodi:nonprintable", true},
306
{"inkscape:groupmode", true},
307
{"sodipodi:version", true},
308
{"inkscape:version", true},
309
{"inkscape:pageopacity", true},
310
{"inkscape:pageshadow", true},
311
{"inkscape:zoom", true},
312
{"inkscape:cx", true},
313
{"inkscape:cy", true},
314
{"inkscape:window-width", true},
315
{"inkscape:window-height", true},
316
{"inkscape:window-x", true},
317
{"inkscape:window-y", true},
318
{"inkscape:grid-bbox", true},
319
{"inkscape:guide-bbox", true},
320
{"inkscape:grid-points", true},
321
{"inkscape:guide-points", true},
322
{"inkscape:current-layer", true},
323
{"inkscape:connector-type", true},
324
{"inkscape:connection-start", true},
325
{"inkscape:connection-end", true},
326
{"inkscape:connector-avoid", true},
327
{"sodipodi:cx", true},
328
{"sodipodi:cy", true},
329
{"sodipodi:rx", true},
330
{"sodipodi:ry", true},
331
{"sodipodi:start", true},
332
{"sodipodi:end", true},
333
{"sodipodi:open", true},
334
{"sodipodi:sides", true},
335
{"sodipodi:r1", true},
336
{"sodipodi:r2", true},
337
{"sodipodi:arg1", true},
338
{"sodipodi:arg2", true},
339
{"inkscape:flatsided", true},
340
{"inkscape:rounded", true},
341
{"inkscape:randomized", true},
342
{"sodipodi:expansion", true},
343
{"sodipodi:revolution", true},
344
{"sodipodi:radius", true},
345
{"sodipodi:argument", true},
346
{"sodipodi:t0", true},
347
{"sodipodi:original", true},
348
{"inkscape:original", true},
349
{"inkscape:href", true},
350
{"inkscape:radius", true},
351
{"sodipodi:role", true},
352
{"sodipodi:linespacing", true},
353
{"inkscape:srcNoMarkup", true},
354
{"inkscape:srcPango", true},
355
{"inkscape:dstShape", true},
356
{"inkscape:dstPath", true},
357
{"inkscape:dstBox", true},
358
{"inkscape:dstColumn", true},
359
{"inkscape:excludeShape", true},
360
{"inkscape:layoutOptions", true},
365
{"showguides", true},
366
{"gridtolerance", true},
367
{"guidetolerance", true},
368
{"gridoriginx", true},
369
{"gridoriginy", true},
370
{"gridspacingx", true},
371
{"gridspacingy", true},
373
{"gridopacity", true},
374
{"gridempcolor", true},
375
{"gridempopacity", true},
376
{"gridempspacing", true},
377
{"guidecolor", true},
378
{"guideopacity", true},
379
{"guidehicolor", true},
380
{"guidehiopacity", true},
381
{"showborder", true},
382
{"inkscape:showpageshadow", true},
383
{"borderlayer", true},
384
{"bordercolor", true},
385
{"borderopacity", true},
396
utest_start("attributes");
398
std::vector<bool> ids;
400
UTEST_TEST("attribute lookup") {
401
for (unsigned i = 0; i < G_N_ELEMENTS(all_attrs); ++i) {
402
char const *const attr_str = all_attrs[i].attr;
403
unsigned const id = sp_attribute_lookup(attr_str);
404
bool const recognized(id);
405
UTEST_ASSERT(recognized == all_attrs[i].supported);
407
if (ids.size() <= id) {
410
UTEST_ASSERT(!ids[id]);
413
unsigned char const *reverse_ustr = sp_attribute_name(id);
414
char const *reverse_str = reinterpret_cast<char const *>(reverse_ustr);
415
UTEST_ASSERT(streq(reverse_str, attr_str));
419
/* Test for any attributes that this test program doesn't know about.
421
* If any are found, then:
423
* If it is in the `inkscape:' namespace then simply add it to all_attrs with
424
* `true' as the second field (`supported').
426
* If it is in the `sodipodi:' namespace then check the spelling against sodipodi
427
* sources. If you don't have sodipodi sources, then don't add it: leave to someone
430
* Otherwise, it's probably a bug: ~all SVG 1.1 attributes should already be
431
* in the all_attrs table. However, the comment above all_attrs does mention
432
* some things missing from attindex.html, so there may be more. Check the SVG
433
* spec. Another possibility is that the attribute is new in SVG 1.2. In this case,
434
* check the spelling against the [draft] SVG 1.2 spec before adding to all_attrs.
435
* (If you can't be bothered checking the spec, then don't update all_attrs.)
437
* If the attribute isn't in either SVG 1.1 or 1.2 then it's probably a mistake
438
* for it not to be in the inkscape namespace. (Not sure about attributes used only
439
* on elements in the inkscape namespace though.)
441
* In any case, make sure that the attribute's source is documented accordingly.
444
unsigned const n_ids = ids.size();
445
for (unsigned id = 1; id < n_ids; ++id) {
447
unsigned char const *str = sp_attribute_name(id);
448
printf("%s\n", (const char *)str); /* Apparently printf doesn't like unsigned strings -- Ted */
452
UTEST_ASSERT(!found);
460
return ( test_attributes()
468
c-file-style:"stroustrup"
469
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
474
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :