File indexing completed on 2024-04-14 03:43:57

0001 /*
0002     SPDX-FileCopyrightText: 2022 Nicolas Fella <nicolas.fella@gmx.de>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #include <QTest>
0007 
0008 #include "../src/blankanswer.h"
0009 
0010 class BlankTest : public QObject
0011 {
0012     Q_OBJECT
0013 
0014 private Q_SLOTS:
0015     void testBlank_data();
0016     void testBlank();
0017 };
0018 
0019 void BlankTest::testBlank_data()
0020 {
0021     QTest::addColumn<QString>("input");
0022     QTest::addColumn<QString>("blankedAnswer");
0023     QTest::addColumn<QString>("correctAnswer");
0024 
0025     QTest::addRow("empty") << ""
0026                            << ""
0027                            << "";
0028     QTest::addRow("no_blank") << "Just a sentence"
0029                               << ""
0030                               << "";
0031     QTest::addRow("one_blank") << "This is [one] test"
0032                                << "This is .......... test"
0033                                << "one";
0034     QTest::addRow("two_blank") << "This is [one] test with [two] blanks"
0035                                << "This is .......... test with .......... blanks"
0036                                << "one; two";
0037     QTest::addRow("two_words") << "[Two words] in one blank"
0038                                << ".......... in one blank"
0039                                << "Two words";
0040 }
0041 
0042 void BlankTest::testBlank()
0043 {
0044     QFETCH(QString, input);
0045     QFETCH(QString, blankedAnswer);
0046     QFETCH(QString, correctAnswer);
0047 
0048     BlankAnswer::BlankResult result = BlankAnswer::blankAnswer(input);
0049 
0050     QCOMPARE(result.blankedAnswer, blankedAnswer);
0051     QCOMPARE(result.correctAnswer, correctAnswer);
0052 }
0053 
0054 QTEST_MAIN(BlankTest)
0055 
0056 #include "blanktest.moc"