From: jaspervdg Date: Fri, 8 Aug 2008 14:18:02 +0000 (+0000) Subject: Fixed svg-path (and display/curve) tests to properly handle closepath and made a... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=fe9eeff08e8901ae06ce3b24392a2ce3ec57c131;p=inkscape.git Fixed svg-path (and display/curve) tests to properly handle closepath and made a check target. --- diff --git a/buildtool.cpp b/buildtool.cpp index 3a3f2ff65..1de8d68bc 100644 --- a/buildtool.cpp +++ b/buildtool.cpp @@ -2765,6 +2765,75 @@ static void removeFromStatCache(const String f) { statCache.erase(f); } +//######################################################################## +//# Dir cache to speed up dir requests +//######################################################################## +/*struct DirListing { + bool available; + std::vector files; + std::vector dirs; +}; +typedef std::map dirCacheType; +static dirCacheType dirCache; +static const DirListing &cachedDir(String fullDir) +{ + String dirNative = getNativePath(fullDir); + std::pair result = dirCache.insert(dirCacheType::value_type(dirNative, DirListing())); + if (result.second) { + DIR *dir = opendir(dirNative.c_str()); + if (!dir) + { + error("Could not open directory %s : %s", + dirNative.c_str(), strerror(errno)); + result.first->second.available = false; + } + else + { + result.first->second.available = true; + while (true) + { + struct dirent *de = readdir(dir); + if (!de) + break; + + //Get the directory member name + String s = de->d_name; + if (s.size() == 0 || s[0] == '.') + continue; + String childName; + if (dirName.size()>0) + { + childName.append(dirName); + childName.append("/"); + } + childName.append(s); + String fullChild = baseDir; + fullChild.append("/"); + fullChild.append(childName); + + if (isDirectory(fullChild)) + { + //trace("directory: %s", childName.c_str()); + if (!listFiles(baseDir, childName, res)) + return false; + continue; + } + else if (!isRegularFile(fullChild)) + { + error("unknown file:%s", childName.c_str()); + return false; + } + + //all done! + res.push_back(childName); + + } + closedir(dir); + } + } + return result.first->second; +}*/ + //######################################################################## //# F I L E S E T //######################################################################## @@ -3962,13 +4031,18 @@ bool MakeBase::executeCommand(const String &command, return false; } SetHandleInformation(stdoutRead, HANDLE_FLAG_INHERIT, 0); - if (!CreatePipe(&stderrRead, &stderrWrite, &saAttr, 0)) - { - error("executeProgram: could not create pipe"); - delete[] paramBuf; - return false; - } - SetHandleInformation(stderrRead, HANDLE_FLAG_INHERIT, 0); + if (&outbuf != &errbuf) { + if (!CreatePipe(&stderrRead, &stderrWrite, &saAttr, 0)) + { + error("executeProgram: could not create pipe"); + delete[] paramBuf; + return false; + } + SetHandleInformation(stderrRead, HANDLE_FLAG_INHERIT, 0); + } else { + stderrRead = stdoutRead; + stderrWrite = stdoutWrite; + } // Create the process STARTUPINFO siStartupInfo; @@ -4010,7 +4084,7 @@ bool MakeBase::executeCommand(const String &command, error("executeCommand: could not close read pipe"); return false; } - if (!CloseHandle(stderrWrite)) + if (stdoutWrite != stderrWrite && !CloseHandle(stderrWrite)) { error("executeCommand: could not close read pipe"); return false; @@ -4068,7 +4142,7 @@ bool MakeBase::executeCommand(const String &command, error("executeCommand: could not close read pipe"); return false; } - if (!CloseHandle(stderrRead)) + if (stdoutRead != stderrRead && !CloseHandle(stderrRead)) { error("executeCommand: could not close read pipe"); return false; @@ -6490,6 +6564,7 @@ public: TASK_COPY, TASK_CXXTEST_PART, TASK_CXXTEST_ROOT, + TASK_CXXTEST_RUN, TASK_DELETE, TASK_ECHO, TASK_JAR, @@ -7401,6 +7476,97 @@ private: }; +/** + * Execute the CxxTest test executable + */ +class TaskCxxTestRun: public Task +{ +public: + + TaskCxxTestRun(MakeBase &par) : Task(par) + { + type = TASK_CXXTEST_RUN; + name = "cxxtestrun"; + } + + virtual ~TaskCxxTestRun() + {} + + virtual bool execute() + { + unsigned int newFiles = 0; + + String workingDir = parent.resolve(parent.eval(workingDirOpt, "inkscape")); + String rawCmd = parent.eval(commandOpt, "build/cxxtests"); + + String cmdExe; + if (fileExists(rawCmd)) { + cmdExe = rawCmd; + } else if (fileExists(rawCmd + ".exe")) { + cmdExe = rawCmd + ".exe"; + } else { + error(" problem: cxxtests executable not found! (command=\"%s\")", rawCmd.c_str()); + } + // Note that the log file names are based on the exact name used to call cxxtests (it uses argv[0] + ".log"/".xml") + if (isNewerThan(cmdExe, rawCmd + ".log") || isNewerThan(cmdExe, rawCmd + ".xml")) newFiles++; + + // Prepend the necessary ../'s + String cmd = rawCmd; + unsigned int workingDirDepth = 0; + bool wasSlash = true; + for(size_t i=0; i0) { + char olddir[1024]; + if (workingDir.size()>0) { + // TODO: Double-check usage of getcwd and handle chdir errors + getcwd(olddir, 1024); + chdir(workingDir.c_str()); + } + + String outString; + if (!executeCommand(cmd.c_str(), "", outString, outString)) + { + error(" problem: %s", outString.c_str()); + return false; + } + + if (workingDir.size()>0) { + // TODO: Handle errors? + chdir(olddir); + } + + removeFromStatCache(getNativePath(cmd + ".log")); + removeFromStatCache(getNativePath(cmd + ".xml")); + } + + return true; + } + + virtual bool parse(Element *elem) + { + if (!parent.getAttribute(elem, "command", commandOpt)) + return false; + if (!parent.getAttribute(elem, "workingdir", workingDirOpt)) + return false; + return true; + } + +private: + + String commandOpt; + String workingDirOpt; + +}; + + /** * */ @@ -8801,6 +8967,8 @@ Task *Task::createTask(Element *elem, int lineNr) task = new TaskCxxTestPart(parent); else if (tagName == "cxxtestroot") task = new TaskCxxTestRoot(parent); + else if (tagName == "cxxtestrun") + task = new TaskCxxTestRun(parent); else if (tagName == "delete") task = new TaskDelete(parent); else if (tagName == "echo") diff --git a/src/display/curve-test.h b/src/display/curve-test.h index cca77e063..a45f01afd 100644 --- a/src/display/curve-test.h +++ b/src/display/curve-test.h @@ -15,11 +15,11 @@ private: public: CurveTest() : path4(Geom::Point(3,5)) // Just a moveto { - // Closed path which needs a closing segment + // Closed path path1.append(Geom::HLineSegment(Geom::Point(0,0),1)); path1.append(Geom::VLineSegment(Geom::Point(1,0),1)); path1.close(); - // Closed path that doesn't need a closing segment + // Closed path (ClosingSegment is zero length) path2.append(Geom::LineSegment(Geom::Point(2,0),Geom::Point(3,0))); path2.append(Geom::BezierCurve<3>(Geom::Point(3,0),Geom::Point(2,1),Geom::Point(1,1),Geom::Point(2,0))); path2.close(); @@ -53,11 +53,13 @@ public: pv[0] = path1; TS_ASSERT_EQUALS(SPCurve(pv).get_segment_count() , 3u); pv[0] = path2; - TS_ASSERT_EQUALS(SPCurve(pv).get_segment_count() , 2u); + TS_ASSERT_EQUALS(SPCurve(pv).get_segment_count() , 3u); pv[0] = path3; TS_ASSERT_EQUALS(SPCurve(pv).get_segment_count() , 4u); pv[0] = path4; TS_ASSERT_EQUALS(SPCurve(pv).get_segment_count() , 0u); + pv[0].close(); + TS_ASSERT_EQUALS(SPCurve(pv).get_segment_count() , 1u); } { // Combination Geom::PathVector pv; @@ -66,7 +68,7 @@ public: pv.push_back(path3); pv.push_back(path4); SPCurve curve(pv); - TS_ASSERT_EQUALS(curve.get_segment_count() , 9u); + TS_ASSERT_EQUALS(curve.get_segment_count() , 10u); } } @@ -88,11 +90,13 @@ public: pv[0] = path1; TS_ASSERT_EQUALS(SPCurve(pv).nodes_in_path() , 3u); pv[0] = path2; - TS_ASSERT_EQUALS(SPCurve(pv).nodes_in_path() , 2u); + TS_ASSERT_EQUALS(SPCurve(pv).nodes_in_path() , 3u); pv[0] = path3; TS_ASSERT_EQUALS(SPCurve(pv).nodes_in_path() , 5u); pv[0] = path4; TS_ASSERT_EQUALS(SPCurve(pv).nodes_in_path() , 1u); + pv[0].close(); + TS_ASSERT_EQUALS(SPCurve(pv).nodes_in_path() , 1u); } { // Combination Geom::PathVector pv; @@ -101,7 +105,7 @@ public: pv.push_back(path3); pv.push_back(path4); SPCurve curve(pv); - TS_ASSERT_EQUALS(curve.nodes_in_path() , 11u); + TS_ASSERT_EQUALS(curve.nodes_in_path() , 12u); } } diff --git a/src/svg/svg-path-geom-test.h b/src/svg/svg-path-geom-test.h index 1bcc5fb17..32a2ed231 100644 --- a/src/svg/svg-path-geom-test.h +++ b/src/svg/svg-path-geom-test.h @@ -17,11 +17,14 @@ private: std::vector rectanglesRelativeClosed; std::vector rectanglesAbsoluteOpen; std::vector rectanglesRelativeOpen; - Geom::PathVector rectanglepv; + std::vector rectanglesAbsoluteClosed2; + std::vector rectanglesRelativeClosed2; + Geom::PathVector rectanglepvopen; + Geom::PathVector rectanglepvclosed; + Geom::PathVector rectanglepvclosed2; public: SvgPathGeomTest() { // Lots of ways to define the same rectangle - rectanglesAbsoluteClosed.push_back("M 1,2 L 4,2 L 4,8 L 1,8 L 1,2 Z"); rectanglesAbsoluteClosed.push_back("M 1,2 L 4,2 L 4,8 L 1,8 z"); rectanglesAbsoluteClosed.push_back("M 1,2 4,2 4,8 1,8 z"); rectanglesAbsoluteClosed.push_back("M 1,2 H 4 V 8 H 1 z"); @@ -34,12 +37,31 @@ public: rectanglesRelativeOpen.push_back("m 1,2 l 3,0 l 0,6 l -3,0 l 0,-6"); rectanglesRelativeOpen.push_back("m 1,2 3,0 0,6 -3,0 0,-6"); rectanglesRelativeOpen.push_back("m 1,2 h 3 v 6 h -3 v -6"); - rectanglepv.push_back(Geom::Path(Geom::Point(1,2))); - rectanglepv.back().append(Geom::LineSegment(Geom::Point(1,2),Geom::Point(4,2))); - rectanglepv.back().append(Geom::LineSegment(Geom::Point(4,2),Geom::Point(4,8))); - rectanglepv.back().append(Geom::LineSegment(Geom::Point(4,8),Geom::Point(1,8))); - rectanglepv.back().append(Geom::LineSegment(Geom::Point(1,8),Geom::Point(1,2))); + rectanglesAbsoluteClosed2.push_back("M 1,2 L 4,2 L 4,8 L 1,8 L 1,2 z"); + rectanglesAbsoluteClosed2.push_back("M 1,2 4,2 4,8 1,8 1,2 z"); + rectanglesAbsoluteClosed2.push_back("M 1,2 H 4 V 8 H 1 V 2 z"); + rectanglesRelativeClosed2.push_back("m 1,2 l 3,0 l 0,6 l -3,0 l 0,-6 z"); + rectanglesRelativeClosed2.push_back("m 1,2 3,0 0,6 -3,0 0,-6 z"); + rectanglesRelativeClosed2.push_back("m 1,2 h 3 v 6 h -3 v -6 z"); + rectanglepvopen.push_back(Geom::Path(Geom::Point(1,2))); + rectanglepvopen.back().append(Geom::LineSegment(Geom::Point(1,2),Geom::Point(4,2))); + rectanglepvopen.back().append(Geom::LineSegment(Geom::Point(4,2),Geom::Point(4,8))); + rectanglepvopen.back().append(Geom::LineSegment(Geom::Point(4,8),Geom::Point(1,8))); + rectanglepvopen.back().append(Geom::LineSegment(Geom::Point(1,8),Geom::Point(1,2))); + rectanglepvclosed.push_back(Geom::Path(Geom::Point(1,2))); + rectanglepvclosed.back().append(Geom::LineSegment(Geom::Point(1,2),Geom::Point(4,2))); + rectanglepvclosed.back().append(Geom::LineSegment(Geom::Point(4,2),Geom::Point(4,8))); + rectanglepvclosed.back().append(Geom::LineSegment(Geom::Point(4,8),Geom::Point(1,8))); + rectanglepvclosed.back().close(); + rectanglepvclosed2.push_back(Geom::Path(Geom::Point(1,2))); + rectanglepvclosed2.back().append(Geom::LineSegment(Geom::Point(1,2),Geom::Point(4,2))); + rectanglepvclosed2.back().append(Geom::LineSegment(Geom::Point(4,2),Geom::Point(4,8))); + rectanglepvclosed2.back().append(Geom::LineSegment(Geom::Point(4,8),Geom::Point(1,8))); + rectanglepvclosed2.back().append(Geom::LineSegment(Geom::Point(1,8),Geom::Point(1,2))); + rectanglepvclosed2.back().close(); // TODO: Also test some (smooth) cubic/quadratic beziers and elliptical arcs + // TODO: Should we make it mandatory that h/v in the path data results in a H/VLineSegment? + // If so, the tests should be modified to reflect this. } // createSuite and destroySuite get us per-suite setup and teardown @@ -49,47 +71,60 @@ public: void testReadRectanglesAbsoluteClosed() { - rectanglepv.back().close(); for(size_t i=0; i(cb); if (!Geom::are_near((*la)[0],(*lb)[0], eps)) { char temp[200]; - sprintf(temp, "Different start of segment: (%g,%g) != (%g,%g)", (*la)[0][Geom::X], (*la)[0][Geom::Y], (*lb)[0][Geom::X], (*lb)[0][Geom::Y]); + sprintf(temp, "Different start of segment: (%g,%g) != (%g,%g), subpath: %u, segment: %u", (*la)[0][Geom::X], (*la)[0][Geom::Y], (*lb)[0][Geom::X], (*lb)[0][Geom::Y], i, j); TS_FAIL(temp); return false; } if (!Geom::are_near((*la)[1],(*lb)[1], eps)) { char temp[200]; - sprintf(temp, "Different end of segment: (%g,%g) != (%g,%g)", (*la)[1][Geom::X], (*la)[1][Geom::Y], (*lb)[1][Geom::X], (*lb)[1][Geom::Y]); + sprintf(temp, "Different end of segment: (%g,%g) != (%g,%g), subpath: %u, segment: %u", (*la)[1][Geom::X], (*la)[1][Geom::Y], (*lb)[1][Geom::X], (*lb)[1][Geom::Y], i, j); TS_FAIL(temp); return false; } @@ -414,13 +457,13 @@ private: Geom::HLineSegment const *lb = dynamic_cast(cb); if (!Geom::are_near((*la).initialPoint(),(*lb).initialPoint(), eps)) { char temp[200]; - sprintf(temp, "Different start of segment: (%g,%g) != (%g,%g)", (*la).initialPoint()[Geom::X], (*la).initialPoint()[Geom::Y], (*lb).initialPoint()[Geom::X], (*lb).initialPoint()[Geom::Y]); + sprintf(temp, "Different start of segment: (%g,%g) != (%g,%g), subpath: %u, segment: %u", (*la).initialPoint()[Geom::X], (*la).initialPoint()[Geom::Y], (*lb).initialPoint()[Geom::X], (*lb).initialPoint()[Geom::Y], i, j); TS_FAIL(temp); return false; } if (!Geom::are_near((*la).finalPoint(),(*lb).finalPoint(), eps)) { char temp[200]; - sprintf(temp, "Different end of segment: (%g,%g) != (%g,%g)", (*la).finalPoint()[Geom::X], (*la).finalPoint()[Geom::Y], (*lb).finalPoint()[Geom::X], (*lb).finalPoint()[Geom::Y]); + sprintf(temp, "Different end of segment: (%g,%g) != (%g,%g), subpath: %u, segment: %u", (*la).finalPoint()[Geom::X], (*la).finalPoint()[Geom::Y], (*lb).finalPoint()[Geom::X], (*lb).finalPoint()[Geom::Y], i, j); TS_FAIL(temp); return false; } @@ -430,13 +473,13 @@ private: Geom::VLineSegment const *lb = dynamic_cast(cb); if (!Geom::are_near((*la).initialPoint(),(*lb).initialPoint(), eps)) { char temp[200]; - sprintf(temp, "Different start of segment: (%g,%g) != (%g,%g)", (*la).initialPoint()[Geom::X], (*la).initialPoint()[Geom::Y], (*lb).initialPoint()[Geom::X], (*lb).initialPoint()[Geom::Y]); + sprintf(temp, "Different start of segment: (%g,%g) != (%g,%g), subpath: %u, segment: %u", (*la).initialPoint()[Geom::X], (*la).initialPoint()[Geom::Y], (*lb).initialPoint()[Geom::X], (*lb).initialPoint()[Geom::Y], i, j); TS_FAIL(temp); return false; } if (!Geom::are_near((*la).finalPoint(),(*lb).finalPoint(), eps)) { char temp[200]; - sprintf(temp, "Different end of segment: (%g,%g) != (%g,%g)", (*la).finalPoint()[Geom::X], (*la).finalPoint()[Geom::Y], (*lb).finalPoint()[Geom::X], (*lb).finalPoint()[Geom::Y]); + sprintf(temp, "Different end of segment: (%g,%g) != (%g,%g), subpath: %u, segment: %u", (*la).finalPoint()[Geom::X], (*la).finalPoint()[Geom::Y], (*lb).finalPoint()[Geom::X], (*lb).finalPoint()[Geom::Y], i, j); TS_FAIL(temp); return false; } @@ -446,33 +489,34 @@ private: Geom::CubicBezier const *lb = dynamic_cast(cb); if (!Geom::are_near((*la)[0],(*lb)[0], eps)) { char temp[200]; - sprintf(temp, "Different start of segment: (%g,%g) != (%g,%g)", (*la)[0][Geom::X], (*la)[0][Geom::Y], (*lb)[0][Geom::X], (*lb)[0][Geom::Y]); + sprintf(temp, "Different start of segment: (%g,%g) != (%g,%g), subpath: %u, segment: %u", (*la)[0][Geom::X], (*la)[0][Geom::Y], (*lb)[0][Geom::X], (*lb)[0][Geom::Y], i, j); TS_FAIL(temp); return false; } if (!Geom::are_near((*la)[1],(*lb)[1], eps)) { char temp[200]; - sprintf(temp, "Different 1st control point: (%g,%g) != (%g,%g)", (*la)[1][Geom::X], (*la)[1][Geom::Y], (*lb)[1][Geom::X], (*lb)[1][Geom::Y]); + sprintf(temp, "Different 1st control point: (%g,%g) != (%g,%g), subpath: %u, segment: %u", (*la)[1][Geom::X], (*la)[1][Geom::Y], (*lb)[1][Geom::X], (*lb)[1][Geom::Y], i, j); TS_FAIL(temp); return false; } if (!Geom::are_near((*la)[2],(*lb)[2], eps)) { char temp[200]; - sprintf(temp, "Different 2nd control point: (%g,%g) != (%g,%g)", (*la)[2][Geom::X], (*la)[2][Geom::Y], (*lb)[2][Geom::X], (*lb)[2][Geom::Y]); + sprintf(temp, "Different 2nd control point: (%g,%g) != (%g,%g), subpath: %u, segment: %u", (*la)[2][Geom::X], (*la)[2][Geom::Y], (*lb)[2][Geom::X], (*lb)[2][Geom::Y], i, j); TS_FAIL(temp); return false; } if (!Geom::are_near((*la)[3],(*lb)[3], eps)) { char temp[200]; - sprintf(temp, "Different end of segment: (%g,%g) != (%g,%g)", (*la)[3][Geom::X], (*la)[3][Geom::Y], (*lb)[3][Geom::X], (*lb)[3][Geom::Y]); + sprintf(temp, "Different end of segment: (%g,%g) != (%g,%g), subpath: %u, segment: %u", (*la)[3][Geom::X], (*la)[3][Geom::Y], (*lb)[3][Geom::X], (*lb)[3][Geom::Y], i, j); TS_FAIL(temp); return false; } } else { - TS_FAIL((std::string("Unknown curve type: ") + typeid(*ca).name()).c_str()); - return false; + char temp[200]; + sprintf(temp, "Unknown curve type: %s, subpath: %u, segment: %u", typeid(*ca).name(), i, j); + TS_FAIL(temp); } } else // not same type @@ -482,32 +526,39 @@ private: if (Geom::HLineSegment const *lb = dynamic_cast(cb)) { if (!Geom::are_near((*la).initialPoint(),(*lb).initialPoint(), eps)) { char temp[200]; - sprintf(temp, "Different start of segment: (%g,%g) != (%g,%g)", (*la).initialPoint()[Geom::X], (*la).initialPoint()[Geom::Y], (*lb).initialPoint()[Geom::X], (*lb).initialPoint()[Geom::Y]); + sprintf(temp, "Different start of segment: (%g,%g) != (%g,%g), subpath: %u, segment: %u", (*la).initialPoint()[Geom::X], (*la).initialPoint()[Geom::Y], (*lb).initialPoint()[Geom::X], (*lb).initialPoint()[Geom::Y], i, j); TS_FAIL(temp); return false; } if (!Geom::are_near((*la).finalPoint(),(*lb).finalPoint(), eps)) { char temp[200]; - sprintf(temp, "Different end of segment: (%g,%g) != (%g,%g)", (*la).finalPoint()[Geom::X], (*la).finalPoint()[Geom::Y], (*lb).finalPoint()[Geom::X], (*lb).finalPoint()[Geom::Y]); + sprintf(temp, "Different end of segment: (%g,%g) != (%g,%g), subpath: %u, segment: %u", (*la).finalPoint()[Geom::X], (*la).finalPoint()[Geom::Y], (*lb).finalPoint()[Geom::X], (*lb).finalPoint()[Geom::Y], i, j); TS_FAIL(temp); return false; } + char temp[200]; + sprintf(temp, "A LineSegment and an HLineSegment have been considered equal. Subpath: %u, segment: %u", i, j); + TS_TRACE(temp); } else if (Geom::VLineSegment const *lb = dynamic_cast(cb)) { if (!Geom::are_near((*la).initialPoint(),(*lb).initialPoint(), eps)) { char temp[200]; - sprintf(temp, "Different start of segment: (%g,%g) != (%g,%g)", (*la).initialPoint()[Geom::X], (*la).initialPoint()[Geom::Y], (*lb).initialPoint()[Geom::X], (*lb).initialPoint()[Geom::Y]); + sprintf(temp, "Different start of segment: (%g,%g) != (%g,%g), subpath: %u, segment: %u", (*la).initialPoint()[Geom::X], (*la).initialPoint()[Geom::Y], (*lb).initialPoint()[Geom::X], (*lb).initialPoint()[Geom::Y], i, j); TS_FAIL(temp); return false; } if (!Geom::are_near((*la).finalPoint(),(*lb).finalPoint(), eps)) { char temp[200]; - sprintf(temp, "Different end of segment: (%g,%g) != (%g,%g)", (*la).finalPoint()[Geom::X], (*la).finalPoint()[Geom::Y], (*lb).finalPoint()[Geom::X], (*lb).finalPoint()[Geom::Y]); + sprintf(temp, "Different end of segment: (%g,%g) != (%g,%g), subpath: %u, segment: %u", (*la).finalPoint()[Geom::X], (*la).finalPoint()[Geom::Y], (*lb).finalPoint()[Geom::X], (*lb).finalPoint()[Geom::Y], i, j); TS_FAIL(temp); return false; } + char temp[200]; + sprintf(temp, "A LineSegment and a VLineSegment have been considered equal. Subpath: %u, segment: %u", i, j); + TS_TRACE(temp); } else { - TS_FAIL((std::string("Different curve types: ") + typeid(*ca).name() + " != " + typeid(*cb).name()).c_str()); - return false; + char temp[200]; + sprintf(temp, "Different curve types: %s != %s, subpath: %u, segment: %u", typeid(*ca).name(), typeid(*cb).name(), i, j); + TS_FAIL(temp); } } else if(Geom::LineSegment const *lb = dynamic_cast(cb)) @@ -515,33 +566,45 @@ private: if (Geom::HLineSegment const *la = dynamic_cast(ca)) { if (!Geom::are_near((*la).initialPoint(),(*lb).initialPoint(), eps)) { char temp[200]; - sprintf(temp, "Different start of segment: (%g,%g) != (%g,%g)", (*la).initialPoint()[Geom::X], (*la).initialPoint()[Geom::Y], (*lb).initialPoint()[Geom::X], (*lb).initialPoint()[Geom::Y]); + sprintf(temp, "Different start of segment: (%g,%g) != (%g,%g), subpath: %u, segment: %u", (*la).initialPoint()[Geom::X], (*la).initialPoint()[Geom::Y], (*lb).initialPoint()[Geom::X], (*lb).initialPoint()[Geom::Y], i, j); TS_FAIL(temp); return false; } if (!Geom::are_near((*la).finalPoint(),(*lb).finalPoint(), eps)) { char temp[200]; - sprintf(temp, "Different end of segment: (%g,%g) != (%g,%g)", (*la).finalPoint()[Geom::X], (*la).finalPoint()[Geom::Y], (*lb).finalPoint()[Geom::X], (*lb).finalPoint()[Geom::Y]); + sprintf(temp, "Different end of segment: (%g,%g) != (%g,%g), subpath: %u, segment: %u", (*la).finalPoint()[Geom::X], (*la).finalPoint()[Geom::Y], (*lb).finalPoint()[Geom::X], (*lb).finalPoint()[Geom::Y], i, j); TS_FAIL(temp); return false; } + char temp[200]; + sprintf(temp, "An HLineSegment and a LineSegment have been considered equal. Subpath: %u, segment: %u", i, j); + TS_TRACE(temp); } else if (Geom::VLineSegment const *la = dynamic_cast(ca)) { if (!Geom::are_near((*la).initialPoint(),(*lb).initialPoint(), eps)) { char temp[200]; - sprintf(temp, "Different start of segment: (%g,%g) != (%g,%g)", (*la).initialPoint()[Geom::X], (*la).initialPoint()[Geom::Y], (*lb).initialPoint()[Geom::X], (*lb).initialPoint()[Geom::Y]); + sprintf(temp, "Different start of segment: (%g,%g) != (%g,%g), subpath: %u, segment: %u", (*la).initialPoint()[Geom::X], (*la).initialPoint()[Geom::Y], (*lb).initialPoint()[Geom::X], (*lb).initialPoint()[Geom::Y], i, j); TS_FAIL(temp); return false; } if (!Geom::are_near((*la).finalPoint(),(*lb).finalPoint(), eps)) { char temp[200]; - sprintf(temp, "Different end of segment: (%g,%g) != (%g,%g)", (*la).finalPoint()[Geom::X], (*la).finalPoint()[Geom::Y], (*lb).finalPoint()[Geom::X], (*lb).finalPoint()[Geom::Y]); + sprintf(temp, "Different end of segment: (%g,%g) != (%g,%g), subpath: %u, segment: %u", (*la).finalPoint()[Geom::X], (*la).finalPoint()[Geom::Y], (*lb).finalPoint()[Geom::X], (*lb).finalPoint()[Geom::Y], i, j); TS_FAIL(temp); return false; } + char temp[200]; + sprintf(temp, "A VLineSegment and a LineSegment have been considered equal. Subpath: %u, segment: %u", i, j); + TS_TRACE(temp); } else { - TS_FAIL((std::string("Different curve types: ") + typeid(*ca).name() + " != " + typeid(*cb).name()).c_str()); + char temp[200]; + sprintf(temp, "Different curve types: %s != %s, subpath: %u, segment: %u", typeid(*ca).name(), typeid(*cb).name(), i, j); + TS_FAIL(temp); return false; } + } else { + char temp[200]; + sprintf(temp, "Different curve types: %s != %s, subpath: %u, segment: %u", typeid(*ca).name(), typeid(*cb).name(), i, j); + TS_FAIL(temp); } } } diff --git a/src/svg/svg-path-nr-test.h b/src/svg/svg-path-nr-test.h index df9c46051..58f7cd0e7 100644 --- a/src/svg/svg-path-nr-test.h +++ b/src/svg/svg-path-nr-test.h @@ -1,3 +1,10 @@ +/* WARNING: These tests are not completely correct! + * Specifically, 'M 0,0 L 1,1 z' and 'M 0,0 L 1,1 L 0,0 z' are treated as equal, but aren't. + * This difference is (probably?) only relevant in the context of markers. + * However, since NArtBpath has no (valid) way to distinguish these two and is being retired, + * these tests have not been updated to reflect this. + */ + #include #include "libnr/n-art-bpath.h" #include "svg/svg.h"