Merge pull request #64 from QuasarApp/task_63

Fixing bugs: added comments for all test methods.
This commit is contained in:
Igor loschinin 2021-05-13 11:49:20 +03:00 committed by GitHub
commit 61d96a54e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 3 deletions

View File

@ -49,7 +49,12 @@ void ConfigParserTest::testParseConf() const {
CopyrighFixer::Config testConfig;
CopyrighFixer::ConfigParser testParserConf;
// This condition returns true if the parameters were parsed without error
// because the input parameters were specified as valid.
QVERIFY(testParserConf.parseOptions(testConfig));
// This condition returns true if signature that in Config have been parsed without error,
// because the input parameters were specified as valid.
QVERIFY(testConfig.getSignVal().isValid());
}
@ -60,19 +65,21 @@ void ConfigParserTest::testSrcKey() const {
CopyrighFixer::Config testConfig;
CopyrighFixer::ConfigParser testParserConf;
// This condition returns true in any case, even if the
// sourceDir key is not present in the parameter list or is not written correctly.
QVERIFY(testParserConf.parseOptions(testConfig));
}
void ConfigParserTest::testSrcPath() const {
QStringList lstOpt = {"-sourceDir", "./ParserProj", "-sign", "testSign.json"};
QuasarAppUtils::Params::parseParams(lstOpt);
CopyrighFixer::Config testConfig;
CopyrighFixer::ConfigParser testParserConf;
// This condition checks for the correct path to the sourceDir key.
// Should return false, because the path to lstOpt is not correct.
QVERIFY(!testParserConf.parseOptions(testConfig));
}
void ConfigParserTest::testSignKey() const {
@ -82,8 +89,9 @@ void ConfigParserTest::testSignKey() const {
CopyrighFixer::Config testConfig;
CopyrighFixer::ConfigParser testParserConf;
// This condition checks for the presence and validity of the sign
// parameter. If it is entered incorrectly or is missing return false.
QVERIFY(!testParserConf.parseOptions(testConfig));
}
void ConfigParserTest::testSignPath() const {
@ -93,6 +101,9 @@ void ConfigParserTest::testSignPath() const {
CopyrighFixer::Config testConfig;
CopyrighFixer::ConfigParser testParserConf;
// This condition checks for the validity of the path to file
// signature. After checking, the file is missing and returns false
// because lstOpt specifies a non-existing file path.
QVERIFY(!testParserConf.parseOptions(testConfig));
}
@ -100,6 +111,8 @@ void ConfigParserTest::testSignPath() const {
void ConfigParserTest::testParsOpt() {
QString testFileSign = "testSign.json";
// Initialization of a signature with random parameters.
generateRandomSign(testFileSign);
testParseConf();

View File

@ -44,8 +44,11 @@ CopyrighFixer::Signature SignTest::generateRandomSign(QString& filename) const {
void SignTest::testJsonObj() {
QString filename = "signature.json";
// Generating a randomly populated signature object.
CopyrighFixer::Signature baseSign = generateRandomSign(filename);
// The condition will return true because the signature structure
// is correct. Which is checked in the following condition.
QVERIFY(baseSign.toJson(filename));
QVERIFY(baseSign.isValid());