diff --git a/Makefile b/Makefile
index 3c66e8678..db79d67b8 100644
--- a/Makefile
+++ b/Makefile
@@ -76,7 +76,7 @@ TESTOBJ = test/options.o \
test/testdivision.o \
test/testerrorlogger.o \
test/testexceptionsafety.o \
- test/testfilelister_unix.o \
+ test/testfilelister.o \
test/testincompletestatement.o \
test/testmathlib.o \
test/testmemleak.o \
@@ -271,8 +271,8 @@ test/testerrorlogger.o: test/testerrorlogger.cpp lib/cppcheck.h lib/settings.h l
test/testexceptionsafety.o: test/testexceptionsafety.cpp lib/tokenize.h lib/checkexceptionsafety.h lib/check.h lib/token.h lib/settings.h lib/errorlogger.h test/testsuite.h test/redirect.h
$(CXX) $(CPPFLAGS) $(CXXFLAGS) ${INCLUDE_FOR_TEST} -c -o test/testexceptionsafety.o test/testexceptionsafety.cpp
-test/testfilelister_unix.o: test/testfilelister_unix.cpp test/testsuite.h lib/errorlogger.h lib/settings.h test/redirect.h
- $(CXX) $(CPPFLAGS) $(CXXFLAGS) ${INCLUDE_FOR_TEST} -c -o test/testfilelister_unix.o test/testfilelister_unix.cpp
+test/testfilelister.o: test/testfilelister.cpp test/testsuite.h lib/errorlogger.h lib/settings.h test/redirect.h
+ $(CXX) $(CPPFLAGS) $(CXXFLAGS) ${INCLUDE_FOR_TEST} -c -o test/testfilelister.o test/testfilelister.cpp
test/testincompletestatement.o: test/testincompletestatement.cpp test/testsuite.h lib/errorlogger.h lib/settings.h test/redirect.h lib/tokenize.h lib/checkother.h lib/check.h lib/token.h
$(CXX) $(CPPFLAGS) $(CXXFLAGS) ${INCLUDE_FOR_TEST} -c -o test/testincompletestatement.o test/testincompletestatement.cpp
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index f04501720..5bfde5e36 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -19,6 +19,7 @@ SET(CHECKTEST_SRCS
testdivision.cpp
testerrorlogger.cpp
testexceptionsafety.cpp
+ testfilelister.cpp
testincompletestatement.cpp
testmathlib.cpp
testmemleak.cpp
@@ -56,8 +57,6 @@ if(WIN32)
# Windows needs additional shlwapi library.
set(CHECK_LIBS ${CHECK_LIBS} shlwapi)
endif()
-else()
- set(CHECKTEST_SRCS ${CHECKTEST_SRCS} testfilelister_unix.cpp)
endif()
if (CMAKE_COMPILER_IS_GNUCXX)
diff --git a/test/test.pro b/test/test.pro
index 75f9b7997..dc901ca0a 100644
--- a/test/test.pro
+++ b/test/test.pro
@@ -48,6 +48,7 @@ SOURCES += options.cpp \
testdivision.cpp \
testerrorlogger.cpp \
testexceptionsafety.cpp \
+ testfilelister.cpp \
testincompletestatement.cpp \
testmathlib.cpp \
testmemleak.cpp \
diff --git a/test/testfilelister.cpp b/test/testfilelister.cpp
new file mode 100644
index 000000000..ea4b95a28
--- /dev/null
+++ b/test/testfilelister.cpp
@@ -0,0 +1,72 @@
+/*
+ * Cppcheck - A tool for static C/C++ code analysis
+ * Copyright (C) 2007-2011 Daniel Marjamäki and Cppcheck team.
+ *
+ * This program 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.
+ *
+ * This program 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 this program. If not, see .
+ */
+
+#include "testsuite.h"
+#include "filelister.h"
+#include
+#include
+
+class TestFileLister: public TestFixture
+{
+public:
+ TestFileLister()
+ :TestFixture("TestFileLister")
+ {}
+
+private:
+ void run()
+ {
+ // bail out if the tests are not executed from the base folder
+ {
+ std::ifstream fin("test/testfilelister.cpp");
+ if (!fin.is_open())
+ return;
+ }
+
+ TEST_CASE(isDirectory);
+ TEST_CASE(recursiveAddFiles);
+ }
+
+ void isDirectory()
+ {
+ ASSERT_EQUALS(false, FileLister::isDirectory("readme.txt"));
+ ASSERT_EQUALS(true, FileLister::isDirectory("lib"));
+ }
+
+ void recursiveAddFiles()
+ {
+ // Recursively add add files..
+ std::vector filenames;
+ FileLister::recursiveAddFiles(filenames, ".");
+/*
+ for (unsigned int i = 0; i < filenames.size(); ++i)
+ std::cout << filenames[i] << std::endl;
+*/
+ // Make sure source files are added..
+ ASSERT(std::find(filenames.begin(), filenames.end(), "./cli/main.cpp") != filenames.end());
+ ASSERT(std::find(filenames.begin(), filenames.end(), "./lib/token.cpp") != filenames.end());
+ ASSERT(std::find(filenames.begin(), filenames.end(), "./lib/tokenize.cpp") != filenames.end());
+ ASSERT(std::find(filenames.begin(), filenames.end(), "./test/testfilelister.cpp") != filenames.end());
+
+ // Make sure headers are not added..
+ ASSERT(std::find(filenames.begin(), filenames.end(), "./lib/tokenize.h") == filenames.end());
+ }
+};
+
+REGISTER_TEST(TestFileLister)
+
diff --git a/test/testfilelister_unix.cpp b/test/testfilelister_unix.cpp
deleted file mode 100644
index fddd2944b..000000000
--- a/test/testfilelister_unix.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Cppcheck - A tool for static C/C++ code analysis
- * Copyright (C) 2007-2011 Daniel Marjamäki and Cppcheck team.
- *
- * This program 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.
- *
- * This program 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 this program. If not, see .
- */
-
-#include "testsuite.h"
-
-#include "filelister.h"
-
-class TestFileLister: public TestFixture
-{
-public:
- TestFileLister()
- :TestFixture("TestFileLister")
- {}
-
-private:
- void run()
- {
-#ifndef _WIN32
- TEST_CASE(test_recursiveAddFiles2);
-#endif
- }
-
-#ifndef _WIN32
- void test_recursiveAddFiles2()
- {
- std::vector relative, absolute;
- FileLister::recursiveAddFiles2(relative, absolute, ".");
-
- ASSERT(!relative.empty());
- ASSERT_EQUALS((int)relative.size(), (int)absolute.size());
-
- for (std::vector::const_iterator r = relative.begin(), r_end = relative.end(),
- a = absolute.begin(), a_end = absolute.end();
- r != r_end && a != a_end;
- ++r, ++a
- )
- {
- static const size_t start_at_relative = std::string("./").size();
- static const size_t start_at_absolute = std::string("./").size() + a->size() - r->size();
-
- ASSERT_EQUALS(r->substr(start_at_relative), a->substr(start_at_absolute));
- }
- }
-#endif
-};
-
-REGISTER_TEST(TestFileLister)
-