From 2f6f66fc8e4c21d0bd9f3d8dc15197fb945727c0 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Thu, 9 Jun 2016 08:42:03 +0100 Subject: Rename test->testfiles folder to avoid naming conflict (bzr r14967.1.1) --- CMakeLists.txt | 4 +- test/CMakeLists.txt | 67 ---- test/doc-per-case-test.cpp | 52 --- test/doc-per-case-test.h | 43 --- test/src/attributes-test.cpp | 633 ----------------------------------- test/src/color-profile-test.cpp | 126 ------- test/src/dir-util-test.cpp | 63 ---- test/unittest.cpp | 58 ---- testfiles/CMakeLists.txt | 67 ++++ testfiles/doc-per-case-test.cpp | 52 +++ testfiles/doc-per-case-test.h | 43 +++ testfiles/src/attributes-test.cpp | 633 +++++++++++++++++++++++++++++++++++ testfiles/src/color-profile-test.cpp | 126 +++++++ testfiles/src/dir-util-test.cpp | 63 ++++ testfiles/unittest.cpp | 58 ++++ 15 files changed, 1044 insertions(+), 1044 deletions(-) delete mode 100644 test/CMakeLists.txt delete mode 100644 test/doc-per-case-test.cpp delete mode 100644 test/doc-per-case-test.h delete mode 100644 test/src/attributes-test.cpp delete mode 100644 test/src/color-profile-test.cpp delete mode 100644 test/src/dir-util-test.cpp delete mode 100644 test/unittest.cpp create mode 100644 testfiles/CMakeLists.txt create mode 100644 testfiles/doc-per-case-test.cpp create mode 100644 testfiles/doc-per-case-test.h create mode 100644 testfiles/src/attributes-test.cpp create mode 100644 testfiles/src/color-profile-test.cpp create mode 100644 testfiles/src/dir-util-test.cpp create mode 100644 testfiles/unittest.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 91a090371..5f3d1aac0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -211,11 +211,11 @@ add_custom_target(clean-all #----------------------------------------------------------------------------- -add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}) +#add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}) if(WITH_GTEST) enable_testing() - add_subdirectory(test EXCLUDE_FROM_ALL) + add_subdirectory(testfiles EXCLUDE_FROM_ALL) endif() # Canonicalize the flags to speed up recompilation using ccache/etc. diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt deleted file mode 100644 index 8da39d627..000000000 --- a/test/CMakeLists.txt +++ /dev/null @@ -1,67 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# ----------------------------------------------------------------------------- - -set(CMAKE_CTEST_COMMAND ctest -V) - -add_subdirectory(${GMOCK_DIR} ${CMAKE_BINARY_DIR}/gmock) - -include_directories(SYSTEM ${GMOCK_DIR}/gtest/include - ${GMOCK_DIR}/include - ${CMAKE_SOURCE_DIR}/gtest/gtest/include) - -set_source_files_properties( - ${CMAKE_BINARY_DIR}/src/inkscape-version.cpp - PROPERTIES GENERATED TRUE) - -# include_directories(${CMAKE_CURRENT_BINARY_DIR}/__/src) -include_directories(${CMAKE_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 -) - -target_link_libraries(unittest inkscape_base) - -add_dependencies(unittest inkscape_version) - -set (_optional_unittest_libs ) - -if (NOT "${WITH_EXT_GDL}") - list (APPEND _optional_unittest_libs "gdl_LIB") -endif() - -target_link_libraries(unittest - gmock_main - - # order from automake - #sp_LIB - - #inkscape_LIB - #sp_LIB # annoying, we need both! - nrtype_LIB # annoying, we need both! - - croco_LIB - avoid_LIB - ${_optional_unittest_libs} - 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 deleted file mode 100644 index da75b1e65..000000000 --- a/test/doc-per-case-test.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Test fixture with SPDocument per entire test case. - * - * Author: - * Jon A. Cruz - * - * 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 deleted file mode 100644 index b6f01403a..000000000 --- a/test/doc-per-case-test.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Test fixture with SPDocument per entire test case. - * - * Author: - * Jon A. Cruz - * - * 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 deleted file mode 100644 index 41c0274ec..000000000 --- a/test/src/attributes-test.cpp +++ /dev/null @@ -1,633 +0,0 @@ -/* - * Unit tests for attributes. - * - * Author: - * Jon A. Cruz - * - * Copyright (C) 2015 Authors - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include -#include - -#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::iterator AttrItr; - -std::vector 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,,@,g' | - tr @ \\n | - sed 's,.*,,;s,^,,;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("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-feature-settings", true), - AttributeInfo("font-size", true), - AttributeInfo("font-size-adjust", true), - AttributeInfo("font-stretch", true), - AttributeInfo("font-style", true), - AttributeInfo("font-variant", true), - AttributeInfo("font-variant-ligatures", true), - AttributeInfo("font-variant-position", true), - AttributeInfo("font-variant-caps", true), - AttributeInfo("font-variant-numeric", true), - AttributeInfo("font-variant-east-asian", true), - AttributeInfo("font-variant-alternates", true), - AttributeInfo("font-weight", true), - AttributeInfo("format", false), - AttributeInfo("from", true), - AttributeInfo("fx", true), - AttributeInfo("fr", 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-fill", true), - AttributeInfo("text-decoration-line", true), - AttributeInfo("text-decoration-stroke", true), - AttributeInfo("text-decoration-style", true), - AttributeInfo("text-indent", true), - AttributeInfo("text-orientation", 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:color", 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:lockguides", true), - AttributeInfo("inkscape:locked", true), - AttributeInfo("inkscape:object-nodes", true), - AttributeInfo("inkscape:object-paths", true), - AttributeInfo("inkscape:original", true), - AttributeInfo("inkscape:original-d", true), - AttributeInfo("inkscape:pagecheckerboard", 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:spray-origin", 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 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 getIdIds() -{ - std::vector ids; - std::vector 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 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 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(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 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 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 deleted file mode 100644 index 365be687a..000000000 --- a/test/src/color-profile-test.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Unit tests for color profile. - * - * Author: - * Jon A. Cruz - * - * 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 deleted file mode 100644 index 32b3fce74..000000000 --- a/test/src/dir-util-test.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Unit tests for dir utils. - * - * Author: - * Jon A. Cruz - * - * Copyright (C) 2015 Authors - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include "gtest/gtest.h" - -#include - -#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 deleted file mode 100644 index 0ec8f0383..000000000 --- a/test/unittest.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Unit test main. - * - * Author: - * Jon A. Cruz - * - * Copyright (C) 2015 Authors - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include "gtest/gtest.h" - -#include - -#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(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 : diff --git a/testfiles/CMakeLists.txt b/testfiles/CMakeLists.txt new file mode 100644 index 000000000..8da39d627 --- /dev/null +++ b/testfiles/CMakeLists.txt @@ -0,0 +1,67 @@ +# ----------------------------------------------------------------------------- +# +# ----------------------------------------------------------------------------- + +set(CMAKE_CTEST_COMMAND ctest -V) + +add_subdirectory(${GMOCK_DIR} ${CMAKE_BINARY_DIR}/gmock) + +include_directories(SYSTEM ${GMOCK_DIR}/gtest/include + ${GMOCK_DIR}/include + ${CMAKE_SOURCE_DIR}/gtest/gtest/include) + +set_source_files_properties( + ${CMAKE_BINARY_DIR}/src/inkscape-version.cpp + PROPERTIES GENERATED TRUE) + +# include_directories(${CMAKE_CURRENT_BINARY_DIR}/__/src) +include_directories(${CMAKE_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 +) + +target_link_libraries(unittest inkscape_base) + +add_dependencies(unittest inkscape_version) + +set (_optional_unittest_libs ) + +if (NOT "${WITH_EXT_GDL}") + list (APPEND _optional_unittest_libs "gdl_LIB") +endif() + +target_link_libraries(unittest + gmock_main + + # order from automake + #sp_LIB + + #inkscape_LIB + #sp_LIB # annoying, we need both! + nrtype_LIB # annoying, we need both! + + croco_LIB + avoid_LIB + ${_optional_unittest_libs} + 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/testfiles/doc-per-case-test.cpp b/testfiles/doc-per-case-test.cpp new file mode 100644 index 000000000..da75b1e65 --- /dev/null +++ b/testfiles/doc-per-case-test.cpp @@ -0,0 +1,52 @@ +/* + * Test fixture with SPDocument per entire test case. + * + * Author: + * Jon A. Cruz + * + * 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/testfiles/doc-per-case-test.h b/testfiles/doc-per-case-test.h new file mode 100644 index 000000000..b6f01403a --- /dev/null +++ b/testfiles/doc-per-case-test.h @@ -0,0 +1,43 @@ +/* + * Test fixture with SPDocument per entire test case. + * + * Author: + * Jon A. Cruz + * + * 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/testfiles/src/attributes-test.cpp b/testfiles/src/attributes-test.cpp new file mode 100644 index 000000000..41c0274ec --- /dev/null +++ b/testfiles/src/attributes-test.cpp @@ -0,0 +1,633 @@ +/* + * Unit tests for attributes. + * + * Author: + * Jon A. Cruz + * + * Copyright (C) 2015 Authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include +#include + +#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::iterator AttrItr; + +std::vector 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,,@,g' | + tr @ \\n | + sed 's,.*,,;s,^,,;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("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-feature-settings", true), + AttributeInfo("font-size", true), + AttributeInfo("font-size-adjust", true), + AttributeInfo("font-stretch", true), + AttributeInfo("font-style", true), + AttributeInfo("font-variant", true), + AttributeInfo("font-variant-ligatures", true), + AttributeInfo("font-variant-position", true), + AttributeInfo("font-variant-caps", true), + AttributeInfo("font-variant-numeric", true), + AttributeInfo("font-variant-east-asian", true), + AttributeInfo("font-variant-alternates", true), + AttributeInfo("font-weight", true), + AttributeInfo("format", false), + AttributeInfo("from", true), + AttributeInfo("fx", true), + AttributeInfo("fr", 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-fill", true), + AttributeInfo("text-decoration-line", true), + AttributeInfo("text-decoration-stroke", true), + AttributeInfo("text-decoration-style", true), + AttributeInfo("text-indent", true), + AttributeInfo("text-orientation", 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:color", 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:lockguides", true), + AttributeInfo("inkscape:locked", true), + AttributeInfo("inkscape:object-nodes", true), + AttributeInfo("inkscape:object-paths", true), + AttributeInfo("inkscape:original", true), + AttributeInfo("inkscape:original-d", true), + AttributeInfo("inkscape:pagecheckerboard", 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:spray-origin", 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 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 getIdIds() +{ + std::vector ids; + std::vector 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 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 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(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 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 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/testfiles/src/color-profile-test.cpp b/testfiles/src/color-profile-test.cpp new file mode 100644 index 000000000..365be687a --- /dev/null +++ b/testfiles/src/color-profile-test.cpp @@ -0,0 +1,126 @@ +/* + * Unit tests for color profile. + * + * Author: + * Jon A. Cruz + * + * 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/testfiles/src/dir-util-test.cpp b/testfiles/src/dir-util-test.cpp new file mode 100644 index 000000000..32b3fce74 --- /dev/null +++ b/testfiles/src/dir-util-test.cpp @@ -0,0 +1,63 @@ +/* + * Unit tests for dir utils. + * + * Author: + * Jon A. Cruz + * + * Copyright (C) 2015 Authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "gtest/gtest.h" + +#include + +#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/testfiles/unittest.cpp b/testfiles/unittest.cpp new file mode 100644 index 000000000..0ec8f0383 --- /dev/null +++ b/testfiles/unittest.cpp @@ -0,0 +1,58 @@ +/* + * Unit test main. + * + * Author: + * Jon A. Cruz + * + * Copyright (C) 2015 Authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "gtest/gtest.h" + +#include + +#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(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 : -- cgit v1.2.3