Commit 5923c48a authored by Laurent Montel's avatar Laurent Montel 😁

Add autotest

parent 7eafb03d
{
"context": {
"length": 8,
"offset": 3,
"text": "Je suis pas là, il va se basé sur la poile "
},
"ignoreForIncompleteSentence": false,
"length": 8,
"message": "Voulez-vous écrire \"ne suis pas\" ?",
"offset": 3,
"replacements": [
{
"value": "ne suis pas"
}
],
"rule": {
"category": {
"id": "CAT_GRAMMAIRE",
"name": "Grammaire"
},
"description": "négation sans NE",
"id": "P_V_PAS",
"issueType": "uncategorized",
"subId": "4",
"urls": [
{
"value": "http://www.academie-francaise.fr/ne"
}
]
},
"sentence": "Je suis pas là, il va se basé sur la poile",
"shortMessage": "",
"type": {
"typeName": "Other"
}
}
......@@ -18,6 +18,8 @@
*/
#include "languagetoolgrammarerrortest.h"
#include "languagetoolgrammarerror.h"
#include <QJsonDocument>
#include <QTest>
QTEST_GUILESS_MAIN(LanguageToolGrammarErrorTest)
LanguageToolGrammarErrorTest::LanguageToolGrammarErrorTest(QObject *parent)
......@@ -25,12 +27,43 @@ LanguageToolGrammarErrorTest::LanguageToolGrammarErrorTest(QObject *parent)
{
}
void LanguageToolGrammarErrorTest::shouldParseJson_data()
{
//TODO
QTest::addColumn<QString>("fileName");
QTest::addColumn<int>("nbBlock");
QTest::addColumn<LanguageToolGrammarError>("error");
LanguageToolGrammarError err;
err.setBlockId(2);
err.setStart(3);
err.setLength(8);
err.setColor(QColor(Qt::red));
err.setSuggestions(QStringList() << QStringLiteral("ne suis pas"));
err.setError(QStringLiteral("Voulez-vous écrire \"ne suis pas\" ?"));
//err.setOption(QStringLiteral("maj"));
// err.setRule(QStringLiteral("majuscule_après_point"));
err.setUrl(QStringLiteral("http://www.academie-francaise.fr/ne"));
QTest::newRow("parse-error1") << QStringLiteral("parse-error1") << 1 << err;
}
void LanguageToolGrammarErrorTest::shouldParseJson()
{
//TODO
QFETCH(QString, fileName);
QFETCH(int, nbBlock);
QFETCH(LanguageToolGrammarError, error);
const QString originalJsonFile = QLatin1String(LANGUAGETOOL_DATA_DIR) + QLatin1Char('/') + fileName + QStringLiteral(".json");
QFile f(originalJsonFile);
QVERIFY(f.open(QIODevice::ReadOnly));
const QByteArray content = f.readAll();
f.close();
const QJsonDocument doc = QJsonDocument::fromJson(content);
const QJsonObject fields = doc.object();
LanguageToolGrammarError parser;
parser.parse(fields, nbBlock);
const bool compare = (parser == error);
if (!compare) {
qDebug() << " Parser " << parser;
qDebug() << " error " << error;
}
QVERIFY(compare);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment