Skip to content

Commit 7f32d17

Browse files
author
timlinux
committed
Improvements to unit builder script - you can pass it the class nema to build the test for from the cli and it will not prompts you and just create everything - to be used in source dir parsing script that Ill add soon...
dded new test unit for qgsgeometry git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5241 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 052cc9a commit 7f32d17

File tree

3 files changed

+159
-10
lines changed

3 files changed

+159
-10
lines changed

tests/src/core/Makefile.am

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1010

1111
bin_PROGRAMS = testqgsapplication \
12+
testqgsgeometry \
1213
testqgsfeature \
1314
testqgsfield \
1415
testqgssymbol
@@ -28,6 +29,7 @@ GLOBALCXXFLAGS = $(CXXFLAGS) $(EXTRA_CXXFLAGS) $(GDAL_CFLAGS) $(QT_CXXFLAGS) $(P
2829
$(MOC) -o $@ $<
2930

3031
BUILT_SOURCES = $(testqgsapplication_MOC) \
32+
$(testqgsgeometry_MOC) \
3133
$(testqgsfeature_MOC) \
3234
$(testqgsfield_MOC) \
3335
$(testqgssymbol_MOC)
@@ -58,3 +60,8 @@ testqgsfeature_MOC = testqgsfeature.moc.cpp
5860
testqgsfeature_SOURCES = testqgsfeature.cpp
5961
testqgsfeature_LDADD = $(GLOBALLDADD)
6062
testqgsfeature_CXXFLAGS = $(GLOBALCXXFLAGS)
63+
64+
testqgsgeometry_MOC = testqgsgeometry.moc.cpp
65+
testqgsgeometry_SOURCES = testqgsgeometry.cpp
66+
testqgsgeometry_LDADD = $(GLOBALLDADD)
67+
testqgsgeometry_CXXFLAGS = $(GLOBALCXXFLAGS)

tests/src/core/test_builder.pl

Lines changed: 52 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#make sure we are in a the tests/src/core dir
1212
$myDir = fastgetcwd;
13+
$sourceDir = "../../../src/core";
1314
print "\n\nChecking that we are in the <qgis dir>/test/src/core/ directory....";
1415
if ($myDir =~ m/tests\/src\/core$/)
1516
{
@@ -23,14 +24,47 @@
2324
exit;
2425
}
2526
# get the needed information from the user
26-
print "\n\nEnter the name of the class for which the test will be created.\n";
27-
print "Used mixed case notation.\n";
28-
print "e.g. QgsSymbol\n";
29-
$testClass =<STDIN>;
30-
chop $testClass;
27+
$testClass="";
28+
$argCount = $#ARGV+1;
29+
if ($argCount > 0)
30+
{
31+
$testClass=@ARGV[ 0 ];
32+
}
33+
else
34+
{
35+
print "\n\nEnter the name of the class for which the test will be created.\n";
36+
print "Used mixed case notation.\n";
37+
print "e.g. QgsSymbol\n";
38+
$testClass =<STDIN>;
39+
chop $testClass;
40+
}
41+
3142
$testClassLowerCaseName = lc($testClass); #todo convert to lower case
43+
44+
#
45+
# Check source file is ok
46+
#
47+
48+
if ($testClass eq "")
49+
{
50+
print "ClassName not supplied ...exiting...";
51+
exit;
52+
}
53+
print "Checking if source class exists in filesystem ...";
54+
if (-e "${sourceDir}/${testClassLowerCaseName}.cpp" )
55+
{
56+
print "yes\n";
57+
}
58+
else
59+
{
60+
print "no, exiting\n";
61+
print "${sourceDir}/${testClassLowerCaseName}.cpp does not exist!\n";
62+
exit;
63+
}
64+
65+
3266
print "Stubs will be created for the following methods:\n";
33-
open CPPFILE, "<../../../src/core/$testClassLowerCaseName.cpp"|| die 'Unable to open header file $testClassLowerCaseName.cpp';
67+
open CPPFILE, "<$sourceDir/$testClassLowerCaseName.cpp"|| die 'Unable to open header file $testClassLowerCaseName.cpp';
3468
$stubString="";
3569
$lastLine="";
3670
while(<CPPFILE>)
@@ -58,10 +92,18 @@
5892
$lastLine=$line;
5993
}
6094
}
61-
print "-----------------------------\n";
62-
print "Create the unit test? [y/n]: ";
63-
$createIt = <STDIN>;
64-
chop $createIt;
95+
$createIt="n";
96+
if ($argCount eq 0)
97+
{
98+
print "-----------------------------\n";
99+
print "Create the unit test? [y/n]: ";
100+
$createIt = <STDIN>;
101+
chop $createIt;
102+
}
103+
else
104+
{
105+
$createIt="y";
106+
}
65107

66108
if(($createIt eq 'y') || ($createIt eq 'Y'))
67109
{

tests/src/core/testqgsgeometry.cpp

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#include <QtTest>
2+
#include <QObject>
3+
#include <QString>
4+
#include <QObject>
5+
//header for class being tested
6+
#include <qgsgeometry.h>
7+
8+
class TestQgsGeometry: public QObject
9+
{
10+
Q_OBJECT;
11+
private slots:
12+
void QgsGeometryQgsGeometry()
13+
{
14+
15+
};
16+
void QgsGeometrysetWkbAndOwnership()
17+
{
18+
19+
};
20+
void QgsGeometrywkbBuffer()
21+
{
22+
23+
};
24+
void QgsGeometrywkbSize()
25+
{
26+
27+
};
28+
void QgsGeometrywkt()
29+
{
30+
31+
};
32+
void QgsGeometrysetGeos()
33+
{
34+
35+
};
36+
void QgsGeometryclosestVertex()
37+
{
38+
39+
};
40+
void QgsGeometryinsertVertexBefore()
41+
{
42+
43+
};
44+
void QgsGeometrymoveVertexAt()
45+
{
46+
47+
};
48+
void QgsGeometrydeleteVertexAt()
49+
{
50+
51+
};
52+
void QgsGeometryvertexAt()
53+
{
54+
55+
};
56+
void QgsGeometryclosestVertexWithContext()
57+
{
58+
59+
};
60+
void QgsGeometryclosestSegmentWithContext()
61+
{
62+
63+
};
64+
void QgsGeometryboundingBox()
65+
{
66+
67+
};
68+
void QgsGeometryintersects()
69+
{
70+
71+
};
72+
void QgsGeometryexportToWkt()
73+
{
74+
75+
};
76+
void QgsGeometrygeosGeometry()
77+
{
78+
79+
};
80+
void QgsGeometryexportWkbToGeos()
81+
{
82+
83+
};
84+
void QgsGeometryexportGeosToWkb()
85+
{
86+
87+
};
88+
void QgsGeometrydistanceSquaredPointToSegment()
89+
{
90+
91+
};
92+
93+
};
94+
95+
QTEST_MAIN(TestQgsGeometry)
96+
#include "testqgsgeometry.moc.cpp"
97+
98+
99+
100+

0 commit comments

Comments
 (0)