GUITEST: Add couple of tests for XmlReport.

This commit is contained in:
Kimmo Varis 2011-02-09 01:58:26 +02:00
parent 73e746cfd8
commit 9dd1515f6f
6 changed files with 170 additions and 21 deletions

35
gui/test/main.cpp Normal file
View File

@ -0,0 +1,35 @@
/*
* Cppcheck - A tool for static C/C++ code analysis
* Copyright (C) 2007-2011 Daniel Marjamäki and Cppcheck team.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QCoreApplication>
#include <QtTest>
#include "testtranslationhandler.h"
#include "testxmlreport.h"
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
TestTranslationHandler testTtranslationHandler;
QTest::qExec(&testTtranslationHandler);
TestXmlReport testXmlReport;
QTest::qExec(&testXmlReport);
return a.exec();
}

View File

@ -1,10 +1,22 @@
TEMPLATE = app
TARGET =
CONFIG += qtestlib
DEPENDPATH += . ..
INCLUDEPATH += . ..
SOURCES += testtranslationhandler.cpp
HEADERS += ../translationhandler.h
SOURCES += ../translationhandler.cpp
TEMPLATE = app
TARGET = test
CONFIG += qtestlib
DEPENDPATH += . ..
INCLUDEPATH += . ..
# tests
SOURCES += main.cpp \
testtranslationhandler.cpp \
testxmlreport.cpp
HEADERS += testtranslationhandler.h \
testxmlreport.h
# GUI
SOURCES += report.cpp \
../translationhandler.cpp \
../xmlreport.cpp
HEADERS += report.h \
../translationhandler.h \
../xmlreport.h

View File

@ -1,21 +1,29 @@
/*
* Cppcheck - A tool for static C/C++ code analysis
* Copyright (C) 2007-2011 Daniel Marjamäki and Cppcheck team.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QtTest>
#include <QObject>
#include "testtranslationhandler.h"
#include "translationhandler.h"
class TestTranslationHandler: public QObject
{
Q_OBJECT
private slots:
void construct();
};
void TestTranslationHandler::construct()
{
TranslationHandler handler;
QCOMPARE(10, handler.GetNames().size());
QCOMPARE(QString("en"), handler.GetCurrentLanguage());
}
#include "testtranslationhandler.moc"
QTEST_MAIN(TestTranslationHandler)

View File

@ -0,0 +1,28 @@
/*
* Cppcheck - A tool for static C/C++ code analysis
* Copyright (C) 2007-2011 Daniel Marjamäki and Cppcheck team.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QtTest>
#include <QObject>
class TestTranslationHandler: public QObject
{
Q_OBJECT
private slots:
void construct();
};

View File

@ -0,0 +1,37 @@
/*
* Cppcheck - A tool for static C/C++ code analysis
* Copyright (C) 2007-2011 Daniel Marjamäki and Cppcheck team.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QtTest>
#include <QObject>
#include "testxmlreport.h"
#include "xmlreport.h"
void TestXmlReport::testQuoteMessage()
{
const QString toQuote("abcdefgh&\"'<>12345");
const QString quoted("abcdefgh&amp;&quot;&#039;&lt;&gt;12345");
QCOMPARE(quoted, XmlReport::quoteMessage(toQuote));
}
void TestXmlReport::testUnquoteMessage()
{
const QString toQuote("abcdefgh&\"'<>12345");
const QString quoted("abcdefgh&amp;&quot;&#039;&lt;&gt;12345");
QCOMPARE(toQuote, XmlReport::unquoteMessage(quoted));
}

29
gui/test/testxmlreport.h Normal file
View File

@ -0,0 +1,29 @@
/*
* Cppcheck - A tool for static C/C++ code analysis
* Copyright (C) 2007-2011 Daniel Marjamäki and Cppcheck team.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QtTest>
#include <QObject>
class TestXmlReport: public QObject
{
Q_OBJECT
private slots:
void testQuoteMessage();
void testUnquoteMessage();
};