From cd65c671f221f21eb0d6391647057375a44158aa Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 7 May 2015 16:12:53 +0300 Subject: [PATCH] Test for issue #298. --HG-- branch : develop --- src/test/ValentinaTest/ValentinaTest.pro | 17 +++- src/test/ValentinaTest/abstracttest.cpp | 49 ++++++++++ src/test/ValentinaTest/abstracttest.h | 45 ++++++++++ src/test/ValentinaTest/qttestmainlambda.cpp | 2 + .../ValentinaTest/tst_vabstractdetail.cpp | 19 +--- src/test/ValentinaTest/tst_vabstractdetail.h | 6 +- src/test/ValentinaTest/tst_vspline.cpp | 90 +++++++++++++++++++ src/test/ValentinaTest/tst_vspline.h | 47 ++++++++++ 8 files changed, 254 insertions(+), 21 deletions(-) create mode 100644 src/test/ValentinaTest/abstracttest.cpp create mode 100644 src/test/ValentinaTest/abstracttest.h create mode 100644 src/test/ValentinaTest/tst_vspline.cpp create mode 100644 src/test/ValentinaTest/tst_vspline.h diff --git a/src/test/ValentinaTest/ValentinaTest.pro b/src/test/ValentinaTest/ValentinaTest.pro index d761c1c7a..5a51fee7e 100644 --- a/src/test/ValentinaTest/ValentinaTest.pro +++ b/src/test/ValentinaTest/ValentinaTest.pro @@ -36,11 +36,15 @@ DEFINES += SRCDIR=\\\"$$PWD/\\\" SOURCES += \ qttestmainlambda.cpp \ tst_vposter.cpp \ - tst_vabstractdetail.cpp + tst_vabstractdetail.cpp \ + tst_vspline.cpp \ + abstracttest.cpp HEADERS += \ tst_vposter.h \ - tst_vabstractdetail.h + tst_vabstractdetail.h \ + tst_vspline.h \ + abstracttest.h CONFIG(debug, debug|release){ # Debug mode @@ -96,3 +100,12 @@ DEPENDPATH += $$PWD/../../libs/vlayout win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vlayout/$${DESTDIR}/vlayout.lib else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vlayout/$${DESTDIR}/libvlayout.a + +# VGeometry static library +unix|win32: LIBS += -L$$OUT_PWD/../../libs/vgeometry/$${DESTDIR} -lvgeometry + +INCLUDEPATH += $$PWD/../../libs/vgeometry +DEPENDPATH += $$PWD/../../libs/vgeometry + +win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vgeometry/$${DESTDIR}/vgeometry.lib +else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vgeometry/$${DESTDIR}/libvgeometry.a diff --git a/src/test/ValentinaTest/abstracttest.cpp b/src/test/ValentinaTest/abstracttest.cpp new file mode 100644 index 000000000..415688a54 --- /dev/null +++ b/src/test/ValentinaTest/abstracttest.cpp @@ -0,0 +1,49 @@ +/************************************************************************ + ** + ** @file abstracttest.cpp + ** @author Roman Telezhynskyi + ** @date 7 5, 2015 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2015 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include "abstracttest.h" + +#include + +//--------------------------------------------------------------------------------------------------------------------- +AbstractTest::AbstractTest(QObject *parent) : + QObject(parent) +{ +} + +//--------------------------------------------------------------------------------------------------------------------- +void AbstractTest::Comparison(const QVector &ekv, const QVector &ekvOrig) const +{ + // Begin comparison + QCOMPARE(ekv.size(), ekvOrig.size());// First check if sizes equal + for (int i=0; i < ekv.size(); i++) + { + // Check each point + QCOMPARE(ekv.at(i).toPoint(), ekvOrig.at(i).toPoint()); // Don't use comparison float values + } +} diff --git a/src/test/ValentinaTest/abstracttest.h b/src/test/ValentinaTest/abstracttest.h new file mode 100644 index 000000000..953989cdb --- /dev/null +++ b/src/test/ValentinaTest/abstracttest.h @@ -0,0 +1,45 @@ +/************************************************************************ + ** + ** @file abstracttest.h + ** @author Roman Telezhynskyi + ** @date 7 5, 2015 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2015 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef ABSTRACTTEST_H +#define ABSTRACTTEST_H + +#include + +class AbstractTest : public QObject +{ + Q_OBJECT +public: + explicit AbstractTest(QObject *parent = 0); + +protected: + void Comparison(const QVector &ekv, const QVector &ekvOrig) const; + +}; + +#endif // ABSTRACTTEST_H diff --git a/src/test/ValentinaTest/qttestmainlambda.cpp b/src/test/ValentinaTest/qttestmainlambda.cpp index 193f1714d..8af765e4c 100644 --- a/src/test/ValentinaTest/qttestmainlambda.cpp +++ b/src/test/ValentinaTest/qttestmainlambda.cpp @@ -30,6 +30,7 @@ #include "tst_vposter.h" #include "tst_vabstractdetail.h" +#include "tst_vspline.h" int main(int argc, char** argv) { @@ -44,6 +45,7 @@ int main(int argc, char** argv) ASSERT_TEST(new TST_VPoster()); ASSERT_TEST(new TST_VAbstractDetail()); + ASSERT_TEST(new TST_VSpline()); return status; } diff --git a/src/test/ValentinaTest/tst_vabstractdetail.cpp b/src/test/ValentinaTest/tst_vabstractdetail.cpp index 48efc3ef6..978545ab7 100644 --- a/src/test/ValentinaTest/tst_vabstractdetail.cpp +++ b/src/test/ValentinaTest/tst_vabstractdetail.cpp @@ -29,11 +29,12 @@ #include "tst_vabstractdetail.h" #include "../../libs/vlayout/vabstractdetail.h" -#include +#include +#include //--------------------------------------------------------------------------------------------------------------------- -TST_VAbstractDetail::TST_VAbstractDetail(QObject *parent) : - QObject(parent) +TST_VAbstractDetail::TST_VAbstractDetail(QObject *parent) + :AbstractTest(parent) { } @@ -320,15 +321,3 @@ QVector TST_VAbstractDetail::OutputPointsCase2() const return points; } - -//--------------------------------------------------------------------------------------------------------------------- -void TST_VAbstractDetail::Comparison(const QVector &ekv, const QVector &ekvOrig) const -{ - // Begin comparison - QCOMPARE(ekv.size(), ekvOrig.size());// First check if sizes equal - for (int i=0; i < ekv.size(); i++) - { - // Check each point - QCOMPARE(ekv.at(i).toPoint(), ekvOrig.at(i).toPoint()); // Don't use comparison float values - } -} diff --git a/src/test/ValentinaTest/tst_vabstractdetail.h b/src/test/ValentinaTest/tst_vabstractdetail.h index 5c01fd520..44b729a38 100644 --- a/src/test/ValentinaTest/tst_vabstractdetail.h +++ b/src/test/ValentinaTest/tst_vabstractdetail.h @@ -29,9 +29,9 @@ #ifndef TST_VABSTRACTDETAIL_H #define TST_VABSTRACTDETAIL_H -#include +#include "abstracttest.h" -class TST_VAbstractDetail : public QObject +class TST_VAbstractDetail : public AbstractTest { Q_OBJECT public: @@ -52,8 +52,6 @@ private: QVector InputPointsCase2() const; QVector OutputPointsCase2() const; - void Comparison(const QVector &ekv, const QVector &ekvOrig) const; - }; #endif // TST_VABSTRACTDETAIL_H diff --git a/src/test/ValentinaTest/tst_vspline.cpp b/src/test/ValentinaTest/tst_vspline.cpp new file mode 100644 index 000000000..770e2c7c7 --- /dev/null +++ b/src/test/ValentinaTest/tst_vspline.cpp @@ -0,0 +1,90 @@ +/************************************************************************ + ** + ** @file tst_vspline.cpp + ** @author Roman Telezhynskyi + ** @date 7 5, 2015 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2015 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include "tst_vspline.h" +#include "../../libs/vgeometry/vspline.h" + +#include + +//--------------------------------------------------------------------------------------------------------------------- +TST_VSpline::TST_VSpline(QObject *parent) + :AbstractTest(parent) +{ +} + +//--------------------------------------------------------------------------------------------------------------------- +void TST_VSpline::GetSegmentPoints() +{ + // Input data taken from real case + VPointF p1(1168.8582803149607, 39.999874015748034, "p1", 5.0000125984251973, 9.9999874015748045); + VPointF p4(681.33729132409951, 1815.7969526662778, "p4", 5.0000125984251973, 9.9999874015748045); + + VSpline spl(p1, p4, 229.381, 41.6325, 0.96294100000000005, 1.00054, 1); + + QPointF begin(957.69885233364062, 943.84482037833141); + QPointF end(681.33729132409951, 1815.7969526662778); + + QVector points; + points << spl.GetSegmentPoints(begin, end, false); + + QVector origPoints; + origPoints.append(QPointF(957.698852334, 943.844820378)); + origPoints.append(QPointF(957.84724553, 975.602655091)); + origPoints.append(QPointF(957.728801633, 1035.13055094)); + origPoints.append(QPointF(956.808773853, 1094.37046246)); + origPoints.append(QPointF(955.328435862, 1138.53744981)); + origPoints.append(QPointF(953.925479436, 1167.84862152)); + origPoints.append(QPointF(952.117074266, 1197.03211968)); + origPoints.append(QPointF(949.857653068, 1226.07557151)); + origPoints.append(QPointF(947.101648559, 1254.96660424)); + origPoints.append(QPointF(943.803493456, 1283.6928451)); + origPoints.append(QPointF(939.917620476, 1312.24192132)); + origPoints.append(QPointF(935.398462336, 1340.60146013)); + origPoints.append(QPointF(930.200451752, 1368.75908875)); + origPoints.append(QPointF(924.278021443, 1396.70243441)); + origPoints.append(QPointF(917.585604124, 1424.41912434)); + origPoints.append(QPointF(910.077632512, 1451.89678578)); + origPoints.append(QPointF(901.708539325, 1479.12304594)); + origPoints.append(QPointF(892.432757279, 1506.08553207)); + origPoints.append(QPointF(882.204719092, 1532.77187137)); + origPoints.append(QPointF(870.978857479, 1559.1696911)); + origPoints.append(QPointF(858.709605159, 1585.26661847)); + origPoints.append(QPointF(845.351394848, 1611.05028071)); + origPoints.append(QPointF(830.858659262, 1636.50830504)); + origPoints.append(QPointF(815.18583112, 1661.62831871)); + origPoints.append(QPointF(798.287343137, 1686.39794894)); + origPoints.append(QPointF(780.117628031, 1710.80482295)); + origPoints.append(QPointF(760.631118518, 1734.83656798)); + origPoints.append(QPointF(739.782247316, 1758.48081125)); + origPoints.append(QPointF(717.525447141, 1781.72518)); + origPoints.append(QPointF(693.81515071, 1804.55730144)); + origPoints.append(QPointF(681.337291324, 1815.79695267)); + + // Begin comparison + Comparison(points, origPoints); +} diff --git a/src/test/ValentinaTest/tst_vspline.h b/src/test/ValentinaTest/tst_vspline.h new file mode 100644 index 000000000..9c575393e --- /dev/null +++ b/src/test/ValentinaTest/tst_vspline.h @@ -0,0 +1,47 @@ +/************************************************************************ + ** + ** @file tst_vspline.h + ** @author Roman Telezhynskyi + ** @date 7 5, 2015 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2015 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef TST_VSPLINE_H +#define TST_VSPLINE_H + +#include "abstracttest.h" + +class TST_VSpline : public AbstractTest +{ + Q_OBJECT +public: + explicit TST_VSpline(QObject *parent = 0); + +signals: + +private slots: + void GetSegmentPoints(); + +}; + +#endif // TST_VSPLINE_H