diff --git a/src/app/share/collection/bugs/Issue_#752.val b/src/app/share/collection/bugs/Issue_#752.val new file mode 100644 index 000000000..01a648222 --- /dev/null +++ b/src/app/share/collection/bugs/Issue_#752.val @@ -0,0 +1,798 @@ + + + + 0.6.2 + cm + + + Issue_#752.vst + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +
+ + + diff --git a/src/app/share/collection/bugs/Issue_#752.vst b/src/app/share/collection/bugs/Issue_#752.vst new file mode 100644 index 000000000..7f67621d8 --- /dev/null +++ b/src/app/share/collection/bugs/Issue_#752.vst @@ -0,0 +1,58 @@ + + + + 0.4.4 + false + + cm + 42 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/ValentinaTest/ValentinaTest.pro b/src/test/ValentinaTest/ValentinaTest.pro index 62d4dac48..69d2fd1ea 100644 --- a/src/test/ValentinaTest/ValentinaTest.pro +++ b/src/test/ValentinaTest/ValentinaTest.pro @@ -62,7 +62,8 @@ SOURCES += \ tst_vpointf.cpp \ tst_readval.cpp \ tst_vtranslatevars.cpp \ - tst_vabstractpiece.cpp + tst_vabstractpiece.cpp \ + tst_vtooluniondetails.cpp *msvc*:SOURCES += stable.cpp @@ -88,7 +89,8 @@ HEADERS += \ tst_vpointf.h \ tst_readval.h \ tst_vtranslatevars.h \ - tst_vabstractpiece.h + tst_vabstractpiece.h \ + tst_vtooluniondetails.h # Set using ccache. Function enable_ccache() defined in common.pri. $$enable_ccache() diff --git a/src/test/ValentinaTest/qttestmainlambda.cpp b/src/test/ValentinaTest/qttestmainlambda.cpp index 697d684ca..df9ba7327 100644 --- a/src/test/ValentinaTest/qttestmainlambda.cpp +++ b/src/test/ValentinaTest/qttestmainlambda.cpp @@ -49,6 +49,7 @@ #include "tst_vpointf.h" #include "tst_readval.h" #include "tst_vtranslatevars.h" +#include "tst_vtooluniondetails.h" #include "../vmisc/def.h" #include "../qmuparser/qmudef.h" @@ -130,6 +131,7 @@ int main(int argc, char** argv) ASSERT_TEST(new TST_VPointF()); ASSERT_TEST(new TST_ReadVal()); ASSERT_TEST(new TST_VTranslateVars()); + ASSERT_TEST(new TST_VToolUnionDetails()); return status; } diff --git a/src/test/ValentinaTest/tst_vtooluniondetails.cpp b/src/test/ValentinaTest/tst_vtooluniondetails.cpp new file mode 100644 index 000000000..6aa21940d --- /dev/null +++ b/src/test/ValentinaTest/tst_vtooluniondetails.cpp @@ -0,0 +1,173 @@ +/************************************************************************ + ** + ** @file + ** @author Roman Telezhynskyi + ** @date 11 9, 2017 + ** + ** @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) 2017 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_vtooluniondetails.h" +#include "../vpatterndb/vpiecepath.h" +#include "../vpatterndb/vpiecenode.h" +#include "../vtools/tools/vtooluniondetails.h" + +#include + +typedef QPair UnitedPathNode; + +Q_DECLARE_METATYPE(UnitedPathNode) + +//--------------------------------------------------------------------------------------------------------------------- +TST_VToolUnionDetails::TST_VToolUnionDetails(QObject *parent) + : QObject (parent) +{ +} + +//--------------------------------------------------------------------------------------------------------------------- +void TST_VToolUnionDetails::TestUnitingMainPaths_data() +{ + QTest::addColumn("d1"); + QTest::addColumn("d2"); + QTest::addColumn("indexD2"); + QTest::addColumn("pRotate"); + QTest::addColumn>("result"); + + VPieceNode d1p0(1205, Tool::NodePoint); + VPieceNode d1p1(1206, Tool::NodePoint); + VPieceNode d1p2(1207, Tool::NodeSpline); + VPieceNode d1p3(1208, Tool::NodePoint); + VPieceNode d1p4(1209, Tool::NodePoint); + VPieceNode d1p5(1204, Tool::NodeSpline); + + VPieceNode d2p0(1211, Tool::NodePoint); + VPieceNode d2p1(1212, Tool::NodePoint); + VPieceNode d2p2(1213, Tool::NodeSpline); + VPieceNode d2p3(1214, Tool::NodePoint); + VPieceNode d2p4(1215, Tool::NodePoint); + + QVector result; + result.append(qMakePair(true, d1p0)); + result.append(qMakePair(true, d1p1)); + result.append(qMakePair(true, d1p2)); + result.append(qMakePair(true, d1p3)); + result.append(qMakePair(false, d2p2)); + result.append(qMakePair(false, d2p3)); + result.append(qMakePair(false, d2p4)); + result.append(qMakePair(false, d2p0)); + result.append(qMakePair(true, d1p4)); + result.append(qMakePair(true, d1p5)); + + VPiecePath d1; + d1.Append(d1p0); + d1.Append(d1p1); + d1.Append(d1p2); + d1.Append(d1p3); + d1.Append(d1p4); + d1.Append(d1p5); + + VPiecePath d2; + d2.Append(d2p0); + d2.Append(d2p1); + d2.Append(d2p2); + d2.Append(d2p3); + d2.Append(d2p4); + + quint32 indexD2 = 0; + quint32 pRotate = 1208; + + // See the file /src/app/share/collection/Issue_#752.val + QTest::newRow("Case 1") << d1 << d2 << indexD2 << pRotate << result; + + result.clear(); + result.append(qMakePair(true, d1p1)); + result.append(qMakePair(true, d1p2)); + result.append(qMakePair(true, d1p3)); + result.append(qMakePair(false, d2p2)); + result.append(qMakePair(false, d2p3)); + result.append(qMakePair(false, d2p4)); + result.append(qMakePair(false, d2p0)); + result.append(qMakePair(true, d1p4)); + result.append(qMakePair(true, d1p5)); + result.append(qMakePair(true, d1p0)); + + d1.Clear(); + d1.Append(d1p1); + d1.Append(d1p2); + d1.Append(d1p3); + d1.Append(d1p4); + d1.Append(d1p5); + d1.Append(d1p0); + + QTest::newRow("Case 2") << d1 << d2 << indexD2 << pRotate << result; + + result.clear(); + result.append(qMakePair(true, d1p2)); + result.append(qMakePair(true, d1p3)); + result.append(qMakePair(false, d2p2)); + result.append(qMakePair(false, d2p3)); + result.append(qMakePair(false, d2p4)); + result.append(qMakePair(false, d2p0)); + result.append(qMakePair(true, d1p4)); + result.append(qMakePair(true, d1p5)); + result.append(qMakePair(true, d1p0)); + result.append(qMakePair(true, d1p1)); + + d1.Clear(); + d1.Append(d1p2); + d1.Append(d1p3); + d1.Append(d1p4); + d1.Append(d1p5); + d1.Append(d1p0); + d1.Append(d1p1); + + QTest::newRow("Case 3") << d1 << d2 << indexD2 << pRotate << result; +} + +//--------------------------------------------------------------------------------------------------------------------- +void TST_VToolUnionDetails::TestUnitingMainPaths() +{ + QFETCH(VPiecePath, d1); + QFETCH(VPiecePath, d2); + QFETCH(quint32, indexD2); + QFETCH(quint32, pRotate); + QFETCH(QVector, result); + + const QVector out = VToolUnionDetails::CalcUnitedPath(d1, d2, indexD2, pRotate); + + QVERIFY(result.size() == out.size()); + + for (int i=0; i < out.size(); ++i) + { + const VPieceNode resP = result.at(i).second; + const VPieceNode outP = out.at(i).second; + + const QString msg = QString("Index: %1. Got item with id = %2, type = %3; Expected item with id = %4, " + "type = %5.") + .arg(i).arg(outP.GetId()).arg(static_cast(outP.GetTypeTool())) + .arg(resP.GetId()).arg(static_cast(resP.GetTypeTool())); + + QVERIFY2(out.at(i).first == result.at(i).first + && outP.GetId() == resP.GetId() + && outP.GetTypeTool() == resP.GetTypeTool(), qUtf8Printable(msg)); + } +} diff --git a/src/test/ValentinaTest/tst_vtooluniondetails.h b/src/test/ValentinaTest/tst_vtooluniondetails.h new file mode 100644 index 000000000..753b9d125 --- /dev/null +++ b/src/test/ValentinaTest/tst_vtooluniondetails.h @@ -0,0 +1,46 @@ +/************************************************************************ + ** + ** @file + ** @author Roman Telezhynskyi + ** @date 11 9, 2017 + ** + ** @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) 2017 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_VTOOLUNIONDETAILS_H +#define TST_VTOOLUNIONDETAILS_H + +#include + +class TST_VToolUnionDetails : public QObject +{ + Q_OBJECT +public: + explicit TST_VToolUnionDetails(QObject *parent = nullptr); +private slots: + void TestUnitingMainPaths_data(); + void TestUnitingMainPaths(); +private: + Q_DISABLE_COPY(TST_VToolUnionDetails) +}; + +#endif // TST_VTOOLUNIONDETAILS_H