File tree 1 file changed +22
-5
lines changed
1 file changed +22
-5
lines changed Original file line number Diff line number Diff line change 29
29
$testClass =<STDIN >;
30
30
chop $testClass ;
31
31
$testClassLowerCaseName = lc ($testClass ); # todo convert to lower case
32
+ 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' ;
34
+ $stubString =" " ;
35
+ while (<CPPFILE>)
36
+ {
37
+ if (m /${testClass} ::[A-Za-z0-9] *\( / )
38
+ {
39
+ # get the matched part of the line
40
+ $line = $& ;
41
+ # strip off the ::
42
+ $line =~ s / ::// g ;
43
+ # strip off the (
44
+ $line =~ s /\( // g ;
45
+ # add it to our stub code
46
+ $stubString = $stubString . " void $line ()\n\(\n\n\)\n " ;
47
+ # show the user the list
48
+ print $line ;
49
+ }
50
+ }
51
+ print $stubString ;
52
+ print " -----------------------------\n " ;
32
53
print " Create the unit test? [y/n]: " ;
33
54
$createIt = <STDIN >;
34
55
chop $createIt ;
43
64
# Substitute the class name in the file
44
65
system (" perl -pi -e 's/\\\[ testClassLowerCaseName\\\] /$testClassLowerCaseName /g' test$testClassLowerCaseName .cpp" );
45
66
system (" perl -pi -e 's/\\\[ testClassCamelCaseName\\\] /$testClass /g' test$testClassLowerCaseName .cpp" );
46
- #
47
- # TODO: write a parser to pull out method signatures from class bing tested and create a stub
48
- # for each method in the generated test class to replace teh [TestMethods] placeholder
49
- #
50
-
67
+ system (" perl -pi -e 's/\\\[ TestMethods\\\] /$stubString /g' test$testClassLowerCaseName .cpp" );
51
68
# Add an entry to Makefile.am
52
69
open MAKEFILE, " <./Makefile.am" || die ' Unable to open Makefile.am' ;
53
70
open MAKEFILEMOD, " >./Makefile.am.mod" || die ' Unable to create Makefile.am.mod' ;
You can’t perform that action at this time.
0 commit comments