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.12 by williamc, Mon Sep 18 08:54:59 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 169 | Line 187 | sub verifyexists {
187          }
188   }
189  
190 + sub testswitch {
191 +        my $self=shift;
192 +        my $bool=shift;
193 +        my $string1=shift;
194 +        my $string2=shift;
195 +
196 +        if ( ! $bool ) {
197 +           $self->testpass($string1);
198 +        }
199 +        else {
200 +           $self->testfail($string2);
201 +        }
202 + }
203 +
204   sub testfail {
205          my $self=shift;
206          my $string=shift;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines