test: Put test data into TestSuite specific folders
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#include "test_header.h"
|
||||
#include "header.h"
|
||||
|
||||
char* name;
|
||||
H g;
|
||||
@@ -1,6 +1,6 @@
|
||||
Graph.cpp Graph::removeEdge() ERROR: Can't remove member edge, without removing the child node.
|
||||
TextAccess.cpp TextAccess::checkIndexIntervalInRange() WARNING: Index 'firstLine' has to be lower or equal index 'lastLine', is 2 > 1
|
||||
TextAccess.cpp TextAccess::checkIndexInRange() WARNING: Tried to access index 9. Maximum index is 7
|
||||
TextAccess.cpp TextAccess::checkIndexInRange() WARNING: Tried to access index 9. Maximum index is 7
|
||||
TextAccess.cpp TextAccess::getLine() WARNING: Line numbers start with one, is 0
|
||||
TextAccess.cpp TextAccess::getLines() WARNING: Line numbers start with one, is 0
|
||||
Graph.cpp removeEdge() ERROR: Can't remove member edge, without removing the child node.
|
||||
TextAccess.cpp checkIndexIntervalInRange() WARNING: Index 'firstLine' has to be lower or equal index 'lastLine', is 2 > 1
|
||||
TextAccess.cpp checkIndexInRange() WARNING: Tried to access index 9. Maximum index is 7
|
||||
TextAccess.cpp checkIndexInRange() WARNING: Tried to access index 9. Maximum index is 7
|
||||
TextAccess.cpp getLine() WARNING: Line numbers start with one, is 0
|
||||
TextAccess.cpp getLines() WARNING: Line numbers start with one, is 0
|
||||
|
||||
@@ -40,7 +40,7 @@ std::string TextAccess::getFilePath() const
|
||||
|
||||
std::string TextAccess::getLine(const unsigned int lineNumber) const
|
||||
{
|
||||
if(lineNumber < 1)
|
||||
if (lineNumber < 1)
|
||||
{
|
||||
std::stringstream message;
|
||||
message << "Line numbers start with one, is " << lineNumber;
|
||||
@@ -96,7 +96,7 @@ std::string TextAccess::getText() const
|
||||
{
|
||||
std::string result = "";
|
||||
|
||||
for(unsigned int i = 0; i < m_lines.size(); i++)
|
||||
for (unsigned int i = 0; i < m_lines.size(); i++)
|
||||
{
|
||||
result += m_lines[i];
|
||||
}
|
||||
@@ -111,6 +111,12 @@ std::vector<std::string> TextAccess::readFile(const std::string& filePath)
|
||||
std::ifstream srcFile;
|
||||
srcFile.open(filePath);
|
||||
|
||||
if (srcFile.fail())
|
||||
{
|
||||
LOG_ERROR("Could not open file " + filePath);
|
||||
return result;
|
||||
}
|
||||
|
||||
while (!srcFile.eof())
|
||||
{
|
||||
std::string line;
|
||||
|
||||
@@ -481,8 +481,8 @@ public:
|
||||
CxxParser parser(client);
|
||||
|
||||
std::vector<std::string> filePaths;
|
||||
filePaths.push_back("data/test_header.h");
|
||||
filePaths.push_back("data/test_code.cpp");
|
||||
filePaths.push_back("data/CxxParserTestSuite/header.h");
|
||||
filePaths.push_back("data/CxxParserTestSuite/code.cpp");
|
||||
parser.parseFiles(filePaths);
|
||||
|
||||
TS_ASSERT_EQUALS(client->typedefs.size(), 1);
|
||||
|
||||
@@ -14,11 +14,12 @@ public:
|
||||
std::vector<std::string> extensions;
|
||||
extensions.push_back(".cpp");
|
||||
|
||||
std::vector<std::string> cppFiles = FileSystem::getSourceFilesFromDirectory("data/src",extensions);
|
||||
std::vector<std::string> cppFiles =
|
||||
FileSystem::getSourceFilesFromDirectory("data/FileSystemTestSuite", extensions);
|
||||
|
||||
TS_ASSERT_EQUALS(cppFiles.size(), 2)
|
||||
TS_ASSERT(isInVector(cppFiles, "data/src/main.cpp"))
|
||||
TS_ASSERT(isInVector(cppFiles, "data/src/Settings/sample.cpp"))
|
||||
TS_ASSERT_EQUALS(cppFiles.size(), 2);
|
||||
TS_ASSERT(isInVector(cppFiles, "data/FileSystemTestSuite/main.cpp"));
|
||||
TS_ASSERT(isInVector(cppFiles, "data/FileSystemTestSuite/Settings/sample.cpp"));
|
||||
}
|
||||
|
||||
void test_find_h_files()
|
||||
@@ -26,11 +27,12 @@ public:
|
||||
std::vector<std::string> extensions;
|
||||
extensions.push_back(".h");
|
||||
|
||||
std::vector<std::string> headerFiles = FileSystem::getSourceFilesFromDirectory("data/src",extensions);
|
||||
std::vector<std::string> headerFiles =
|
||||
FileSystem::getSourceFilesFromDirectory("data/FileSystemTestSuite", extensions);
|
||||
|
||||
TS_ASSERT_EQUALS(headerFiles.size(), 2)
|
||||
TS_ASSERT(isInVector(headerFiles, "data/src/tictactoe.h"))
|
||||
TS_ASSERT(isInVector(headerFiles, "data/src/Settings/player.h"))
|
||||
TS_ASSERT_EQUALS(headerFiles.size(), 2);
|
||||
TS_ASSERT(isInVector(headerFiles, "data/FileSystemTestSuite/tictactoe.h"));
|
||||
TS_ASSERT(isInVector(headerFiles, "data/FileSystemTestSuite/Settings/player.h"));
|
||||
}
|
||||
|
||||
void test_find_all_source_files()
|
||||
@@ -40,21 +42,22 @@ public:
|
||||
extensions.push_back(".hpp");
|
||||
extensions.push_back(".cpp");
|
||||
|
||||
std::vector<std::string> sourceFiles = FileSystem::getSourceFilesFromDirectory("data/src",extensions);
|
||||
std::vector<std::string> sourceFiles =
|
||||
FileSystem::getSourceFilesFromDirectory("data/FileSystemTestSuite", extensions);
|
||||
|
||||
TS_ASSERT_EQUALS(sourceFiles.size(), 5)
|
||||
TS_ASSERT_EQUALS(sourceFiles.size(), 5);
|
||||
}
|
||||
|
||||
void test_filesystem_finds_existing_files()
|
||||
{
|
||||
TS_ASSERT(FileSystem::exists("data/src"))
|
||||
TS_ASSERT(FileSystem::exists("data/src/tictactoe.h"));
|
||||
TS_ASSERT(FileSystem::exists("data/FileSystemTestSuite"));
|
||||
TS_ASSERT(FileSystem::exists("data/FileSystemTestSuite/tictactoe.h"));
|
||||
}
|
||||
|
||||
void test_filesystem_does_not_find_non_existing_files()
|
||||
{
|
||||
TS_ASSERT(!FileSystem::exists("data/foo"));
|
||||
TS_ASSERT(!FileSystem::exists("data/src/blabla.h"));
|
||||
TS_ASSERT(!FileSystem::exists("data/FileSystemTestSuite/foo"));
|
||||
TS_ASSERT(!FileSystem::exists("data/FileSystemTestSuite/blabla.h"));
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -6,13 +6,13 @@ class ProjectSettingsTestSuite : public CxxTest::TestSuite
|
||||
{
|
||||
public:
|
||||
void test_loading_projectSettings_from_file()
|
||||
{
|
||||
TS_ASSERT(ProjectSettings::getInstance()->load("data/test_ProjectSettings.xml"));
|
||||
{
|
||||
TS_ASSERT(ProjectSettings::getInstance()->load("data/ProjectSettingsTestSuite/settings.xml"));
|
||||
}
|
||||
|
||||
void test_load_sourcepath_from_file()
|
||||
{
|
||||
ProjectSettings::getInstance()->load("data/test_ProjectSettings.xml");
|
||||
ProjectSettings::getInstance()->load("data/ProjectSettingsTestSuite/settings.xml");
|
||||
TS_ASSERT_EQUALS(ProjectSettings::getInstance()->getSourcePath(), "data");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -90,7 +90,7 @@ public:
|
||||
|
||||
void test_textAccessFile_constructor()
|
||||
{
|
||||
std::string filePath = "data/test_text.txt";
|
||||
std::string filePath = "data/TextAccessTestSuite/text.txt";
|
||||
|
||||
std::shared_ptr<TextAccess> textAccess = TextAccess::createFromFile(filePath);
|
||||
|
||||
@@ -99,7 +99,7 @@ public:
|
||||
|
||||
void test_textAccessFile_lines_count()
|
||||
{
|
||||
std::string filePath = "data/test_text.txt";
|
||||
std::string filePath = "data/TextAccessTestSuite/text.txt";
|
||||
unsigned int lineCount = 7;
|
||||
|
||||
std::shared_ptr<TextAccess> textAccess = TextAccess::createFromFile(filePath);
|
||||
@@ -109,7 +109,7 @@ public:
|
||||
|
||||
void test_textAccessFile_lines_content()
|
||||
{
|
||||
std::string filePath = "data/test_text.txt";
|
||||
std::string filePath = "data/TextAccessTestSuite/text.txt";
|
||||
|
||||
std::shared_ptr<TextAccess> textAccess = TextAccess::createFromFile(filePath);
|
||||
std::vector<std::string> lines = textAccess->getLines(1, 4);
|
||||
@@ -123,7 +123,7 @@ public:
|
||||
|
||||
void test_textAccessFile_get_filePath()
|
||||
{
|
||||
std::string filePath = "data/test_text.txt";
|
||||
std::string filePath = "data/TextAccessTestSuite/text.txt";
|
||||
std::shared_ptr<TextAccess> textAccess = TextAccess::createFromFile(filePath);
|
||||
|
||||
TS_ASSERT_EQUALS(textAccess->getFilePath(), filePath);
|
||||
|
||||
Reference in New Issue
Block a user