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.9 by williamc, Thu Mar 2 16:40:24 2000 UTC vs.
Revision 1.9.2.2.6.1 by williamc, Thu Nov 2 15:53:57 2000 UTC

# Line 12 | Line 12
12   # verifydir(dir) : Check existence of the directory
13   # verifyexists(file) : Verify the existence of file
14   # datadir([dir]) : return the current data directory (set it to dir if supplied)
15 + # testswitch(int,"0 text"," non 0 text") : testpass or fail according to bool
16   # testfail(string) : report that current test has failed
17   # testpass(string) : report that current test has passed
18   # newfilename() : return a new filename that can be opened etc.
# Line 21 | Line 22
22   # expect(string) : tell the testinterface of any expected return values
23   # clearexpect()  : Reset any expect variables.
24   #cleantemp()    : delete the temporary area
25 + # cmparray(arrayref, @reqvals) : test the arrayref against expected
26 + # cmpstring(expectedstring,actualstring) :
27  
28   package Utilities::TestClass;
29   require 5.004;
# Line 81 | Line 84 | sub dotest {
84          $self->{testobj}->checktests();
85   }
86  
87 + sub cmparray {
88 +        my $self=shift;
89 +        my $array=shift;
90 +        my @vals=@_;
91 +
92 +        if ( $#{$array} ne $#vals) { $self->testfail(
93 +                 $#{$array}." items retuned, $#vals expected");
94 +        }
95 +        else {
96 +        for( my $i=0; $i<= $#{$array}; $i++) {
97 +           $self->cmpstring($vals[$i],$$array[$i]);
98 +        }
99 +        }
100 + }
101 +
102  
103   sub cmpstring {
104          my $self=shift;
# Line 88 | Line 106 | sub cmpstring {
106          my $s2=shift;
107  
108          if ( ! defined $s2) {
109 <          $self->testfail("Return string is undefined expecting $s1"),
109 >          if ( ( ! defined $s1 ) || ( $s1==undef )) {
110 >            $self->testpass("Got undefined as expected");
111 >          }
112 >          else {
113 >            $self->testfail("Return string is undefined expecting $s1"),
114 >          }
115          }
116          elsif ( $s1 ne $s2 ) {
117            $self->testfail("Expecting $s1 got $s2");
# Line 169 | Line 192 | sub verifyexists {
192          }
193   }
194  
195 + sub testswitch {
196 +        my $self=shift;
197 +        my $bool=shift;
198 +        my $string1=shift;
199 +        my $string2=shift;
200 +
201 +        if ( ! $bool ) {
202 +           $self->testpass($string1);
203 +        }
204 +        else {
205 +           $self->testfail($string2);
206 +        }
207 + }
208 +
209   sub testfail {
210          my $self=shift;
211          my $string=shift;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines