Skip to content

Commit

Permalink
Improvements to unit builder script - you can pass it the class nema …
Browse files Browse the repository at this point in the history
…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 committed Apr 9, 2006
1 parent 052cc9a commit 7f32d17
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. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


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


BUILT_SOURCES = $(testqgsapplication_MOC) \ BUILT_SOURCES = $(testqgsapplication_MOC) \
$(testqgsgeometry_MOC) \
$(testqgsfeature_MOC) \ $(testqgsfeature_MOC) \
$(testqgsfield_MOC) \ $(testqgsfield_MOC) \
$(testqgssymbol_MOC) $(testqgssymbol_MOC)
Expand Down Expand Up @@ -58,3 +60,8 @@ testqgsfeature_MOC = testqgsfeature.moc.cpp
testqgsfeature_SOURCES = testqgsfeature.cpp testqgsfeature_SOURCES = testqgsfeature.cpp
testqgsfeature_LDADD = $(GLOBALLDADD) testqgsfeature_LDADD = $(GLOBALLDADD)
testqgsfeature_CXXFLAGS = $(GLOBALCXXFLAGS) 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 #make sure we are in a the tests/src/core dir
$myDir = fastgetcwd; $myDir = fastgetcwd;
$sourceDir = "../../../src/core";
print "\n\nChecking that we are in the <qgis dir>/test/src/core/ directory...."; print "\n\nChecking that we are in the <qgis dir>/test/src/core/ directory....";
if ($myDir =~ m/tests\/src\/core$/) if ($myDir =~ m/tests\/src\/core$/)
{ {
Expand All @@ -23,14 +24,47 @@
exit; exit;
} }
# get the needed information from the user # get the needed information from the user
print "\n\nEnter the name of the class for which the test will be created.\n"; $testClass="";
print "Used mixed case notation.\n"; $argCount = $#ARGV+1;
print "e.g. QgsSymbol\n"; if ($argCount > 0)
$testClass =<STDIN>; {
chop $testClass; $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 $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"; 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=""; $stubString="";
$lastLine=""; $lastLine="";
while(<CPPFILE>) while(<CPPFILE>)
Expand Down Expand Up @@ -58,10 +92,18 @@
$lastLine=$line; $lastLine=$line;
} }
} }
print "-----------------------------\n"; $createIt="n";
print "Create the unit test? [y/n]: "; if ($argCount eq 0)
$createIt = <STDIN>; {
chop $createIt; print "-----------------------------\n";
print "Create the unit test? [y/n]: ";
$createIt = <STDIN>;
chop $createIt;
}
else
{
$createIt="y";
}


if(($createIt eq 'y') || ($createIt eq '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 7f32d17

Please sign in to comment.