File indexing completed on 2024-05-05 04:35:28

0001 /*
0002  * This file is part of KDevelop Krazy2 Plugin.
0003  *
0004  * Copyright 2012 Daniel Calviño Sánchez <danxuliu@gmail.com>
0005  *
0006  * This program is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU General Public License
0008  * as published by the Free Software Foundation; either version 2
0009  * of the License, or (at your option) any later version.
0010  *
0011  * This program is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014  * GNU General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU General Public License
0017  * along with this program. If not, see <http://www.gnu.org/licenses/>.
0018  */
0019 
0020 #include <QTest>
0021 
0022 #include "../issue.h"
0023 #include "../checker.h"
0024 
0025 class IssueTest: public QObject {
0026 Q_OBJECT
0027 private slots:
0028 
0029     void testConstructor();
0030 
0031     void testSetMessage();
0032 
0033     void testSetFileName();
0034 
0035     void testSetLine();
0036 
0037     void testSetChecker();
0038 
0039 };
0040 
0041 void IssueTest::testConstructor() {
0042     Issue issue;
0043 
0044     QCOMPARE(issue.message(), QString());
0045     QCOMPARE(issue.fileName(), QString());
0046     QCOMPARE(issue.line(), -1);
0047     QCOMPARE(issue.checker(), (Checker*)nullptr);
0048 }
0049 
0050 void IssueTest::testSetMessage() {
0051     Issue issue;
0052     issue.setMessage("The message");
0053 
0054     QCOMPARE(issue.message(), QString("The message"));
0055 }
0056 
0057 void IssueTest::testSetFileName() {
0058     Issue issue;
0059     issue.setFileName("The fileName");
0060 
0061     QCOMPARE(issue.fileName(), QString("The fileName"));
0062 }
0063 
0064 void IssueTest::testSetLine() {
0065     Issue issue;
0066     issue.setLine(42);
0067 
0068     QCOMPARE(issue.line(), 42);
0069 }
0070 
0071 void IssueTest::testSetChecker() {
0072     Issue issue;
0073     Checker checker;
0074     issue.setChecker(&checker);
0075 
0076     QCOMPARE(issue.checker(), &checker);
0077 }
0078 
0079 QTEST_GUILESS_MAIN(IssueTest)
0080 
0081 #include "issuetest.moc"