test: Fixed tests and removed test_log.txt

* Deleted PlainFileLogger
* Fixed clang warnings
This commit is contained in:
Eberhard Graether
2018-01-09 15:53:18 +01:00
parent 63590fc92d
commit c479493e02
13 changed files with 20 additions and 633 deletions
-2
View File
@@ -375,8 +375,6 @@ add_files(
utility/logging/LogManagerImplementation.cpp
utility/logging/LogManagerImplementation.h
utility/logging/LogMessage.h
utility/logging/PlainFileLogger.cpp
utility/logging/PlainFileLogger.h
utility/math/Color.h
utility/math/MatrixBase.h
+1 -1
View File
@@ -17,7 +17,7 @@ void DialogView::hideUnknownProgressDialog()
{
}
void DialogView::showProgressDialog(const std::string& title, const std::string& message, int progress)
void DialogView::showProgressDialog(const std::string& title, const std::string& message, size_t progress)
{
}
+1 -1
View File
@@ -19,7 +19,7 @@ public:
virtual void showUnknownProgressDialog(const std::string& title, const std::string& message);
virtual void hideUnknownProgressDialog();
virtual void showProgressDialog(const std::string& title, const std::string& message, int progress);
virtual void showProgressDialog(const std::string& title, const std::string& message, size_t progress);
virtual void hideProgressDialog();
virtual void startIndexingDialog(
@@ -1,47 +0,0 @@
#include "utility/logging/PlainFileLogger.h"
#include <fstream>
#include <sstream>
PlainFileLogger::PlainFileLogger(std::string filePath)
: Logger("PlainFileLogger")
, m_filePath(filePath)
{
std::ofstream fileStream;
fileStream.open(m_filePath, std::ios::trunc);
fileStream.close();
}
PlainFileLogger::~PlainFileLogger()
{
}
void PlainFileLogger::logString(std::string str)
{
std::ofstream fileStream;
fileStream.open(m_filePath, std::ios::app);
fileStream << str;
fileStream.close();
}
void PlainFileLogger::logInfo(const LogMessage& message)
{
logMessage("INFO", message);
}
void PlainFileLogger::logWarning(const LogMessage& message)
{
logMessage("WARNING", message);
}
void PlainFileLogger::logError(const LogMessage& message)
{
logMessage("ERROR", message);
}
void PlainFileLogger::logMessage(const std::string& type, const LogMessage& message)
{
std::stringstream ss;
ss << message.getFileName() << " " << type << ": " << message.message << std::endl;
logString(ss.str());
}
-27
View File
@@ -1,27 +0,0 @@
#ifndef PLAIN_FILE_LOGGER_H
#define PLAIN_FILE_LOGGER_H
#include <string>
#include "utility/logging/Logger.h"
#include "utility/logging/LogMessage.h"
class PlainFileLogger: public Logger
{
public:
PlainFileLogger(std::string filePath);
virtual ~PlainFileLogger();
void logString(std::string str);
private:
virtual void logInfo(const LogMessage& message);
virtual void logWarning(const LogMessage& message);
virtual void logError(const LogMessage& message);
void logMessage(const std::string& type, const LogMessage& message);
std::string m_filePath;
};
#endif // PLAIN_FILE_LOGGER_H
+3 -3
View File
@@ -56,7 +56,7 @@ void QtDialogView::hideUnknownProgressDialog()
setParentWindow(nullptr);
}
void QtDialogView::showProgressDialog(const std::string& title, const std::string& message, int progress)
void QtDialogView::showProgressDialog(const std::string& title, const std::string& message, size_t progress)
{
m_onQtThread(
[=]()
@@ -73,8 +73,8 @@ void QtDialogView::showProgressDialog(const std::string& title, const std::strin
else
{
sendStatusMessage = (
window->getTitle() != title ||
window->getMessage() != message ||
window->getTitle() != title ||
window->getMessage() != message ||
window->getProgress() != progress
);
}
+1 -1
View File
@@ -32,7 +32,7 @@ public:
virtual void showUnknownProgressDialog(const std::string& title, const std::string& message) override;
virtual void hideUnknownProgressDialog() override;
virtual void showProgressDialog(const std::string& title, const std::string& message, int progress) override;
virtual void showProgressDialog(const std::string& title, const std::string& message, size_t progress) override;
virtual void hideProgressDialog() override;
virtual void startIndexingDialog(
@@ -429,10 +429,10 @@ QtProjectWizzardContentPathsHeaderSearch::QtProjectWizzardContentPathsHeaderSear
std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window, bool isCDB
)
: QtProjectWizzardContentPaths(settings, window)
, m_showValidationResultFunctor(std::bind(
&QtProjectWizzardContentPathsHeaderSearch::showValidationResult, this, std::placeholders::_1))
, m_showDetectedIncludesResultFunctor(std::bind(
&QtProjectWizzardContentPathsHeaderSearch::showDetectedIncludesResult, this, std::placeholders::_1))
, m_showValidationResultFunctor(std::bind(
&QtProjectWizzardContentPathsHeaderSearch::showValidationResult, this, std::placeholders::_1))
, m_isCdb(isCDB)
{
setTitleString(m_isCdb ? "Additional Include Paths" : "Include Paths");
@@ -707,7 +707,7 @@ void QtProjectWizzardContentPathsHeaderSearch::showDetectedIncludesResult(const
"Detected Include Paths",
(
"<p>The following <b>" + std::to_string(additionalHeaderSearchPaths.size()) + "</b> include paths have been "
"detected and will be added to the include paths that are already defined by this Source Group.<b>"
"detected and will be added to the include paths that are already defined by this Source Group.<b>"
).c_str()
);
@@ -131,6 +131,7 @@ private slots:
private:
void showDetectedIncludesResult(const std::set<FilePath>& detectedHeaderSearchPaths);
void showValidationResult(const std::vector<IncludeDirective>& unresolvedIncludes);
QtThreadedFunctor<std::set<FilePath>> m_showDetectedIncludesResultFunctor;
QtThreadedFunctor<std::vector<IncludeDirective>> m_showValidationResultFunctor;
+10 -10
View File
@@ -71,47 +71,47 @@ public:
void test_header_search_path_detection_does_not_find_path_relative_to_including_file()
{
std::set<FilePath> headerSearchDirectoies = IncludeProcessing::getHeaderSearchDirectories(
std::set<FilePath> headerSearchDirectories = IncludeProcessing::getHeaderSearchDirectories(
{ FilePath("data/CxxIncludeProcessingTestSuite/test_header_search_path_detection_does_not_find_path_relative_to_including_file/a.cpp") },
{ FilePath("data/CxxIncludeProcessingTestSuite/test_header_search_path_detection_does_not_find_path_relative_to_including_file") },
1, [&](float) {}
);
TS_ASSERT(headerSearchDirectoies.empty());
TS_ASSERT(headerSearchDirectories.empty());
}
void test_header_search_path_detection_finds_path_inside_sub_directory()
{
std::set<FilePath> headerSearchDirectoies = IncludeProcessing::getHeaderSearchDirectories(
std::set<FilePath> headerSearchDirectories = IncludeProcessing::getHeaderSearchDirectories(
{ FilePath("data/CxxIncludeProcessingTestSuite/test_header_search_path_detection_finds_path_inside_sub_directory/a.cpp") },
{ FilePath("data/CxxIncludeProcessingTestSuite/test_header_search_path_detection_finds_path_inside_sub_directory") },
1, [&](float) {}
);
TS_ASSERT(!headerSearchDirectoies.empty());
if (!headerSearchDirectoies.empty())
TS_ASSERT(!headerSearchDirectories.empty());
if (!headerSearchDirectories.empty())
{
TS_ASSERT_EQUALS(
"CxxIncludeProcessingTestSuite/test_header_search_path_detection_finds_path_inside_sub_directory/include",
headerSearchDirectoies.begin()->getRelativeTo(FilePath("data").getAbsolute()).str()
headerSearchDirectories.begin()->getRelativeTo(FilePath("data").getAbsolute()).str()
);
}
}
void test_header_search_path_detection_finds_path_relative_to_sub_directory()
{
std::set<FilePath> headerSearchDirectoies = IncludeProcessing::getHeaderSearchDirectories(
std::set<FilePath> headerSearchDirectories = IncludeProcessing::getHeaderSearchDirectories(
{ FilePath("data/CxxIncludeProcessingTestSuite/test_header_search_path_detection_finds_path_relative_to_sub_directory/a.cpp") },
{ FilePath("data/CxxIncludeProcessingTestSuite/test_header_search_path_detection_finds_path_relative_to_sub_directory") },
1, [&](float) {}
);
TS_ASSERT(!headerSearchDirectoies.empty());
if (!headerSearchDirectoies.empty())
TS_ASSERT(!headerSearchDirectories.empty());
if (!headerSearchDirectories.empty())
{
TS_ASSERT_EQUALS(
"CxxIncludeProcessingTestSuite/test_header_search_path_detection_finds_path_relative_to_sub_directory/include",
headerSearchDirectoies.begin()->getRelativeTo(FilePath("data").getAbsolute()).str()
headerSearchDirectories.begin()->getRelativeTo(FilePath("data").getAbsolute()).str()
);
}
}
-11
View File
@@ -2,9 +2,6 @@
#include <iostream>
#include "utility/logging/FileLogger.h"
#include "utility/logging/LogManager.h"
#include "utility/logging/PlainFileLogger.h"
#include "settings/ApplicationSettings.h"
TestSuiteFixture::TestSuiteFixture()
@@ -17,12 +14,6 @@ TestSuiteFixture::~TestSuiteFixture()
bool TestSuiteFixture::setUpWorld()
{
LogManager* logManager = LogManager::getInstance().get();
logManager->setLoggingEnabled(true);
logManager->addLogger(std::make_shared<PlainFileLogger>("data/log/test_log.txt"));
logManager->addLogger(std::make_shared<FileLogger>());
#ifdef __linux__
const std::string homedir = getenv("HOME");
@@ -51,7 +42,5 @@ bool TestSuiteFixture::setUpWorld()
bool TestSuiteFixture::tearDownWorld()
{
LogManager::destroyInstance();
return true;
}