Skip to content
Permalink
Browse files

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
  • Loading branch information
timlinux
timlinux committed Apr 9, 2006
1 parent 052cc9a commit 7f32d1787c7c1bba4141f33f665fbfc86bf18c36
Showing with 159 additions and 10 deletions.
  1. +7 −0 tests/src/core/Makefile.am
  2. +52 −10 tests/src/core/test_builder.pl
  3. +100 −0 tests/src/core/testqgsgeometry.cpp
@@ -9,6 +9,7 @@
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

bin_PROGRAMS = testqgsapplication \
testqgsgeometry \
testqgsfeature \
testqgsfield \
testqgssymbol
@@ -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)
@@ -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)
@@ -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$/)
{
@@ -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>)
@@ -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'))
{
@@ -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 7f32d17

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