File indexing completed on 2024-09-15 03:31:03
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 YourAnswerTest : public QObject 0011 { 0012 Q_OBJECT 0013 0014 private Q_SLOTS: 0015 void testYourAnswer_data(); 0016 void testYourAnswer(); 0017 }; 0018 0019 void YourAnswerTest::testYourAnswer_data() 0020 { 0021 QTest::addColumn<QString>("givenAnswer"); 0022 QTest::addColumn<QString>("blankedAnswer"); 0023 QTest::addColumn<QString>("expectedYourAnswer"); 0024 0025 QTest::addRow("no_blank") << "Hallo" 0026 << "" 0027 << "Hallo"; 0028 0029 QTest::addRow("one_blank_empty") << "" 0030 << "One blank .........." 0031 << "<qt>One blank <u></u></qt>"; 0032 0033 QTest::addRow("one_blank_not_empty") << "filled" 0034 << "One blank .........." 0035 << "<qt>One blank <u>filled</u></qt>"; 0036 0037 QTest::addRow("two_blanks_filled") << "blanks;filled" 0038 << "Two .......... .........." 0039 << "<qt>Two <u>blanks</u> <u>filled</u></qt>"; 0040 0041 QTest::addRow("two_blanks_one_filled") << "blanks" 0042 << "Two .......... .........." 0043 << "<qt>Two <u>blanks</u> <u></u></qt>"; 0044 0045 QTest::addRow("two_blanks_empty") << "" 0046 << "Two .......... .........." 0047 << "<qt>Two <u></u> <u></u></qt>"; 0048 } 0049 0050 void YourAnswerTest::testYourAnswer() 0051 { 0052 QFETCH(QString, givenAnswer); 0053 QFETCH(QString, blankedAnswer); 0054 QFETCH(QString, expectedYourAnswer); 0055 0056 const QString result = BlankAnswer::yourAnswerResult(givenAnswer, blankedAnswer); 0057 0058 QCOMPARE(result, expectedYourAnswer); 0059 } 0060 0061 QTEST_MAIN(YourAnswerTest) 0062 0063 #include "youranswertest.moc"