GUITEST: Add couple of tests for XmlReport.
This commit is contained in:
parent
73e746cfd8
commit
9dd1515f6f
|
@ -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();
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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();
|
||||
};
|
|
@ -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&"'<>12345");
|
||||
QCOMPARE(quoted, XmlReport::quoteMessage(toQuote));
|
||||
}
|
||||
|
||||
void TestXmlReport::testUnquoteMessage()
|
||||
{
|
||||
const QString toQuote("abcdefgh&\"'<>12345");
|
||||
const QString quoted("abcdefgh&"'<>12345");
|
||||
QCOMPARE(toQuote, XmlReport::unquoteMessage(quoted));
|
||||
}
|
||||
|
|
@ -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();
|
||||
};
|
Loading…
Reference in New Issue