Skip to content
Permalink
Browse files

Merge pull request #233 from homann/test_qgsclipper

Test Friday! QgsClipper test
  • Loading branch information
homann committed Sep 14, 2012
2 parents c328539 + 3130719 commit 2edbc048761fb02d531c679295966fef129a5645
Showing with 70 additions and 0 deletions.
  1. +1 −0 tests/src/core/CMakeLists.txt
  2. +69 −0 tests/src/core/testqgsclipper.cpp
@@ -78,6 +78,7 @@ ENDMACRO (ADD_QGIS_TEST)
#############################################################
# Tests:

ADD_QGIS_TEST(clippertest testqgsclipper.cpp)
ADD_QGIS_TEST(distanceareatest testqgsdistancearea.cpp)
ADD_QGIS_TEST(applicationtest testqgsapplication.cpp)
ADD_QGIS_TEST(expressiontest testqgsexpression.cpp)
@@ -0,0 +1,69 @@
/***************************************************************************
testqgsclipper.cpp
--------------------------------------
Date : Tue 14 Aug 2012
Copyright : (C) 2012 by Magnus Homann
Email : magnus at homann dot se
***************************************************************************
* *
* 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 <QtTest>
#include <QFile>
#include <QTextStream>
#include <QObject>
#include <QString>
#include <QStringList>
#include <qgsapplication.h>
//header for class being tested
#include <qgsclipper.h>
#include <qgspoint.h>
#include "qgslogger.h"

class TestQgsClipper: public QObject
{

Q_OBJECT;
private slots:
void initTestCase();// will be called before the first testfunction is executed.
void cleanupTestCase() {};// will be called after the last testfunction was executed.
void init() {};// will be called before each testfunction is executed.
void cleanup() {};// will be called after every testfunction.
void basic();
};

void TestQgsClipper::initTestCase()
{
//
// Runs once before any tests are run
//
// init QGIS's paths - true means that all path will be inited from prefix
// QgsApplication::init();
// QgsApplication::initQgis();
// QgsApplication::showSettings();
}

void TestQgsClipper::basic()
{
// CQgsClipper is static only
//QgsClipper snipsnip;

QPolygonF polygon;
polygon << QPointF(10.4, 20.5) << QPointF(20.2, 30.2);

QgsRectangle clipRect(10, 10, 25, 30 );

QgsClipper::trimPolygon( polygon, clipRect );

QRectF bBox( polygon.boundingRect() );
QgsRectangle boundingRect( bBox.bottomLeft().x(), bBox.bottomLeft().y(), bBox.topRight().x(), bBox.topRight().y() );

QVERIFY( clipRect.contains( boundingRect ) );
};

QTEST_MAIN( TestQgsClipper )
#include "moc_testqgsclipper.cxx"

0 comments on commit 2edbc04

Please sign in to comment.
You can’t perform that action at this time.