diff options
| author | Krzysztof Kosi??ski <tweenk.pl@gmail.com> | 2015-05-08 17:26:29 +0000 |
|---|---|---|
| committer | Krzysztof KosiĆski <tweenk.pl@gmail.com> | 2015-05-08 17:26:29 +0000 |
| commit | f31b2c75e1313ccceeb6d33cc14aa545d4d370f9 (patch) | |
| tree | 444b38fe397f34ee5c298ed0efd5cc9f49afb7cf /test | |
| parent | More helper/geom.h pruning. (diff) | |
| parent | cmake: Bring cmake installation in line with autotools (bug #1451481) (diff) | |
| download | inkscape-f31b2c75e1313ccceeb6d33cc14aa545d4d370f9.tar.gz inkscape-f31b2c75e1313ccceeb6d33cc14aa545d4d370f9.zip | |
Merge from trunk
(bzr r14059.2.11)
Diffstat (limited to 'test')
| -rw-r--r-- | test/CMakeLists.txt | 478 | ||||
| -rw-r--r-- | test/doc-per-case-test.cpp | 52 | ||||
| -rw-r--r-- | test/doc-per-case-test.h | 43 | ||||
| -rw-r--r-- | test/src/attributes-test.cpp | 618 | ||||
| -rw-r--r-- | test/src/color-profile-test.cpp | 126 | ||||
| -rw-r--r-- | test/src/dir-util-test.cpp | 63 | ||||
| -rw-r--r-- | test/unittest.cpp | 58 |
7 files changed, 1438 insertions, 0 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 000000000..0b9584631 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,478 @@ +# ----------------------------------------------------------------------------- +# +# ----------------------------------------------------------------------------- + +set(CMAKE_CTEST_COMMAND ctest -V) + +add_subdirectory(${GMOCK_DIR} ${CMAKE_BINARY_DIR}/gmock) + +include_directories(SYSTEM ${GMOCK_DIR}/gtest/include + ${GMOCK_DIR}/include) + +# copied from ../src/CMakeLists.txt +# TODO resolve to shared definition +set(sp_SRC + ../src/attribute-rel-css.cpp + ../src/attribute-rel-svg.cpp + ../src/attribute-rel-util.cpp + ../src/sp-anchor.cpp + ../src/sp-clippath.cpp + ../src/sp-conn-end-pair.cpp + ../src/sp-conn-end.cpp + ../src/sp-cursor.cpp + ../src/sp-defs.cpp + ../src/sp-desc.cpp + ../src/sp-ellipse.cpp + ../src/sp-factory.cpp + ../src/sp-filter-primitive.cpp + ../src/sp-filter-reference.cpp + ../src/sp-filter.cpp + ../src/sp-flowdiv.cpp + ../src/sp-flowregion.cpp + ../src/sp-flowtext.cpp + ../src/sp-font-face.cpp + ../src/sp-font.cpp + ../src/sp-glyph-kerning.cpp + ../src/sp-glyph.cpp + ../src/sp-gradient-reference.cpp + ../src/sp-gradient.cpp + ../src/sp-guide.cpp + ../src/sp-hatch-path.cpp + ../src/sp-hatch.cpp + ../src/sp-image.cpp + ../src/sp-item-group.cpp + ../src/sp-item-notify-moveto.cpp + ../src/sp-item-rm-unsatisfied-cns.cpp + ../src/sp-item-transform.cpp + ../src/sp-item-update-cns.cpp + ../src/sp-item.cpp + ../src/sp-line.cpp + ../src/sp-linear-gradient.cpp + ../src/sp-lpe-item.cpp + ../src/sp-marker.cpp + ../src/sp-mask.cpp + ../src/sp-mesh-array.cpp + ../src/sp-mesh-patch.cpp + ../src/sp-mesh-row.cpp + ../src/sp-mesh.cpp + ../src/sp-metadata.cpp + ../src/sp-missing-glyph.cpp + ../src/sp-namedview.cpp + ../src/sp-object-group.cpp + ../src/sp-object.cpp + ../src/sp-offset.cpp + ../src/sp-paint-server.cpp + ../src/sp-path.cpp + ../src/sp-pattern.cpp + ../src/sp-polygon.cpp + ../src/sp-polyline.cpp + ../src/sp-radial-gradient.cpp + ../src/sp-rect.cpp + ../src/sp-root.cpp + ../src/sp-script.cpp + ../src/sp-shape.cpp + ../src/sp-solid-color.cpp + ../src/sp-spiral.cpp + ../src/sp-star.cpp + ../src/sp-stop.cpp + ../src/sp-string.cpp + ../src/sp-style-elem.cpp + ../src/sp-switch.cpp + ../src/sp-symbol.cpp + ../src/sp-tag-use-reference.cpp + ../src/sp-tag-use.cpp + ../src/sp-tag.cpp + ../src/sp-text.cpp + ../src/sp-title.cpp + ../src/sp-tref-reference.cpp + ../src/sp-tref.cpp + ../src/sp-tspan.cpp + ../src/sp-use-reference.cpp + ../src/sp-use.cpp + ../src/splivarot.cpp + ../src/viewbox.cpp + + # ------- + # Headers + ../src/attribute-rel-css.h + ../src/attribute-rel-svg.h + ../src/attribute-rel-util.h + ../src/sp-anchor.h + ../src/sp-clippath.h + ../src/sp-conn-end-pair.h + ../src/sp-conn-end.h + ../src/sp-cursor.h + ../src/sp-defs.h + ../src/sp-desc.h + ../src/sp-ellipse.h + ../src/sp-factory.h + ../src/sp-filter-primitive.h + ../src/sp-filter-reference.h + ../src/sp-filter-units.h + ../src/sp-filter.h + ../src/sp-flowdiv.h + ../src/sp-flowregion.h + ../src/sp-flowtext.h + ../src/sp-font-face.h + ../src/sp-font.h + ../src/sp-glyph-kerning.h + ../src/sp-glyph.h + ../src/sp-gradient-reference.h + ../src/sp-gradient-spread.h + ../src/sp-gradient-test.h + ../src/sp-gradient-units.h + ../src/sp-gradient-vector.h + ../src/sp-gradient.h + ../src/sp-guide-attachment.h + ../src/sp-guide-constraint.h + ../src/sp-guide.h + ../src/sp-hatch-path.h + ../src/sp-hatch.h + ../src/sp-image.h + ../src/sp-item-group.h + ../src/sp-item-notify-moveto.h + ../src/sp-item-rm-unsatisfied-cns.h + ../src/sp-item-transform.h + ../src/sp-item-update-cns.h + ../src/sp-item.h + ../src/sp-line.h + ../src/sp-linear-gradient.h + ../src/sp-lpe-item.h + ../src/sp-marker-loc.h + ../src/sp-marker.h + ../src/sp-mask.h + ../src/sp-mesh-array.h + ../src/sp-mesh-patch.h + ../src/sp-mesh-row.h + ../src/sp-mesh.h + ../src/sp-metadata.h + ../src/sp-missing-glyph.h + ../src/sp-namedview.h + ../src/sp-object-group.h + ../src/sp-object.h + ../src/sp-offset.h + ../src/sp-paint-server-reference.h + ../src/sp-paint-server.h + ../src/sp-path.h + ../src/sp-pattern.h + ../src/sp-polygon.h + ../src/sp-polyline.h + ../src/sp-radial-gradient.h + ../src/sp-rect.h + ../src/sp-root.h + ../src/sp-script.h + ../src/sp-shape.h + ../src/sp-solid-color.h + ../src/sp-spiral.h + ../src/sp-star.h + ../src/sp-stop.h + ../src/sp-string.h + ../src/sp-style-elem-test.h + ../src/sp-style-elem.h + ../src/sp-switch.h + ../src/sp-symbol.h + ../src/sp-text.h + ../src/sp-textpath.h + ../src/sp-title.h + ../src/sp-tref-reference.h + ../src/sp-tref.h + ../src/sp-tspan.h + ../src/sp-use-reference.h + ../src/sp-use.h + ../src/viewbox.h +) + +# copied from ../src/CMakeLists.txt +# TODO resolve to shared definition +set(inkscape_SRC + ../src/attributes.cpp + ../src/axis-manip.cpp + ../src/box3d-side.cpp + ../src/box3d.cpp + ../src/color-profile.cpp + ../src/color.cpp + ../src/composite-undo-stack-observer.cpp + ../src/conditions.cpp + ../src/conn-avoid-ref.cpp + ../src/console-output-undo-observer.cpp + ../src/context-fns.cpp + ../src/desktop-events.cpp + ../src/desktop-style.cpp + ../src/desktop.cpp + ../src/device-manager.cpp + ../src/dir-util.cpp + ../src/document-subset.cpp + ../src/document-undo.cpp + ../src/document.cpp + ../src/ege-color-prof-tracker.cpp + ../src/event-log.cpp + ../src/extract-uri.cpp + ../src/file.cpp + ../src/filter-chemistry.cpp + ../src/filter-enums.cpp + ../src/gc-anchored.cpp + ../src/gc-finalized.cpp + ../src/gradient-chemistry.cpp + ../src/gradient-drag.cpp + ../src/graphlayout.cpp + ../src/guide-snapper.cpp + ../src/help.cpp + ../src/id-clash.cpp + ../src/inkscape.cpp + ../src/knot-holder-entity.cpp + ../src/knot-ptr.cpp + ../src/knot.cpp + ../src/knotholder.cpp + ../src/layer-fns.cpp + ../src/layer-manager.cpp + ../src/layer-model.cpp + ../src/line-geometry.cpp + ../src/line-snapper.cpp + ../src/main-cmdlineact.cpp + ../src/media.cpp + ../src/message-context.cpp + ../src/message-stack.cpp + ../src/mod360.cpp + ../src/object-hierarchy.cpp + ../src/object-snapper.cpp + ../src/path-chemistry.cpp + ../src/persp3d-reference.cpp + ../src/persp3d.cpp + ../src/perspective-line.cpp + ../src/preferences.cpp + ../src/prefix.cpp + ../src/print.cpp + ../src/profile-manager.cpp + ../src/proj_pt.cpp + ../src/rdf.cpp + ../src/removeoverlap.cpp + ../src/resource-manager.cpp + ../src/rubberband.cpp + ../src/satisfied-guide-cns.cpp + ../src/selcue.cpp + ../src/selection-chemistry.cpp + ../src/selection-describer.cpp + ../src/selection.cpp + ../src/seltrans-handles.cpp + ../src/seltrans.cpp + ../src/shortcuts.cpp + ../src/snap-preferences.cpp + ../src/snap.cpp + ../src/snapped-curve.cpp + ../src/snapped-line.cpp + ../src/snapped-point.cpp + ../src/snapper.cpp + ../src/style-internal.cpp + ../src/style.cpp + ../src/svg-view-widget.cpp + ../src/svg-view.cpp + ../src/text-chemistry.cpp + ../src/text-editing.cpp + ../src/transf_mat_3x4.cpp + ../src/unclump.cpp + ../src/unicoderange.cpp + ../src/uri-references.cpp + ../src/uri.cpp + ../src/vanishing-point.cpp + ../src/verbs.cpp + ../src/version.cpp + + # ------- + # Headers + ../src/MultiPrinter.h + ../src/PylogFormatter.h + ../src/TRPIFormatter.h + ../src/attributes-test.h + ../src/attributes.h + ../src/axis-manip.h + ../src/bad-uri-exception.h + ../src/box3d-side.h + ../src/box3d.h + ../src/cms-color-types.h + ../src/cms-system.h + ../src/color-profile-cms-fns.h + ../src/color-profile-test.h + ../src/color-profile.h + ../src/color-rgba.h + ../src/color.h + ../src/colorspace.h + ../src/composite-undo-stack-observer.h + ../src/conditions.h + ../src/conn-avoid-ref.h + ../src/console-output-undo-observer.h + ../src/context-fns.h + ../src/decimal-round.h + ../src/desktop-events.h + ../src/desktop-style.h + ../src/desktop.h + ../src/device-manager.h + ../src/dir-util-test.h + ../src/dir-util.h + ../src/document-private.h + ../src/document-subset.h + ../src/document-undo.h + ../src/document.h + ../src/ege-color-prof-tracker.h + ../src/enums.h + ../src/event-log.h + ../src/event.h + ../src/extract-uri-test.h + ../src/extract-uri.h + ../src/file.h + ../src/fill-or-stroke.h + ../src/filter-chemistry.h + ../src/filter-enums.h + ../src/gc-anchored.h + ../src/gc-finalized.h + ../src/gradient-chemistry.h + ../src/gradient-drag.h + ../src/graphlayout.h + ../src/guide-snapper.h + ../src/help.h + ../src/helper-fns.h + ../src/icon-size.h + ../src/id-clash.h + ../src/inkscape-version.h + ../src/inkscape.h + ../src/isinf.h + ../src/knot-enums.h + ../src/knot-holder-entity.h + ../src/knot-ptr.h + ../src/knot.h + ../src/knotholder.h + ../src/layer-fns.h + ../src/layer-manager.h + ../src/layer-model.h + ../src/line-geometry.h + ../src/line-snapper.h + ../src/macros.h + ../src/main-cmdlineact.h + ../src/marker-test.h + ../src/media.h + ../src/menus-skeleton.h + ../src/message-context.h + ../src/message-stack.h + ../src/message.h + ../src/mod360-test.h + ../src/mod360.h + ../src/number-opt-number.h + ../src/object-hierarchy.h + ../src/object-snapper.h + ../src/object-test.h + ../src/path-chemistry.h + ../src/path-prefix.h + ../src/persp3d-reference.h + ../src/persp3d.h + ../src/perspective-line.h + ../src/preferences-skeleton.h + ../src/preferences-test.h + ../src/preferences.h + ../src/prefix.h + ../src/print.h + ../src/profile-manager.h + ../src/proj_pt.h + ../src/rdf.h + ../src/remove-last.h + ../src/removeoverlap.h + ../src/require-config.h + ../src/resource-manager.h + ../src/round-test.h + ../src/round.h + ../src/rubberband.h + ../src/satisfied-guide-cns.h + ../src/selcue.h + ../src/selection-chemistry.h + ../src/selection-describer.h + ../src/selection.h + ../src/seltrans-handles.h + ../src/seltrans.h + ../src/shortcuts.h + ../src/snap-candidate.h + ../src/snap-enums.h + ../src/snap-preferences.h + ../src/snap.h + ../src/snapped-curve.h + ../src/snapped-line.h + ../src/snapped-point.h + ../src/snapper.h + ../src/splivarot.h + ../src/streq.h + ../src/strneq.h + ../src/style-enums.h + ../src/style-internal.h + ../src/style-test.h + ../src/style.h + ../src/svg-profile.h + ../src/svg-view-widget.h + ../src/svg-view.h + ../src/syseq.h + ../src/test-helpers.h + ../src/text-chemistry.h + ../src/text-editing.h + ../src/text-tag-attributes.h + ../src/transf_mat_3x4.h + ../src/unclump.h + ../src/undo-stack-observer.h + ../src/unicoderange.h + ../src/uri-references.h + ../src/uri-test.h + ../src/uri.h + ../src/vanishing-point.h + ../src/verbs-test.h + ../src/verbs.h + ../src/version.h +) + +get_property(inkscape_global_SRC GLOBAL PROPERTY inkscape_global_SRC) + +set_source_files_properties( + ${CMAKE_BINARY_DIR}/src/inkscape-version.cpp + PROPERTIES GENERATED TRUE) + +include_directories(${CMAKE_CURRENT_BINARY_DIR}/__/src) + +add_executable(unittest + unittest.cpp + doc-per-case-test.cpp + src/attributes-test.cpp + src/color-profile-test.cpp + src/dir-util-test.cpp + ${inkscape_SRC} + ${sp_SRC} + ${inkscape_global_SRC} + ${CMAKE_BINARY_DIR}/src/inkscape-version.cpp +) + +add_dependencies(unittest inkscape_version) + +target_link_libraries(unittest + gmock_main + + # order from automake + #sp_LIB + nrtype_LIB + + #inkscape_LIB + #sp_LIB # annoying, we need both! + nrtype_LIB # annoying, we need both! + + croco_LIB + avoid_LIB + gdl_LIB + cola_LIB + vpsc_LIB + livarot_LIB + uemf_LIB + 2geom_LIB + depixelize_LIB + util_LIB + gc_LIB + + ${INKSCAPE_LIBS} +) + +add_test(BaseTest ${EXECUTABLE_OUTPUT_PATH}/unittest) + +add_dependencies(check unittest) + +# diff --git a/test/doc-per-case-test.cpp b/test/doc-per-case-test.cpp new file mode 100644 index 000000000..da75b1e65 --- /dev/null +++ b/test/doc-per-case-test.cpp @@ -0,0 +1,52 @@ +/* + * Test fixture with SPDocument per entire test case. + * + * Author: + * Jon A. Cruz <jon@joncruz.org> + * + * Copyright (C) 2015 Authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "doc-per-case-test.h" + +#include "inkscape.h" + +SPDocument *DocPerCaseTest::_doc = 0; + +DocPerCaseTest::DocPerCaseTest() : + ::testing::Test() +{ +} + +void DocPerCaseTest::SetUpTestCase() +{ + if ( !Inkscape::Application::exists() ) + { + // Create the global inkscape object. + Inkscape::Application::create("", false); + } + + _doc = SPDocument::createNewDoc( NULL, TRUE, true ); + ASSERT_TRUE( _doc != NULL ); +} + +void DocPerCaseTest::TearDownTestCase() +{ + if (_doc) { + _doc->doUnref(); + _doc = NULL; + } +} + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/test/doc-per-case-test.h b/test/doc-per-case-test.h new file mode 100644 index 000000000..b6f01403a --- /dev/null +++ b/test/doc-per-case-test.h @@ -0,0 +1,43 @@ +/* + * Test fixture with SPDocument per entire test case. + * + * Author: + * Jon A. Cruz <jon@joncruz.org> + * + * Copyright (C) 2015 Authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "gtest/gtest.h" + +#include "document.h" + + +/** + * Simple fixture that creates a single SPDocument to be shared between all tests + * in this test case. + */ +class DocPerCaseTest : public ::testing::Test +{ +public: + DocPerCaseTest(); + +protected: + static void SetUpTestCase(); + + static void TearDownTestCase(); + + static SPDocument *_doc; +}; + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/test/src/attributes-test.cpp b/test/src/attributes-test.cpp new file mode 100644 index 000000000..ab1c3cec6 --- /dev/null +++ b/test/src/attributes-test.cpp @@ -0,0 +1,618 @@ +/* + * Unit tests for attributes. + * + * Author: + * Jon A. Cruz <jon@joncruz.org> + * + * Copyright (C) 2015 Authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include <string> +#include <vector> + +#include "gtest/gtest.h" + +#include "attributes.h" + +namespace { + +static const unsigned int FIRST_VALID_ID = 1; + +class AttributeInfo +{ +public: + AttributeInfo(std::string const &attr, bool supported) : + attr(attr), + supported(supported) + { + } + + std::string attr; + bool supported; +}; + +typedef std::vector<AttributeInfo>::iterator AttrItr; + +std::vector<AttributeInfo> getKnownAttrs() +{ +/* Extracted mechanically from http://www.w3.org/TR/SVG11/attindex.html: + + tidy -wrap 999 -asxml < attindex.html 2>/dev/null | + tr -d \\n | + sed 's,<tr>,@,g' | + tr @ \\n | + sed 's,</td>.*,,;s,^<td>,,;1,/^%/d;/^%/d;s,^, {",;s/$/", false},/' | + uniq + + attindex.html lacks attributeName, begin, additive, font, marker; + I've added these manually. + + SVG 2: white-space, shape-inside, shape-outside, shape-padding, shape-margin +*/ + AttributeInfo all_attrs[] = { + AttributeInfo("attributeName", true), + AttributeInfo("begin", true), + AttributeInfo("additive", true), + AttributeInfo("font", true), + AttributeInfo("-inkscape-font-specification", true), // TODO look into this attribute's name + AttributeInfo("marker", true), + AttributeInfo("line-height", true), + + AttributeInfo("accent-height", true), + AttributeInfo("accumulate", true), + AttributeInfo("alignment-baseline", true), + AttributeInfo("alphabetic", true), + AttributeInfo("amplitude", true), + AttributeInfo("animate", false), + AttributeInfo("arabic-form", true), + AttributeInfo("ascent", true), + AttributeInfo("attributeType", true), + AttributeInfo("azimuth", true), + AttributeInfo("baseFrequency", true), + AttributeInfo("baseline-shift", true), + AttributeInfo("baseProfile", false), + AttributeInfo("bbox", true), + AttributeInfo("bias", true), + AttributeInfo("block-progression", true), + AttributeInfo("by", true), + AttributeInfo("calcMode", true), + AttributeInfo("cap-height", true), + AttributeInfo("class", false), + AttributeInfo("clip", true), + AttributeInfo("clip-path", true), + AttributeInfo("clip-rule", true), + AttributeInfo("clipPathUnits", true), + AttributeInfo("color", true), + AttributeInfo("color-interpolation", true), + AttributeInfo("color-interpolation-filters", true), + AttributeInfo("color-profile", true), + AttributeInfo("color-rendering", true), + AttributeInfo("contentScriptType", false), + AttributeInfo("contentStyleType", false), + AttributeInfo("cursor", true), + AttributeInfo("cx", true), + AttributeInfo("cy", true), + AttributeInfo("d", true), + AttributeInfo("descent", true), + AttributeInfo("diffuseConstant", true), + AttributeInfo("direction", true), + AttributeInfo("display", true), + AttributeInfo("divisor", true), + AttributeInfo("dominant-baseline", true), + AttributeInfo("dur", true), + AttributeInfo("dx", true), + AttributeInfo("dy", true), + AttributeInfo("edgeMode", true), + AttributeInfo("elevation", true), + AttributeInfo("enable-background", true), + AttributeInfo("end", true), + AttributeInfo("exponent", true), + AttributeInfo("externalResourcesRequired", false), + AttributeInfo("feBlend", false), + AttributeInfo("feColorMatrix", false), + AttributeInfo("feComponentTransfer", false), + AttributeInfo("feComposite", false), + AttributeInfo("feConvolveMatrix", false), + AttributeInfo("feDiffuseLighting", false), + AttributeInfo("feDisplacementMap", false), + AttributeInfo("feFlood", false), + AttributeInfo("feGaussianBlur", false), + AttributeInfo("feImage", false), + AttributeInfo("feMerge", false), + AttributeInfo("feMorphology", false), + AttributeInfo("feOffset", false), + AttributeInfo("feSpecularLighting", false), + AttributeInfo("feTile", false), + AttributeInfo("fill", true), + AttributeInfo("fill-opacity", true), + AttributeInfo("fill-rule", true), + AttributeInfo("filter", true), + AttributeInfo("filterRes", true), + AttributeInfo("filterUnits", true), + AttributeInfo("flood-color", true), + AttributeInfo("flood-opacity", true), + AttributeInfo("font-family", true), + AttributeInfo("font-size", true), + AttributeInfo("font-size-adjust", true), + AttributeInfo("font-stretch", true), + AttributeInfo("font-style", true), + AttributeInfo("font-variant", true), + AttributeInfo("font-weight", true), + AttributeInfo("format", false), + AttributeInfo("from", true), + AttributeInfo("fx", true), + AttributeInfo("fy", true), + AttributeInfo("g1", true), + AttributeInfo("g2", true), + AttributeInfo("glyph-name", true), + AttributeInfo("glyph-orientation-horizontal", true), + AttributeInfo("glyph-orientation-vertical", true), + AttributeInfo("glyphRef", false), + AttributeInfo("gradientTransform", true), + AttributeInfo("gradientUnits", true), + AttributeInfo("hanging", true), + AttributeInfo("hatchContentUnits", true), // SVG 2.0 + AttributeInfo("hatchTransform", true), // SVG 2.0 TODO renamed to transform + AttributeInfo("hatchUnits", true), // SVG 2.0 + AttributeInfo("height", true), + AttributeInfo("horiz-adv-x", true), + AttributeInfo("horiz-origin-x", true), + AttributeInfo("horiz-origin-y", true), + AttributeInfo("ideographic", true), + AttributeInfo("image-rendering", true), + AttributeInfo("in", true), + AttributeInfo("in2", true), + AttributeInfo("intercept", true), + AttributeInfo("isolation", true), + AttributeInfo("k", true), + AttributeInfo("k1", true), + AttributeInfo("k2", true), + AttributeInfo("k3", true), + AttributeInfo("k4", true), + AttributeInfo("kernelMatrix", true), + AttributeInfo("kernelUnitLength", true), + AttributeInfo("kerning", true), + AttributeInfo("keyPoints", false), + AttributeInfo("keySplines", true), + AttributeInfo("keyTimes", true), + AttributeInfo("lang", true), + AttributeInfo("lengthAdjust", true), + AttributeInfo("letter-spacing", true), + AttributeInfo("lighting-color", true), + AttributeInfo("limitingConeAngle", true), + AttributeInfo("local", true), + AttributeInfo("marker-end", true), + AttributeInfo("marker-mid", true), + AttributeInfo("marker-start", true), + AttributeInfo("markerHeight", true), + AttributeInfo("markerUnits", true), + AttributeInfo("markerWidth", true), + AttributeInfo("mask", true), + AttributeInfo("maskContentUnits", true), + AttributeInfo("maskUnits", true), + AttributeInfo("mathematical", true), + AttributeInfo("max", true), + AttributeInfo("media", false), + AttributeInfo("method", false), + AttributeInfo("min", true), + AttributeInfo("mix-blend-mode", true), + AttributeInfo("mode", true), + AttributeInfo("name", true), + AttributeInfo("numOctaves", true), + AttributeInfo("offset", true), + AttributeInfo("onabort", false), + AttributeInfo("onactivate", false), + AttributeInfo("onbegin", false), + AttributeInfo("onclick", false), + AttributeInfo("onend", false), + AttributeInfo("onerror", false), + AttributeInfo("onfocusin", false), + AttributeInfo("onfocusout", false), + AttributeInfo("onload", true), + AttributeInfo("onmousedown", false), + AttributeInfo("onmousemove", false), + AttributeInfo("onmouseout", false), + AttributeInfo("onmouseover", false), + AttributeInfo("onmouseup", false), + AttributeInfo("onrepeat", false), + AttributeInfo("onresize", false), + AttributeInfo("onscroll", false), + AttributeInfo("onunload", false), + AttributeInfo("onzoom", false), + AttributeInfo("opacity", true), + AttributeInfo("operator", true), + AttributeInfo("order", true), + AttributeInfo("orient", true), + AttributeInfo("orientation", true), + AttributeInfo("origin", false), + AttributeInfo("overflow", true), + AttributeInfo("overline-position", true), + AttributeInfo("overline-thickness", true), + AttributeInfo("paint-order", true), + AttributeInfo("panose-1", true), + AttributeInfo("path", true), + AttributeInfo("pathLength", false), + AttributeInfo("patternContentUnits", true), + AttributeInfo("patternTransform", true), + AttributeInfo("patternUnits", true), + AttributeInfo("pitch", true), // SVG 2.- + AttributeInfo("pointer-events", true), + AttributeInfo("points", true), + AttributeInfo("pointsAtX", true), + AttributeInfo("pointsAtY", true), + AttributeInfo("pointsAtZ", true), + AttributeInfo("preserveAlpha", true), + AttributeInfo("preserveAspectRatio", true), + AttributeInfo("primitiveUnits", true), + AttributeInfo("r", true), + AttributeInfo("radius", true), + AttributeInfo("refX", true), + AttributeInfo("refY", true), + AttributeInfo("rendering-intent", true), + AttributeInfo("repeatCount", true), + AttributeInfo("repeatDur", true), + AttributeInfo("requiredFeatures", true), + AttributeInfo("requiredExtensions", true), + AttributeInfo("restart", true), + AttributeInfo("result", true), + AttributeInfo("rotate", true), + AttributeInfo("rx", true), + AttributeInfo("ry", true), + AttributeInfo("scale", true), + AttributeInfo("seed", true), + AttributeInfo("shape-inside", true), + AttributeInfo("shape-margin", true), + AttributeInfo("shape-outside", true), + AttributeInfo("shape-padding", true), + AttributeInfo("shape-rendering", true), + AttributeInfo("slope", true), + AttributeInfo("solid-color", true), // SVG 2.0 + AttributeInfo("solid-opacity", true), // SVG 2.0 + AttributeInfo("spacing", false), + AttributeInfo("specularConstant", true), + AttributeInfo("specularExponent", true), + AttributeInfo("spreadMethod", true), + AttributeInfo("startOffset", true), + AttributeInfo("stdDeviation", true), + AttributeInfo("stemh", true), + AttributeInfo("stemv", true), + AttributeInfo("stitchTiles", true), + AttributeInfo("stop-color", true), + AttributeInfo("stop-opacity", true), + AttributeInfo("strikethrough-position", true), + AttributeInfo("strikethrough-thickness", true), + AttributeInfo("stroke", true), + AttributeInfo("stroke-dasharray", true), + AttributeInfo("stroke-dashoffset", true), + AttributeInfo("stroke-linecap", true), + AttributeInfo("stroke-linejoin", true), + AttributeInfo("stroke-miterlimit", true), + AttributeInfo("stroke-opacity", true), + AttributeInfo("stroke-width", true), + AttributeInfo("style", true), + AttributeInfo("surfaceScale", true), + AttributeInfo("systemLanguage", true), + AttributeInfo("tableValues", true), + AttributeInfo("target", true), + AttributeInfo("targetX", true), + AttributeInfo("targetY", true), + AttributeInfo("text-align", true), + AttributeInfo("text-anchor", true), + AttributeInfo("text-decoration", true), + AttributeInfo("text-decoration-color", true), + AttributeInfo("text-decoration-line", true), + AttributeInfo("text-decoration-style", true), + AttributeInfo("text-indent", true), + AttributeInfo("text-rendering", true), + AttributeInfo("text-transform", true), + AttributeInfo("textLength", true), + AttributeInfo("title", false), + AttributeInfo("to", true), + AttributeInfo("transform", true), + AttributeInfo("type", true), + AttributeInfo("u1", true), + AttributeInfo("u2", true), + AttributeInfo("underline-position", true), + AttributeInfo("underline-thickness", true), + AttributeInfo("unicode", true), + AttributeInfo("unicode-bidi", true), + AttributeInfo("unicode-range", true), + AttributeInfo("units-per-em", true), + AttributeInfo("v-alphabetic", true), + AttributeInfo("v-hanging", true), + AttributeInfo("v-ideographic", true), + AttributeInfo("v-mathematical", true), + AttributeInfo("values", true), + AttributeInfo("version", true), + AttributeInfo("vert-adv-y", true), + AttributeInfo("vert-origin-x", true), + AttributeInfo("vert-origin-y", true), + AttributeInfo("viewBox", true), + AttributeInfo("viewTarget", false), + AttributeInfo("visibility", true), + AttributeInfo("white-space", true), + AttributeInfo("width", true), + AttributeInfo("widths", true), + AttributeInfo("word-spacing", true), + AttributeInfo("writing-mode", true), + AttributeInfo("x", true), + AttributeInfo("x-height", true), + AttributeInfo("x1", true), + AttributeInfo("x2", true), + AttributeInfo("xChannelSelector", true), + AttributeInfo("xlink:actuate", true), + AttributeInfo("xlink:arcrole", true), + AttributeInfo("xlink:href", true), + AttributeInfo("xlink:role", true), + AttributeInfo("xlink:show", true), + AttributeInfo("xlink:title", true), + AttributeInfo("xlink:type", true), + AttributeInfo("xml:base", false), + AttributeInfo("xml:space", true), + AttributeInfo("xmlns", false), + AttributeInfo("xmlns:xlink", false), + AttributeInfo("y", true), + AttributeInfo("y1", true), + AttributeInfo("y2", true), + AttributeInfo("yChannelSelector", true), + AttributeInfo("z", true), + AttributeInfo("zoomAndPan", false), + + // Extra attributes. + AttributeInfo("id", true), + AttributeInfo("inkscape:bbox-nodes", true), + AttributeInfo("inkscape:bbox-paths", true), + AttributeInfo("inkscape:box3dsidetype", true), + AttributeInfo("inkscape:collect", true), + AttributeInfo("inkscape:connection-end", true), + AttributeInfo("inkscape:connection-end-point", true), + AttributeInfo("inkscape:connection-points", true), + AttributeInfo("inkscape:connection-start", true), + AttributeInfo("inkscape:connection-start-point", true), + AttributeInfo("inkscape:connector-avoid", true), + AttributeInfo("inkscape:connector-curvature", true), + AttributeInfo("inkscape:connector-spacing", true), + AttributeInfo("inkscape:connector-type", true), + AttributeInfo("inkscape:corner0", true), + AttributeInfo("inkscape:corner7", true), + AttributeInfo("inkscape:current-layer", true), + AttributeInfo("inkscape:cx", true), + AttributeInfo("inkscape:cy", true), + AttributeInfo("inkscape:document-units", true), + AttributeInfo("inkscape:dstBox", true), + AttributeInfo("inkscape:dstColumn", true), + AttributeInfo("inkscape:dstPath", true), + AttributeInfo("inkscape:dstShape", true), + AttributeInfo("inkscape:excludeShape", true), + AttributeInfo("inkscape:expanded", true), + AttributeInfo("inkscape:flatsided", true), + AttributeInfo("inkscape:groupmode", true), + AttributeInfo("inkscape:highlight-color", true), + AttributeInfo("inkscape:href", true), + AttributeInfo("inkscape:label", true), + AttributeInfo("inkscape:layoutOptions", true), + AttributeInfo("inkscape:object-nodes", true), + AttributeInfo("inkscape:object-paths", true), + AttributeInfo("inkscape:original", true), + AttributeInfo("inkscape:original-d", true), + AttributeInfo("inkscape:pageopacity", true), + AttributeInfo("inkscape:pageshadow", true), + AttributeInfo("inkscape:path-effect", true), + AttributeInfo("inkscape:persp3d", true), + AttributeInfo("inkscape:persp3d-origin", true), + AttributeInfo("inkscape:perspectiveID", true), + AttributeInfo("inkscape:radius", true), + AttributeInfo("inkscape:randomized", true), + AttributeInfo("inkscape:rounded", true), + AttributeInfo("inkscape:snap-bbox", true), + AttributeInfo("inkscape:snap-bbox-edge-midpoints", true), + AttributeInfo("inkscape:snap-bbox-midpoints", true), + AttributeInfo("inkscape:snap-center", true), + AttributeInfo("inkscape:snap-global", true), + AttributeInfo("inkscape:snap-grids", true), + AttributeInfo("inkscape:snap-intersection-paths", true), + AttributeInfo("inkscape:snap-midpoints", true), + AttributeInfo("inkscape:snap-nodes", true), + AttributeInfo("inkscape:snap-object-midpoints", true), + AttributeInfo("inkscape:snap-others", true), + AttributeInfo("inkscape:snap-page", true), + AttributeInfo("inkscape:snap-path-clip", true), + AttributeInfo("inkscape:snap-path-mask", true), + AttributeInfo("inkscape:snap-perpendicular", true), + AttributeInfo("inkscape:snap-smooth-nodes", true), + AttributeInfo("inkscape:snap-tangential", true), + AttributeInfo("inkscape:snap-text-baseline", true), + AttributeInfo("inkscape:snap-to-guides", true), + AttributeInfo("inkscape:srcNoMarkup", true), + AttributeInfo("inkscape:srcPango", true), + AttributeInfo("inkscape:transform-center-x", true), + AttributeInfo("inkscape:transform-center-y", true), + AttributeInfo("inkscape:version", true), + AttributeInfo("inkscape:vp_x", true), + AttributeInfo("inkscape:vp_y", true), + AttributeInfo("inkscape:vp_z", true), + AttributeInfo("inkscape:window-height", true), + AttributeInfo("inkscape:window-maximized", true), + AttributeInfo("inkscape:window-width", true), + AttributeInfo("inkscape:window-x", true), + AttributeInfo("inkscape:window-y", true), + AttributeInfo("inkscape:zoom", true), + AttributeInfo("osb:paint", true), + AttributeInfo("sodipodi:arg1", true), + AttributeInfo("sodipodi:arg2", true), + AttributeInfo("sodipodi:argument", true), + AttributeInfo("sodipodi:cx", true), + AttributeInfo("sodipodi:cy", true), + AttributeInfo("sodipodi:end", true), + AttributeInfo("sodipodi:expansion", true), + AttributeInfo("sodipodi:insensitive", true), + AttributeInfo("sodipodi:linespacing", true), + AttributeInfo("sodipodi:nonprintable", true), + AttributeInfo("sodipodi:open", true), + AttributeInfo("sodipodi:original", true), + AttributeInfo("sodipodi:r1", true), + AttributeInfo("sodipodi:r2", true), + AttributeInfo("sodipodi:radius", true), + AttributeInfo("sodipodi:revolution", true), + AttributeInfo("sodipodi:role", true), + AttributeInfo("sodipodi:rx", true), + AttributeInfo("sodipodi:ry", true), + AttributeInfo("sodipodi:sides", true), + AttributeInfo("sodipodi:start", true), + AttributeInfo("sodipodi:t0", true), + AttributeInfo("sodipodi:version", false), + + // SPMeshPatch + AttributeInfo("tensor", true), + + // SPNamedView + AttributeInfo("fit-margin-top", true), + AttributeInfo("fit-margin-left", true), + AttributeInfo("fit-margin-right", true), + AttributeInfo("fit-margin-bottom", true), + AttributeInfo("units", true), + AttributeInfo("viewonly", true), + AttributeInfo("showgrid", true), +// AttributeInfo("gridtype", true), + AttributeInfo("showguides", true), + AttributeInfo("gridtolerance", true), + AttributeInfo("guidetolerance", true), + AttributeInfo("objecttolerance", true), +/* AttributeInfo("gridoriginx", true), + AttributeInfo("gridoriginy", true), + AttributeInfo("gridspacingx", true), + AttributeInfo("gridspacingy", true), + AttributeInfo("gridanglex", true), + AttributeInfo("gridanglez", true), + AttributeInfo("gridcolor", true), + AttributeInfo("gridopacity", true), + AttributeInfo("gridempcolor", true), + AttributeInfo("gridempopacity", true), + AttributeInfo("gridempspacing", true), */ + AttributeInfo("guidecolor", true), + AttributeInfo("guideopacity", true), + AttributeInfo("guidehicolor", true), + AttributeInfo("guidehiopacity", true), + AttributeInfo("showborder", true), + AttributeInfo("inkscape:showpageshadow", true), + AttributeInfo("borderlayer", true), + AttributeInfo("bordercolor", true), + AttributeInfo("borderopacity", true), + AttributeInfo("pagecolor", true), + + // SPGuide + AttributeInfo("position", true) + }; + + size_t count = sizeof(all_attrs) / sizeof(all_attrs[0]); + std::vector<AttributeInfo> vect(all_attrs, all_attrs + count); + EXPECT_GT(vect.size(), size_t(100)); // should be more than + return vect; +} + +/** + * Returns a vector with counts for all IDs up to the highest known value. + * + * The index is the ID, and the value is the number of times that ID is seen. + */ +std::vector<size_t> getIdIds() +{ + std::vector<size_t> ids; + std::vector<AttributeInfo> all_attrs = getKnownAttrs(); + ids.reserve(all_attrs.size()); // minimize memory thrashing + for (AttrItr it(all_attrs.begin()); it != all_attrs.end(); ++it) { + unsigned int id = sp_attribute_lookup(it->attr.c_str()); + if (id >= ids.size()) { + ids.resize(id + 1); + } + ids[id]++; + } + + return ids; +} + +// Ensure 'supported' value for each known attribute is correct. +TEST(AttributesTest, SupportedKnown) +{ + std::vector<AttributeInfo> all_attrs = getKnownAttrs(); + for (AttrItr it(all_attrs.begin()); it != all_attrs.end(); ++it) { + unsigned int id = sp_attribute_lookup(it->attr.c_str()); + EXPECT_EQ(it->supported, id != 0u) << "Matching for attribute '" << it->attr << "'"; + } +} + +// Ensure names of known attributes are preserved when converted to id and back. +TEST(AttributesTest, NameRoundTrip) +{ + std::vector<AttributeInfo> all_attrs = getKnownAttrs(); + for (AttrItr it(all_attrs.begin()); it != all_attrs.end(); ++it) { + if (it->supported) { + unsigned int id = sp_attribute_lookup(it->attr.c_str()); + char const *redoneName = reinterpret_cast<char const *>(sp_attribute_name(id)); + EXPECT_TRUE(redoneName != NULL) << "For attribute '" << it->attr << "'"; + if (redoneName) { + EXPECT_EQ(it->attr, redoneName); + } + } + } +} + +/* Test for any attributes that this test program doesn't know about. + * + * If any are found, then: + * + * If it is in the `inkscape:' namespace then simply add it to all_attrs with + * `true' as the second field (`supported'). + * + * If it is in the `sodipodi:' namespace then check the spelling against sodipodi + * sources. If you don't have sodipodi sources, then don't add it: leave to someone + * else. + * + * Otherwise, it's probably a bug: ~all SVG 1.1 attributes should already be + * in the all_attrs table. However, the comment above all_attrs does mention + * some things missing from attindex.html, so there may be more. Check the SVG + * spec. Another possibility is that the attribute is new in SVG 1.2. In this case, + * check the spelling against the [draft] SVG 1.2 spec before adding to all_attrs. + * (If you can't be bothered checking the spec, then don't update all_attrs.) + * + * If the attribute isn't in either SVG 1.1 or 1.2 then it's probably a mistake + * for it not to be in the inkscape namespace. (Not sure about attributes used only + * on elements in the inkscape namespace though.) + * + * In any case, make sure that the attribute's source is documented accordingly. + */ +TEST(AttributesTest, ValuesAreKnown) +{ + std::vector<size_t> ids = getIdIds(); + for (size_t i = FIRST_VALID_ID; i < ids.size(); ++i) { + if (!ids[i]) { + unsigned char const *name = sp_attribute_name(i); + EXPECT_TRUE(ids[i] > 0) << "Attribute string with enum " << i << " {" << name << "} not handled"; + } + } +} + +// Ensure two different names aren't mapped to the same enum value. +TEST(AttributesTest, ValuesUnique) +{ + std::vector<size_t> ids = getIdIds(); + for (size_t i = FIRST_VALID_ID; i < ids.size(); ++i) { + EXPECT_LE(ids[i], size_t(1)) << "Attribute enum " << i << " used for multiple strings" + << " including {" << sp_attribute_name(i) << "}"; + } +} + +} // namespace + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/test/src/color-profile-test.cpp b/test/src/color-profile-test.cpp new file mode 100644 index 000000000..365be687a --- /dev/null +++ b/test/src/color-profile-test.cpp @@ -0,0 +1,126 @@ +/* + * Unit tests for color profile. + * + * Author: + * Jon A. Cruz <jon@joncruz.org> + * + * Copyright (C) 2015 Authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "gtest/gtest.h" + +#include "attributes.h" +#include "cms-system.h" +#include "color-profile.h" +#include "doc-per-case-test.h" + +namespace { + +/** + * Test fixture to inherit a shared doc and create a color profile instance per test. + */ +class ProfTest : public DocPerCaseTest +{ +public: + ProfTest() : + DocPerCaseTest(), + _prof(0) + { + } + +protected: + virtual void SetUp() + { + DocPerCaseTest::SetUp(); + _prof = new Inkscape::ColorProfile(); + ASSERT_TRUE( _prof != NULL ); + _prof->document = _doc; + } + + virtual void TearDown() + { + if (_prof) { + delete _prof; + _prof = NULL; + } + DocPerCaseTest::TearDown(); + } + + Inkscape::ColorProfile *_prof; +}; + +typedef ProfTest ColorProfileTest; + +TEST_F(ColorProfileTest, SetRenderingIntent) +{ + struct { + gchar const *attr; + guint intVal; + } + const cases[] = { + {"auto", (guint)Inkscape::RENDERING_INTENT_AUTO}, + {"perceptual", (guint)Inkscape::RENDERING_INTENT_PERCEPTUAL}, + {"relative-colorimetric", (guint)Inkscape::RENDERING_INTENT_RELATIVE_COLORIMETRIC}, + {"saturation", (guint)Inkscape::RENDERING_INTENT_SATURATION}, + {"absolute-colorimetric", (guint)Inkscape::RENDERING_INTENT_ABSOLUTE_COLORIMETRIC}, + {"something-else", (guint)Inkscape::RENDERING_INTENT_UNKNOWN}, + {"auto2", (guint)Inkscape::RENDERING_INTENT_UNKNOWN}, + }; + + for ( size_t i = 0; i < G_N_ELEMENTS( cases ); i++ ) { + _prof->setKeyValue( SP_ATTR_RENDERING_INTENT, cases[i].attr); + ASSERT_EQ( (guint)cases[i].intVal, _prof->rendering_intent ) << cases[i].attr; + } +} + +TEST_F(ColorProfileTest, SetLocal) +{ + gchar const* cases[] = { + "local", + "something", + }; + + for ( size_t i = 0; i < G_N_ELEMENTS( cases ); i++ ) { + _prof->setKeyValue( SP_ATTR_LOCAL, cases[i]); + ASSERT_TRUE( _prof->local != NULL ); + if ( _prof->local ) { + ASSERT_EQ( std::string(cases[i]), _prof->local ); + } + } + _prof->setKeyValue( SP_ATTR_LOCAL, NULL); + ASSERT_EQ( (gchar*)0, _prof->local ); +} + +TEST_F(ColorProfileTest, SetName) +{ + gchar const* cases[] = { + "name", + "something", + }; + + for ( size_t i = 0; i < G_N_ELEMENTS( cases ); i++ ) { + _prof->setKeyValue( SP_ATTR_NAME, cases[i]); + ASSERT_TRUE( _prof->name != NULL ); + if ( _prof->name ) { + ASSERT_EQ( std::string(cases[i]), _prof->name ); + } + } + _prof->setKeyValue( SP_ATTR_NAME, NULL ); + ASSERT_EQ( (gchar*)0, _prof->name ); +} + + +} // namespace + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/test/src/dir-util-test.cpp b/test/src/dir-util-test.cpp new file mode 100644 index 000000000..32b3fce74 --- /dev/null +++ b/test/src/dir-util-test.cpp @@ -0,0 +1,63 @@ +/* + * Unit tests for dir utils. + * + * Author: + * Jon A. Cruz <jon@joncruz.org> + * + * Copyright (C) 2015 Authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "gtest/gtest.h" + +#include <glib.h> + +#include "dir-util.h" + +namespace { + + +TEST(DirUtilTest, Base) +{ + char const* cases[][3] = { +#if defined(WIN32) || defined(__WIN32__) + {"\\foo\\bar", "\\foo", "bar"}, + {"\\foo\\barney", "\\foo\\bar", "\\foo\\barney"}, + {"\\foo\\bar\\baz", "\\foo\\", "bar\\baz"}, + {"\\foo\\bar\\baz", "\\", "foo\\bar\\baz"}, + {"\\foo\\bar\\baz", "\\foo\\qux", "\\foo\\bar\\baz"}, +#else + {"/foo/bar", "/foo", "bar"}, + {"/foo/barney", "/foo/bar", "/foo/barney"}, + {"/foo/bar/baz", "/foo/", "bar/baz"}, + {"/foo/bar/baz", "/", "foo/bar/baz"}, + {"/foo/bar/baz", "/foo/qux", "/foo/bar/baz"}, +#endif + }; + + for ( size_t i = 0; i < G_N_ELEMENTS(cases); i++ ) + { + if ( cases[i][0] && cases[i][1] ) { // std::string can't use null. + std::string result = sp_relative_path_from_path( cases[i][0], cases[i][1] ); + ASSERT_FALSE( result.empty() ); + if ( !result.empty() ) + { + ASSERT_EQ( std::string(cases[i][2]), result ); + } + } + } +} + +} // namespace + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/test/unittest.cpp b/test/unittest.cpp new file mode 100644 index 000000000..0ec8f0383 --- /dev/null +++ b/test/unittest.cpp @@ -0,0 +1,58 @@ +/* + * Unit test main. + * + * Author: + * Jon A. Cruz <jon@joncruz.org> + * + * Copyright (C) 2015 Authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "gtest/gtest.h" + +#include <gtkmm.h> + +#include "inkgc/gc-core.h" +#include "inkscape.h" + +namespace { + +// Ensure that a known positive test works +TEST(PreTest, WorldIsSane) +{ + EXPECT_EQ(4, 2 + 2); +} + +// Example of type casting to avoid compile warnings. + + +} // namespace + +int main(int argc, char **argv) { + + // setup general environment +#if !GLIB_CHECK_VERSION(2,36,0) + g_type_init(); +#endif + int tmpArgc = 1; + char const *tmp[] = {"foo", ""}; + char **tmpArgv = const_cast<char **>(tmp); + Gtk::Main(tmpArgc, tmpArgv); + + Inkscape::GC::init(); + + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : |
