-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_parser.cpp
More file actions
71 lines (58 loc) · 1.87 KB
/
test_parser.cpp
File metadata and controls
71 lines (58 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "test_parser.h"
#include "parser.h"
#include "test_minlength.h"
#include <QTest>
#include<QDebug>
Test_Parser::Test_Parser(QObject* parent) :
QObject(parent)
{
}
/**
*Testing if the program can read a txt file
* @brief Test_Parser::testParsing
*/
void Test_Parser::testParsing()
{
qDebug()<<"testParsing";
Parser* parser = new Parser();
//PATH to a sample file here
parser->parseFile(QDir().absoluteFilePath("/home/lupus/Desktop/text.txt"));
QVERIFY(parser->getText().length() > 0);
delete parser;
}
/**
*Testing the final output
* @brief Test_Parser::testResult
*/
void Test_Parser::testResult()
{
Parser* parser = new Parser();
parser->parseFile(QDir().absoluteFilePath("/home/lupus/Desktop/text.txt"));
parser->calculateStatistics(1);
QVERIFY(parser->getResult() == QString("der : 10 <br></br><br></br>- : 8 <br></br><br></br>Tochter : 6 <br></br><br></br>ist : 4 <br></br><br></br>ins : 3 <br></br><br></br>aufeinander : 2 <br></br><br></br>nichts.\r\nIn : 1 <br></br><br></br>"));
delete parser;
}
/**
* @brief Test_Parser::testWordLengthFiltering
*/
void Test_Parser::testWordLengthFiltering()
{
Parser* parser = new Parser();
parser->parseFile(QDir().absoluteFilePath("/home/lupus/Desktop/text.txt"));
parser->calculateStatistics(3);
QHash<QString, int>* hash = parser->getHashMap();
QVERIFY(getMinLenght(*hash) >= 3);
delete parser;
parser = new Parser();
parser->parseFile(QDir().absoluteFilePath("/home/lupus/Desktop/text.txt"));
parser->calculateStatistics(5);
hash = parser->getHashMap();
QVERIFY(getMinLenght(*hash) >= 5);
delete parser;
parser = new Parser();
parser->parseFile(QDir().absoluteFilePath("/home/lupus/Desktop/text.txt"));
parser->calculateStatistics(6);
hash = parser->getHashMap();
QVERIFY(getMinLenght(*hash) >= 6);
delete parser;
}