Add unit tests

This commit is contained in:
Blottiere Paul 2019-03-27 16:14:10 +01:00
parent 60b308e1b6
commit c5817cb413
2 changed files with 65 additions and 1 deletions

View File

@ -37,13 +37,19 @@ SET(MODULE_WMS_SRCS
${CMAKE_SOURCE_DIR}/src/server/services/wms/qgswmsrendercontext.cpp
)
SET(MODULE_WMS_HDRS
${CMAKE_SOURCE_DIR}/src/server/services/wms/qgswmsserviceexception.h
)
QT5_WRAP_CPP(MODULE_WMS_MOC_SRCS ${MODULE_WMS_HDRS})
MACRO (ADD_QGIS_TEST TESTSRC)
SET (TESTNAME ${TESTSRC})
STRING(REPLACE "test" "" TESTNAME ${TESTNAME})
STRING(REPLACE "qgs" "" TESTNAME ${TESTNAME})
STRING(REPLACE ".cpp" "" TESTNAME ${TESTNAME})
SET (TESTNAME "qgis_${TESTNAME}test")
ADD_EXECUTABLE(${TESTNAME} ${TESTSRC} ${MODULE_WMS_SRCS})
ADD_EXECUTABLE(${TESTNAME} ${TESTSRC} ${MODULE_WMS_SRCS} ${MODULE_WMS_MOC_SRCS})
SET_TARGET_PROPERTIES(${TESTNAME} PROPERTIES AUTOMOC TRUE)
TARGET_LINK_LIBRARIES(${TESTNAME}
${Qt5Core_LIBRARIES}
@ -64,6 +70,7 @@ ENDMACRO (ADD_QGIS_TEST)
SET(TESTS
test_qgsserver_wms_dxf.cpp
test_qgsserver_wms_exceptions.cpp
)
FOREACH(TESTSRC ${TESTS})

View File

@ -0,0 +1,57 @@
/***************************************************************************
test_qgsserver_wms_exceptions.cpp
---------------------------------
Date : 27 Mar 2019
Copyright : (C) 2019 by Paul Blottiere
Email : paul dot blottiere @ oslandia.com
***************************************************************************
* *
* 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 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "qgstest.h"
#include "qgswmsserviceexception.h"
/**
* \ingroup UnitTests
* This is a unit test for the WMS Exceptions
*/
class TestQgsServerWmsExceptions : public QObject
{
Q_OBJECT
private slots:
void initTestCase();
void cleanupTestCase();
void exception_code();
};
void TestQgsServerWmsExceptions::initTestCase()
{
QgsApplication::init();
QgsApplication::initQgis();
}
void TestQgsServerWmsExceptions::cleanupTestCase()
{
QgsApplication::exitQgis();
}
void TestQgsServerWmsExceptions::exception_code()
{
QgsWms::QgsServiceException::ExceptionCode code = QgsWms::QgsServiceException::OGC_INVALID_FORMAT;
QgsWms::QgsServiceException exception0( code, QString(), 400 );
QCOMPARE( exception0.code(), QString( "InvalidFormat" ) );
code = QgsWms::QgsServiceException::QGIS_ERROR;
QgsWms::QgsServiceException exception1( code, QString(), 400 );
QCOMPARE( exception1.code(), QString( "Error" ) );
}
QGSTEST_MAIN( TestQgsServerWmsExceptions )
#include "test_qgsserver_wms_exceptions.moc"