Warning, file /libraries/libqgit2/tests/Diff.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /******************************************************************************
0002 * Permission to use, copy, modify, and distribute the software
0003 * and its documentation for any purpose and without fee is hereby
0004 * granted, provided that the above copyright notice appear in all
0005 * copies and that both that the copyright notice and this
0006 * permission notice and warranty disclaimer appear in supporting
0007 * documentation, and that the name of the author not be used in
0008 * advertising or publicity pertaining to distribution of the
0009 * software without specific, written prior permission.
0010 *
0011 * The author disclaim all warranties with regard to this
0012 * software, including all implied warranties of merchantability
0013 * and fitness.  In no event shall the author be liable for any
0014 * special, indirect or consequential damages or any damages
0015 * whatsoever resulting from loss of use, data or profits, whether
0016 * in an action of contract, negligence or other tortious action,
0017 * arising out of or in connection with the use or performance of
0018 * this software.
0019 */
0020 
0021 #include "TestHelpers.h"
0022 #include "qgitrepository.h"
0023 #include "qgittree.h"
0024 #include "qgitdiff.h"
0025 #include "qgitdiffdelta.h"
0026 #include "qgitdifffile.h"
0027 
0028 using namespace LibQGit2;
0029 
0030 class TestDiff : public TestBase
0031 {
0032     Q_OBJECT
0033 
0034 private slots:
0035     void testDiffFileList();
0036 };
0037 
0038 
0039 void TestDiff::testDiffFileList()
0040 {
0041     Repository repo;
0042     repo.open(ExistingRepository);
0043 
0044     try {
0045         Tree oldTree = repo.lookupRevision("4146952e67^{tree}").toTree(); // These commits are chosen right from the start of
0046         Tree newTree = repo.lookupRevision("e3f21f35e5^{tree}").toTree(); // the development history of libqgit2
0047         Diff diff = repo.diffTrees(oldTree, newTree);
0048         size_t numD = diff.numDeltas();
0049         QStringList expectedPaths = QStringList() << "CMakeLists.txt" << "src/blob.cpp";
0050         for (size_t i = 0; i < numD; ++i) {
0051             expectedPaths.removeAll(diff.delta(i).newFile().path());
0052         }
0053 
0054         QVERIFY2(expectedPaths.isEmpty(), qPrintable("Paths not in diff: " + expectedPaths.join(", ")));
0055     } catch (const Exception& ex) {
0056         QFAIL(ex.what());
0057     }
0058 }
0059 
0060 QTEST_MAIN(TestDiff)
0061 
0062 #include "Diff.moc"