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. |
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; |
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; |
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; |