From 2123f6fafc1e8520c3a34439ac1370a129d63993 Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Tue, 23 Aug 2011 20:38:29 +0300 Subject: [PATCH] GUI: Update projectfile tests. --- gui/test/data/projectfiles/simple.cppcheck | 4 +-- .../data/projectfiles/simple_ignore.cppcheck | 18 +++++++++++++ gui/test/filelist/testfilelist.cpp | 8 +++--- gui/test/projectfile/testprojectfile.cpp | 27 +++++++++++++++++-- gui/test/projectfile/testprojectfile.h | 1 + 5 files changed, 50 insertions(+), 8 deletions(-) create mode 100644 gui/test/data/projectfiles/simple_ignore.cppcheck diff --git a/gui/test/data/projectfiles/simple.cppcheck b/gui/test/data/projectfiles/simple.cppcheck index 7e2ae6c91..d73eb9ae8 100644 --- a/gui/test/data/projectfiles/simple.cppcheck +++ b/gui/test/data/projectfiles/simple.cppcheck @@ -9,9 +9,9 @@ - + - + diff --git a/gui/test/data/projectfiles/simple_ignore.cppcheck b/gui/test/data/projectfiles/simple_ignore.cppcheck new file mode 100644 index 000000000..7e2ae6c91 --- /dev/null +++ b/gui/test/data/projectfiles/simple_ignore.cppcheck @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/gui/test/filelist/testfilelist.cpp b/gui/test/filelist/testfilelist.cpp index f50aa2de0..652097cf6 100644 --- a/gui/test/filelist/testfilelist.cpp +++ b/gui/test/filelist/testfilelist.cpp @@ -98,7 +98,7 @@ void TestFileList::filterFiles() FileList list; QStringList filters; filters << "foo1.cpp" << "foo3.cc"; - list.AddIngoreList(filters); + list.AddExcludeList(filters); list.AddFile(QString(SRCDIR) + "/../data/files/foo1.cpp"); list.AddFile(QString(SRCDIR) + "/../data/files/foo2.cxx"); list.AddFile(QString(SRCDIR) + "/../data/files/foo3.cc"); @@ -119,7 +119,7 @@ void TestFileList::filterFiles2() FileList list; QStringList filters; filters << "foo1.cpp" << "foo3.cc"; - list.AddIngoreList(filters); + list.AddExcludeList(filters); list.AddDirectory(QString(SRCDIR) + "/../data/files"); QStringList files = list.GetFileList(); QCOMPARE(files.size(), 5); @@ -134,7 +134,7 @@ void TestFileList::filterFiles3() FileList list; QStringList filters; filters << "foo1.cpp" << "foo3.cc"; - list.AddIngoreList(filters); + list.AddExcludeList(filters); list.AddDirectory(QString(SRCDIR) + "/../data/files", true); QStringList files = list.GetFileList(); QCOMPARE(files.size(), 6); @@ -151,7 +151,7 @@ void TestFileList::filterFiles4() FileList list; QStringList filters; filters << "dir1/"; - list.AddIngoreList(filters); + list.AddExcludeList(filters); list.AddDirectory(QString(SRCDIR) + "/../data/files", true); QStringList files = list.GetFileList(); QCOMPARE(files.size(), 8); diff --git a/gui/test/projectfile/testprojectfile.cpp b/gui/test/projectfile/testprojectfile.cpp index 8873ff778..285b3e292 100644 --- a/gui/test/projectfile/testprojectfile.cpp +++ b/gui/test/projectfile/testprojectfile.cpp @@ -42,7 +42,30 @@ void TestProjectFile::loadSimple() QCOMPARE(paths.size(), 2); QCOMPARE(paths[0], QString("gui/")); QCOMPARE(paths[1], QString("test/")); - QStringList ignores = pfile.GetIgnoredPaths(); + QStringList excludes = pfile.GetExcludedPaths(); + QCOMPARE(excludes.size(), 1); + QCOMPARE(excludes[0], QString("gui/temp/")); + QStringList defines = pfile.GetDefines(); + QCOMPARE(defines.size(), 1); + QCOMPARE(defines[0], QString("FOO")); +} + +// Test that project file with old 'ignore' element works +void TestProjectFile::loadSimpleWithIgnore() +{ + const QString filepath(QString(SRCDIR) + "/../data/projectfiles/simple_ignore.cppcheck"); + ProjectFile pfile(filepath); + QVERIFY(pfile.Read()); + QCOMPARE(pfile.GetRootPath(), QString("../..")); + QStringList includes = pfile.GetIncludeDirs(); + QCOMPARE(includes.size(), 2); + QCOMPARE(includes[0], QString("lib/")); + QCOMPARE(includes[1], QString("cli/")); + QStringList paths = pfile.GetCheckPaths(); + QCOMPARE(paths.size(), 2); + QCOMPARE(paths[0], QString("gui/")); + QCOMPARE(paths[1], QString("test/")); + QStringList ignores = pfile.GetExcludedPaths(); QCOMPARE(ignores.size(), 1); QCOMPARE(ignores[0], QString("gui/temp/")); QStringList defines = pfile.GetDefines(); @@ -64,7 +87,7 @@ void TestProjectFile::loadSimpleNoroot() QCOMPARE(paths.size(), 2); QCOMPARE(paths[0], QString("gui/")); QCOMPARE(paths[1], QString("test/")); - QStringList ignores = pfile.GetIgnoredPaths(); + QStringList ignores = pfile.GetExcludedPaths(); QCOMPARE(ignores.size(), 1); QCOMPARE(ignores[0], QString("gui/temp/")); QStringList defines = pfile.GetDefines(); diff --git a/gui/test/projectfile/testprojectfile.h b/gui/test/projectfile/testprojectfile.h index 1116cf4e7..860161018 100644 --- a/gui/test/projectfile/testprojectfile.h +++ b/gui/test/projectfile/testprojectfile.h @@ -26,5 +26,6 @@ class TestProjectFile: public QObject private slots: void loadInexisting(); void loadSimple(); + void loadSimpleWithIgnore(); void loadSimpleNoroot(); };