ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/Utilities/TestClass.pm
(Generate patch)

Comparing COMP/SCRAM/src/Utilities/TestClass.pm (file contents):
Revision 1.8 by williamc, Wed Jan 26 12:03:37 2000 UTC vs.
Revision 1.9 by williamc, Thu Mar 2 16:40:24 2000 UTC

# Line 6 | Line 6
6   # new($module,testdatadir) : module example - Utilities/urlhandler
7   # dotest(@args) : Start testing - arguments dependent on inheriting class
8   #
9 + # cmpstring(expectedstring,returnedstring) : cmp a string and fail if not equal
10   # newtest() : Initiate a testing sequence
11   # verify(actual_result_file, expected_result_file) : compare two files
12   # verifydir(dir) : Check existence of the directory
# Line 55 | Line 56 | sub new {
56          $self->{class}=$module;
57          $self->{"datadir"}=$datadir;
58          $self->{filenumber}=0;
59 +        rmtree("/tmp/SCRAMtest++");
60          $self->{temparea}="/tmp/SCRAMtest++";
61          use File::Path;
62          mkpath ($self->{temparea},0, 0777);
# Line 66 | Line 68 | sub new {
68  
69          # make sure the temparea is cleaned
70          use File::Path;
69        rmtree($self->temparea());
71  
72          return $self;
73   }
# Line 81 | Line 82 | sub dotest {
82   }
83  
84  
85 + sub cmpstring {
86 +        my $self=shift;
87 +        my $s1=shift;
88 +        my $s2=shift;
89 +
90 +        if ( ! defined $s2) {
91 +          $self->testfail("Return string is undefined expecting $s1"),
92 +        }
93 +        elsif ( $s1 ne $s2 ) {
94 +          $self->testfail("Expecting $s1 got $s2");
95 +        }
96 +        else {
97 +          $self->testpass("Got $s2 as expected");
98 +        }
99 + }
100          
101   # A virtual method to be overridden
102   sub init {
# Line 244 | Line 260 | sub testinterface {
260          $self->_testout( " (".$args.")" );
261          $num=0;
262          if ( exists $self->{expect} ) {
263 +         print "Testing Expected Values against actual returns ....\n";
264           @mylist=eval { $self->{object}->$subname(@_); };
265            die "Test Failed $@\n" if $@;
266 +         my $nrv=$#mylist+1; my $nrve=$#{$self->{expect}}+1;
267 +         print $nrv." values returned ".$nrve." expected\n";
268 +         if ( $nrv != $nrve ) {
269 +          $self->testfail("Number of returned values != that expected");
270 +         }
271           if ( defined @mylist ) {
272           # size check
273 <         if ( $#mylist < $#{$self->{expect}} ) {
274 <                $self->testfail("not enough returned values");
273 >         if ( $#mylist != $#{$self->{expect}} ) {
274 >                $self->testfail("Number of returned values inconsistent");
275           }
276           foreach $myreturn ( @mylist ) {
277            if ( ! defined $myreturn ) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines