mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-01 00:46:20 -05:00
Add unit tests
This commit is contained in:
parent
60b308e1b6
commit
c5817cb413
@ -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})
|
||||
|
57
tests/src/server/wms/test_qgsserver_wms_exceptions.cpp
Normal file
57
tests/src/server/wms/test_qgsserver_wms_exceptions.cpp
Normal 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"
|
Loading…
x
Reference in New Issue
Block a user