Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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@5241 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Apr 9, 2006
1 parent 971e2d3 commit 1110aaf
Show file tree
Hide file tree
Showing 3 changed files with 159 additions and 10 deletions.
7 changes: 7 additions & 0 deletions tests/src/core/Makefile.am
Expand Up @@ -9,6 +9,7 @@
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

bin_PROGRAMS = testqgsapplication \
testqgsgeometry \
testqgsfeature \
testqgsfield \
testqgssymbol
Expand All @@ -28,6 +29,7 @@ GLOBALCXXFLAGS = $(CXXFLAGS) $(EXTRA_CXXFLAGS) $(GDAL_CFLAGS) $(QT_CXXFLAGS) $(P
$(MOC) -o $@ $<

BUILT_SOURCES = $(testqgsapplication_MOC) \
$(testqgsgeometry_MOC) \
$(testqgsfeature_MOC) \
$(testqgsfield_MOC) \
$(testqgssymbol_MOC)
Expand Down Expand Up @@ -58,3 +60,8 @@ testqgsfeature_MOC = testqgsfeature.moc.cpp
testqgsfeature_SOURCES = testqgsfeature.cpp
testqgsfeature_LDADD = $(GLOBALLDADD)
testqgsfeature_CXXFLAGS = $(GLOBALCXXFLAGS)

testqgsgeometry_MOC = testqgsgeometry.moc.cpp
testqgsgeometry_SOURCES = testqgsgeometry.cpp
testqgsgeometry_LDADD = $(GLOBALLDADD)
testqgsgeometry_CXXFLAGS = $(GLOBALCXXFLAGS)
62 changes: 52 additions & 10 deletions tests/src/core/test_builder.pl
Expand Up @@ -10,6 +10,7 @@

#make sure we are in a the tests/src/core dir
$myDir = fastgetcwd;
$sourceDir = "../../../src/core";
print "\n\nChecking that we are in the <qgis dir>/test/src/core/ directory....";
if ($myDir =~ m/tests\/src\/core$/)
{
Expand All @@ -23,14 +24,47 @@
exit;
}
# get the needed information from the user
print "\n\nEnter the name of the class for which the test will be created.\n";
print "Used mixed case notation.\n";
print "e.g. QgsSymbol\n";
$testClass =<STDIN>;
chop $testClass;
$testClass="";
$argCount = $#ARGV+1;
if ($argCount > 0)
{
$testClass=@ARGV[ 0 ];
}
else
{
print "\n\nEnter the name of the class for which the test will be created.\n";
print "Used mixed case notation.\n";
print "e.g. QgsSymbol\n";
$testClass =<STDIN>;
chop $testClass;
}

$testClassLowerCaseName = lc($testClass); #todo convert to lower case

#
# Check source file is ok
#

if ($testClass eq "")
{
print "ClassName not supplied ...exiting...";
exit;
}
print "Checking if source class exists in filesystem ...";
if (-e "${sourceDir}/${testClassLowerCaseName}.cpp" )
{
print "yes\n";
}
else
{
print "no, exiting\n";
print "${sourceDir}/${testClassLowerCaseName}.cpp does not exist!\n";
exit;
}


print "Stubs will be created for the following methods:\n";
open CPPFILE, "<../../../src/core/$testClassLowerCaseName.cpp"|| die 'Unable to open header file $testClassLowerCaseName.cpp';
open CPPFILE, "<$sourceDir/$testClassLowerCaseName.cpp"|| die 'Unable to open header file $testClassLowerCaseName.cpp';
$stubString="";
$lastLine="";
while(<CPPFILE>)
Expand Down Expand Up @@ -58,10 +92,18 @@
$lastLine=$line;
}
}
print "-----------------------------\n";
print "Create the unit test? [y/n]: ";
$createIt = <STDIN>;
chop $createIt;
$createIt="n";
if ($argCount eq 0)
{
print "-----------------------------\n";
print "Create the unit test? [y/n]: ";
$createIt = <STDIN>;
chop $createIt;
}
else
{
$createIt="y";
}

if(($createIt eq 'y') || ($createIt eq 'Y'))
{
Expand Down
100 changes: 100 additions & 0 deletions tests/src/core/testqgsgeometry.cpp
@@ -0,0 +1,100 @@
#include <QtTest>
#include <QObject>
#include <QString>
#include <QObject>
//header for class being tested
#include <qgsgeometry.h>

class TestQgsGeometry: public QObject
{
Q_OBJECT;
private slots:
void QgsGeometryQgsGeometry()
{

};
void QgsGeometrysetWkbAndOwnership()
{

};
void QgsGeometrywkbBuffer()
{

};
void QgsGeometrywkbSize()
{

};
void QgsGeometrywkt()
{

};
void QgsGeometrysetGeos()
{

};
void QgsGeometryclosestVertex()
{

};
void QgsGeometryinsertVertexBefore()
{

};
void QgsGeometrymoveVertexAt()
{

};
void QgsGeometrydeleteVertexAt()
{

};
void QgsGeometryvertexAt()
{

};
void QgsGeometryclosestVertexWithContext()
{

};
void QgsGeometryclosestSegmentWithContext()
{

};
void QgsGeometryboundingBox()
{

};
void QgsGeometryintersects()
{

};
void QgsGeometryexportToWkt()
{

};
void QgsGeometrygeosGeometry()
{

};
void QgsGeometryexportWkbToGeos()
{

};
void QgsGeometryexportGeosToWkb()
{

};
void QgsGeometrydistanceSquaredPointToSegment()
{

};

};

QTEST_MAIN(TestQgsGeometry)
#include "testqgsgeometry.moc.cpp"




0 comments on commit 1110aaf

Please sign in to comment.