From 1bbee62a79f366b9c24811d5004d31a2e3773809 Mon Sep 17 00:00:00 2001 From: dismine Date: Thu, 22 May 2014 11:08:12 +0300 Subject: [PATCH] App for running tests for QmuParser library. --HG-- branch : feature --- src/app/app.pro | 2 +- src/src.pro | 11 ++--- src/test/ParserTest/ParserTest.pro | 66 +++++++++++++++++++++++++ src/test/ParserTest/main.cpp | 77 ++++++++++++++++++++++++++++++ 4 files changed, 149 insertions(+), 7 deletions(-) create mode 100644 src/test/ParserTest/ParserTest.pro create mode 100644 src/test/ParserTest/main.cpp diff --git a/src/app/app.pro b/src/app/app.pro index 49c819979..3b3a4c182 100644 --- a/src/app/app.pro +++ b/src/app/app.pro @@ -48,7 +48,7 @@ SOURCES += \ tablewindow.cpp \ stable.cpp \ version.cpp \ - options.cpp + options.cpp HEADERS += \ mainwindow.h \ diff --git a/src/src.pro b/src/src.pro index 0157aa5ae..6e951fd25 100644 --- a/src/src.pro +++ b/src/src.pro @@ -1,17 +1,16 @@ TEMPLATE = subdirs -#SUBDIRS = sub_lib sub_tests sub_app SUBDIRS = \ sub_app \ - sub_lib_qmuparser + sub_lib_qmuparser \ + test/ParserTest -#sub_lib_qmuparser.subdir = libs/qmuparser sub_lib_qmuparser.file = libs/qmuparser/qmuparser.pro -#sub_tests.file = tests/proj.pro -#sub_tests.depends = sub_lib -#sub_app.subdir = app +sub_parser_tests.file = test/ParserTest/ParserTest.pro +sub_parser_tests.depends = sub_lib_qmuparser sub_app.file = app/app.pro sub_app.depends = sub_lib_qmuparser + #This makes it possible to use make -j 4 on your fancy quad-core system with a project that consists of several #components that depend on each other. To simplify the process a bit, the following test function can be defined: diff --git a/src/test/ParserTest/ParserTest.pro b/src/test/ParserTest/ParserTest.pro new file mode 100644 index 000000000..e7da26428 --- /dev/null +++ b/src/test/ParserTest/ParserTest.pro @@ -0,0 +1,66 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2014-05-21T20:43:38 +# +#------------------------------------------------- + +QT += core + +QT -= gui + +TARGET = ParserTest +CONFIG += console c++11 +CONFIG -= app_bundle debug_and_release debug_and_release_target + +TEMPLATE = app + +# directory for executable file +DESTDIR = bin + +# objecs files +OBJECTS_DIR = obj + +SOURCES += main.cpp + +unix { +QMAKE_CXX = ccache g++ +} + +CONFIG(debug, debug|release){ + # Debug + unix { + *-g++{ + QMAKE_CXXFLAGS += -isystem "/usr/include/qt5" -isystem "/usr/include/qt5/QtCore" \ + -O0 -Wall -Wextra -pedantic -Weffc++ -Woverloaded-virtual -Wctor-dtor-privacy \ + -Wnon-virtual-dtor -Wold-style-cast -Wconversion -Winit-self -Wstack-protector \ + -Wunreachable-code -Wcast-align -Wcast-qual -Wdisabled-optimization -Wfloat-equal \ + -Wformat=2 -Wimport \ + -Winvalid-pch -Wunsafe-loop-optimizations -Wlong-long -Wmissing-format-attribute \ + -Wmissing-include-dirs -Wpacked -Wredundant-decls -Winline \ + -Wswitch-default -Wswitch-enum -Wuninitialized -Wvariadic-macros \ + -Wlogical-op -Wnoexcept -Wmissing-noreturn -Wpointer-arith\ + -Wstrict-null-sentinel -Wstrict-overflow=5 -Wundef -Wno-unused -gdwarf-3 \ + -ftrapv + } + } else { + *-g++{#Don't use additional GCC keys on Windows system. + QMAKE_CXXFLAGS += -O0 -Wall -Wextra -pedantic + } + } +}else{ + # Release + *-g++{ + QMAKE_CXXFLAGS += -O2 + } +} + +# Remove generated files at cleaning +QMAKE_DISTCLEAN += $${DESTDIR}/* \ + $${OBJECTS_DIR}/* + +win32:CONFIG(release, debug|release): LIBS += -L../../libs/qmuparser/bin -lqmuparser2 +else:win32:CONFIG(debug, debug|release): LIBS += -L../../libs/qmuparser/bin -lqmuparser2 +else:unix: LIBS += -L../../libs/qmuparser/bin -lqmuparser + +INCLUDEPATH += ../../libs/qmuparser +DEPENDPATH += ../../libs/qmuparser diff --git a/src/test/ParserTest/main.cpp b/src/test/ParserTest/main.cpp new file mode 100644 index 000000000..6158c339c --- /dev/null +++ b/src/test/ParserTest/main.cpp @@ -0,0 +1,77 @@ +/************************************************************************ + ** + ** @file main.cpp + ** @author Roman Telezhynskyi + ** @date 21 5, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2014 Valentina project + ** All Rights Reserved. + ** + ** Valentina 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. + ** + ** Valentina 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 Valentina. If not, see . + ** + *************************************************************************/ + +#include +#include +#include +#include "../../libs/qmuparser/qmuparsertest.h" + +using namespace qmu; + +//--------------------------------------------------------------------------------------------------------------------- +void testMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg) +{ + QByteArray localMsg = msg.toLocal8Bit(); + switch (type) + { + case QtDebugMsg: + fprintf(stderr, "%s\n", localMsg.constData()); + break; + case QtWarningMsg: + fprintf(stderr, "Warning: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, + context.function); + break; + case QtCriticalMsg: + fprintf(stderr, "Critical: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, + context.function); + break; + case QtFatalMsg: + fprintf(stderr, "Fatal: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, + context.function); + abort(); + default: + break; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +int main(int argc, char *argv[]) +{ + QCoreApplication a(argc, argv); + + qInstallMessageHandler(testMessageOutput); + + qDebug() << "-----------------------------------------------------------"; + qDebug() << "Running test suite:\n"; + + + qmu::Test::QmuParserTester pt; + pt.Run(); + + return a.exec(); +}