Skip to content

Commit 3130719

Browse files
committed
Test Friday! QgsClipper test
1 parent c328539 commit 3130719

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

tests/src/core/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ ENDMACRO (ADD_QGIS_TEST)
7878
#############################################################
7979
# Tests:
8080
81+
ADD_QGIS_TEST(clippertest testqgsclipper.cpp)
8182
ADD_QGIS_TEST(distanceareatest testqgsdistancearea.cpp)
8283
ADD_QGIS_TEST(applicationtest testqgsapplication.cpp)
8384
ADD_QGIS_TEST(expressiontest testqgsexpression.cpp)

tests/src/core/testqgsclipper.cpp

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/***************************************************************************
2+
testqgsclipper.cpp
3+
--------------------------------------
4+
Date : Tue 14 Aug 2012
5+
Copyright : (C) 2012 by Magnus Homann
6+
Email : magnus at homann dot se
7+
***************************************************************************
8+
* *
9+
* This program is free software; you can redistribute it and/or modify *
10+
* it under the terms of the GNU General Public License as published by *
11+
* the Free Software Foundation; either version 2 of the License, or *
12+
* (at your option) any later version. *
13+
* *
14+
***************************************************************************/
15+
#include <QtTest>
16+
#include <QFile>
17+
#include <QTextStream>
18+
#include <QObject>
19+
#include <QString>
20+
#include <QStringList>
21+
#include <qgsapplication.h>
22+
//header for class being tested
23+
#include <qgsclipper.h>
24+
#include <qgspoint.h>
25+
#include "qgslogger.h"
26+
27+
class TestQgsClipper: public QObject
28+
{
29+
30+
Q_OBJECT;
31+
private slots:
32+
void initTestCase();// will be called before the first testfunction is executed.
33+
void cleanupTestCase() {};// will be called after the last testfunction was executed.
34+
void init() {};// will be called before each testfunction is executed.
35+
void cleanup() {};// will be called after every testfunction.
36+
void basic();
37+
};
38+
39+
void TestQgsClipper::initTestCase()
40+
{
41+
//
42+
// Runs once before any tests are run
43+
//
44+
// init QGIS's paths - true means that all path will be inited from prefix
45+
// QgsApplication::init();
46+
// QgsApplication::initQgis();
47+
// QgsApplication::showSettings();
48+
}
49+
50+
void TestQgsClipper::basic()
51+
{
52+
// CQgsClipper is static only
53+
//QgsClipper snipsnip;
54+
55+
QPolygonF polygon;
56+
polygon << QPointF(10.4, 20.5) << QPointF(20.2, 30.2);
57+
58+
QgsRectangle clipRect(10, 10, 25, 30 );
59+
60+
QgsClipper::trimPolygon( polygon, clipRect );
61+
62+
QRectF bBox( polygon.boundingRect() );
63+
QgsRectangle boundingRect( bBox.bottomLeft().x(), bBox.bottomLeft().y(), bBox.topRight().x(), bBox.topRight().y() );
64+
65+
QVERIFY( clipRect.contains( boundingRect ) );
66+
};
67+
68+
QTEST_MAIN( TestQgsClipper )
69+
#include "moc_testqgsclipper.cxx"

0 commit comments

Comments
 (0)