diff --git a/gui/test/main.cpp b/gui/test/main.cpp new file mode 100644 index 000000000..292ee9dfb --- /dev/null +++ b/gui/test/main.cpp @@ -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 . + */ + +#include +#include +#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(); +} diff --git a/gui/test/test.pro b/gui/test/test.pro index 3f496cd7b..892ded31d 100644 --- a/gui/test/test.pro +++ b/gui/test/test.pro @@ -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 diff --git a/gui/test/testtranslationhandler.cpp b/gui/test/testtranslationhandler.cpp index 884d708e3..dc0b17f3d 100644 --- a/gui/test/testtranslationhandler.cpp +++ b/gui/test/testtranslationhandler.cpp @@ -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 . + */ + #include #include +#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) diff --git a/gui/test/testtranslationhandler.h b/gui/test/testtranslationhandler.h new file mode 100644 index 000000000..6f4235889 --- /dev/null +++ b/gui/test/testtranslationhandler.h @@ -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 . + */ + +#include +#include + +class TestTranslationHandler: public QObject +{ + Q_OBJECT + +private slots: + void construct(); +}; diff --git a/gui/test/testxmlreport.cpp b/gui/test/testxmlreport.cpp new file mode 100644 index 000000000..291b07065 --- /dev/null +++ b/gui/test/testxmlreport.cpp @@ -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 . + */ + +#include +#include +#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)); +} + diff --git a/gui/test/testxmlreport.h b/gui/test/testxmlreport.h new file mode 100644 index 000000000..2304c5252 --- /dev/null +++ b/gui/test/testxmlreport.h @@ -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 . + */ + +#include +#include + +class TestXmlReport: public QObject +{ + Q_OBJECT + +private slots: + void testQuoteMessage(); + void testUnquoteMessage(); +};