diff --git a/src/CopyrighFixer/CopyrighFixer/configparser.cpp b/src/CopyrighFixer/CopyrighFixer/configparser.cpp index 5e87131..140ef17 100644 --- a/src/CopyrighFixer/CopyrighFixer/configparser.cpp +++ b/src/CopyrighFixer/CopyrighFixer/configparser.cpp @@ -7,7 +7,6 @@ #include "configparser.h" #include <quasarapp.h> -#include <iostream> namespace CopyrighFixer { @@ -15,33 +14,34 @@ ConfigParser::ConfigParser() { } -const Config ConfigParser::parseOptions(const Config &conf) const { - - Config configOption = conf; +bool ConfigParser::parseOptions(Config &conf) const { if (QuasarAppUtils::Params::isEndable("sourceDir")) { - configOption.setSourceDir(QuasarAppUtils::Params::getArg("sourceDir")); + conf.setSourceDir(QuasarAppUtils::Params::getArg("sourceDir")); } else { - std::cout << "Warning: Not option sourceDir" << std::endl; + QuasarAppUtils::Params::log("Error: Not option sourceDir.", + QuasarAppUtils::VerboseLvl::Error); + return false; } if (QuasarAppUtils::Params::isEndable("sign")) { - Signature *signature = new Signature; - configOption.setSingValue(*signature); -// configOption.setSingValue(QuasarAppUtils::Params::getArg("sign")); + Signature signature; + conf.setSingValue(signature); } else { - std::cout << "Warning: Not option sign" << std::endl; + QuasarAppUtils::Params::log("Warning: Not option sign.", + QuasarAppUtils::VerboseLvl::Warning); } if (QuasarAppUtils::Params::isEndable("currentOwner")) { - configOption.setCurrOwn(QuasarAppUtils::Params::getArg("currentOwner")); + conf.setCurrOwn(QuasarAppUtils::Params::getArg("currentOwner")); } else { - std::cout << "Warning: Not option currentOwner" << std::endl; + QuasarAppUtils::Params::log("Warning: Not option currentOwner.", + QuasarAppUtils::VerboseLvl::Warning); } - return configOption; + return true; + }; - } diff --git a/src/CopyrighFixer/CopyrighFixer/configparser.h b/src/CopyrighFixer/CopyrighFixer/configparser.h index 4f5fc4b..b24c8e1 100644 --- a/src/CopyrighFixer/CopyrighFixer/configparser.h +++ b/src/CopyrighFixer/CopyrighFixer/configparser.h @@ -24,7 +24,7 @@ public: * @brief parseOptions This a method that will parse all input options. * @return The config object. */ - const Config parseOptions(const Config &conf) const; + bool parseOptions(Config &conf) const; }; diff --git a/tests/tstMain.cpp b/tests/tstMain.cpp index 21f63f8..a981e7f 100644 --- a/tests/tstMain.cpp +++ b/tests/tstMain.cpp @@ -7,6 +7,7 @@ #include <QtTest> #include "cfixertest.h" +#include "configparsertest.h" // Use This macros for initialize your own test classes. // Check exampletests @@ -31,6 +32,7 @@ private slots: // BEGIN TESTS CASES TestCase(exampleTest, ExampleTest) + TestCase(configParserTest, ConfigParserTest) // END TEST CASES private: diff --git a/tests/units/configparsertest.cpp b/tests/units/configparsertest.cpp new file mode 100644 index 0000000..14ab648 --- /dev/null +++ b/tests/units/configparsertest.cpp @@ -0,0 +1,20 @@ +//# +//# Copyright (C) 2020-2021 QuasarApp. +//# Distributed under the lgplv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + +#include "configparsertest.h" + +ConfigParserTest::ConfigParserTest() { + +} + +void ConfigParserTest::test() { + testParsOpt(); +} + +void ConfigParserTest::testParsOpt() { + +} diff --git a/tests/units/configparsertest.h b/tests/units/configparsertest.h new file mode 100644 index 0000000..7d1fd3b --- /dev/null +++ b/tests/units/configparsertest.h @@ -0,0 +1,25 @@ +//# +//# Copyright (C) 2020-2021 QuasarApp. +//# Distributed under the lgplv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + +#ifndef CONFIGPARSERTEST_H +#define CONFIGPARSERTEST_H +#include "test.h" +#include "testutils.h" +#include "CopyrighFixer/configparser.h" + + +class ConfigParserTest: public Test, protected TestUtils { +public: + ConfigParserTest(); + ~ConfigParserTest(); + + void test(); + void testParsOpt(); + +}; + +#endif // CONFIGPARSERTEST_H