Upgrade to Unicode::Normalize 1.01
[p5sagit/p5-mst-13.2.git] / t / lib / compress / oneshot.pl
CommitLineData
1a6a8453 1use lib 't';
2use strict;
3use warnings;
4use bytes;
5
6use Test::More ;
25f0751f 7use CompTestUtils;
1a6a8453 8
9BEGIN {
10 plan(skip_all => "oneshot needs Perl 5.005 or better - you have Perl $]" )
11 if $] < 5.005 ;
12
13
14 # use Test::NoWarnings, if available
15 my $extra = 0 ;
16 $extra = 1
17 if eval { require Test::NoWarnings ; import Test::NoWarnings; 1 };
18
19 plan tests => 944 + $extra ;
20
25f0751f 21 use_ok('IO::Uncompress::AnyUncompress', qw(anyuncompress $AnyUncompressError)) ;
1a6a8453 22
23}
24
25sub run
26{
27
28 my $CompressClass = identify();
29 my $UncompressClass = getInverse($CompressClass);
30 my $Error = getErrorRef($CompressClass);
31 my $UnError = getErrorRef($UncompressClass);
32 my $TopFuncName = getTopFuncName($CompressClass);
33
34
35
36 foreach my $bit ($CompressClass, $UncompressClass,
25f0751f 37 'IO::Uncompress::AnyUncompress',
1a6a8453 38 )
39 {
40 my $Error = getErrorRef($bit);
41 my $Func = getTopFuncRef($bit);
42 my $TopType = getTopFuncName($bit);
43
44 title "Testing $TopType Error Cases";
45
46 my $a;
47 my $x ;
48
49 eval { $a = $Func->(\$a => \$x, Fred => 1) ;} ;
50 like $@, mkErr("^$TopType: unknown key value\\(s\\) Fred"), ' Illegal Parameters';
51
52 eval { $a = $Func->() ;} ;
53 like $@, mkErr("^$TopType: expected at least 1 parameters"), ' No Parameters';
54
55 eval { $a = $Func->(\$x, \1) ;} ;
56 like $$Error, "/^$TopType: output buffer is read-only/", ' Output is read-only' ;
57
58 my $in ;
59 eval { $a = $Func->($in, \$x) ;} ;
60 like $@, mkErr("^$TopType: input filename is undef or null string"),
61 ' Input filename undef' ;
62
63 $in = '';
64 eval { $a = $Func->($in, \$x) ;} ;
65 like $@, mkErr("^$TopType: input filename is undef or null string"),
66 ' Input filename empty' ;
67
68 {
69 my $lex1 = new LexFile my $in ;
70 writeFile($in, "abc");
71 my $out = $in ;
72 eval { $a = $Func->($in, $out) ;} ;
73 like $@, mkErr("^$TopType: input and output filename are identical"),
74 ' Input and Output filename are the same';
75 }
76
77 eval { $a = $Func->(\$in, \$in) ;} ;
78 like $@, mkErr("^$TopType: input and output buffer are identical"),
79 ' Input and Output buffer are the same';
80
81 my $lex = new LexFile my $out_file ;
82 open OUT, ">$out_file" ;
83 eval { $a = $Func->(\*OUT, \*OUT) ;} ;
84 like $@, mkErr("^$TopType: input and output handle are identical"),
85 ' Input and Output handle are the same';
86
87 close OUT;
88 is -s $out_file, 0, " File zero length" ;
89 {
90 my %x = () ;
91 my $object = bless \%x, "someClass" ;
92
93 # Buffer not a scalar reference
94 #eval { $a = $Func->(\$x, \%x) ;} ;
95 eval { $a = $Func->(\$x, $object) ;} ;
96 like $@, mkErr("^$TopType: illegal output parameter"),
97 ' Bad Output Param';
98
99 # Buffer not a scalar reference
100 eval { $a = $Func->(\$x, \%x) ;} ;
101 like $@, mkErr("^$TopType: illegal output parameter"),
102 ' Bad Output Param';
103
104
105 eval { $a = $Func->(\%x, \$x) ;} ;
106 like $@, mkErr("^$TopType: illegal input parameter"),
107 ' Bad Input Param';
108
109 #eval { $a = $Func->(\%x, \$x) ;} ;
110 eval { $a = $Func->($object, \$x) ;} ;
111 like $@, mkErr("^$TopType: illegal input parameter"),
112 ' Bad Input Param';
113 }
114
115 my $filename = 'abc.def';
116 ok ! -e $filename, " input file '$filename' does not exist";
117 $a = $Func->($filename, \$x) ;
118 is $a, undef, " $TopType returned undef";
119 like $$Error, "/^input file '$filename' does not exist\$/", " input File '$filename' does not exist";
120
121 $filename = '/tmp/abd/abc.def';
122 ok ! -e $filename, " output File '$filename' does not exist";
123 $a = $Func->(\$x, $filename) ;
124 is $a, undef, " $TopType returned undef";
125 like $$Error, ("/^(cannot open file '$filename'|input file '$filename' does not exist):/"), " output File '$filename' does not exist";
126
127 eval { $a = $Func->(\$x, '<abc>') } ;
128 like $$Error, "/Need input fileglob for outout fileglob/",
129 ' Output fileglob with no input fileglob';
130 is $a, undef, " $TopType returned undef";
131
132 $a = $Func->('<abc)>', '<abc>') ;
133 is $a, undef, " $TopType returned undef";
134 like $$Error, "/Unmatched \\) in input fileglob/",
135 " Unmatched ) in input fileglob";
136 }
137
138 foreach my $bit ($UncompressClass,
25f0751f 139 'IO::Uncompress::AnyUncompress',
1a6a8453 140 )
141 {
142 my $Error = getErrorRef($bit);
143 my $Func = getTopFuncRef($bit);
144 my $TopType = getTopFuncName($bit);
145
146 my $data = "mary had a little lamb" ;
147 my $keep = $data ;
148
149 for my $trans ( 0, 1)
150 {
151 title "Non-compressed data with $TopType, Transparent => $trans ";
152 my $a;
153 my $x ;
154 my $out = '' ;
155
156 $a = $Func->(\$data, \$out, Transparent => $trans) ;
157
158 is $data, $keep, " Input buffer not changed" ;
159
160 if ($trans)
161 {
162 ok $a, " $TopType returned true" ;
163 is $out, $data, " got expected output" ;
164 ok ! $$Error, " no error [$$Error]" ;
165 }
166 else
167 {
168 ok ! $a, " $TopType returned false" ;
169 #like $$Error, '/xxx/', " error" ;
170 ok $$Error, " error is '$$Error'" ;
171 }
172 }
173 }
174
175 foreach my $bit ($CompressClass
176 )
177 {
178 my $Error = getErrorRef($bit);
179 my $Func = getTopFuncRef($bit);
180 my $TopType = getTopFuncName($bit);
181 my $TopTypeInverse = getInverse($bit);
182 my $FuncInverse = getTopFuncRef($TopTypeInverse);
183 my $ErrorInverse = getErrorRef($TopTypeInverse);
184
185 title "$TopTypeInverse - corrupt data";
186
187 my $data = "abcd" x 100 ;
188 my $out;
189
190 ok $Func->(\$data, \$out), " $TopType ok";
191
192 # corrupt the compressed data
193 #substr($out, -10, 10) = "x" x 10 ;
194 substr($out, int(length($out)/3), 10) = 'abcdeabcde';
195
196 my $result;
197 ok ! $FuncInverse->(\$out => \$result, Transparent => 0), " $TopTypeInverse ok";
198 ok $$ErrorInverse, " Got error '$$ErrorInverse'" ;
199
200 #is $result, $data, " data ok";
201
25f0751f 202 ok ! anyuncompress(\$out => \$result, Transparent => 0), "anyuncompress ok";
203 ok $AnyUncompressError, " Got error '$AnyUncompressError'" ;
1a6a8453 204 }
205
206
207 foreach my $bit ($CompressClass
208 )
209 {
210 my $Error = getErrorRef($bit);
211 my $Func = getTopFuncRef($bit);
212 my $TopType = getTopFuncName($bit);
213 my $TopTypeInverse = getInverse($bit);
214 my $FuncInverse = getTopFuncRef($TopTypeInverse);
215
216 for my $append ( 1, 0 )
217 {
218 my $already = '';
219 $already = 'abcde' if $append ;
220
221 for my $buffer ( undef, '', "abcde" )
222 {
223
224 my $disp_content = defined $buffer ? $buffer : '<undef>' ;
225
226 my $keep = $buffer;
227 my $out_file = "abcde.out";
228 my $in_file = "abcde.in";
229
230 {
231 title "$TopType - From Buff to Buff content '$disp_content' Append $append" ;
232
233 my $output = $already;
234 ok &$Func(\$buffer, \$output, Append => $append), ' Compressed ok' ;
235
236 is $keep, $buffer, " Input buffer not changed" ;
237 my $got = anyUncompress(\$output, $already);
238 $got = undef if ! defined $buffer && $got eq '' ;
239 is $got, $buffer, " Uncompressed matches original";
240
241 }
242
243 {
244 title "$TopType - From Buff to Array Ref content '$disp_content' Append $append" ;
245
246 my @output = ('first') ;
247 ok &$Func(\$buffer, \@output, Append => $append), ' Compressed ok' ;
248
249 is $output[0], 'first', " Array[0] unchanged";
250 is $keep, $buffer, " Input buffer not changed" ;
251 my $got = anyUncompress($output[1]);
252 $got = undef if ! defined $buffer && $got eq '' ;
253 is $got, $buffer, " Uncompressed matches original";
254 }
255
256 {
257 title "$TopType - From Array Ref to Array Ref content '$disp_content' Append $append" ;
258
259 my $lex = new LexFile my $in_file ;
260 writeFile($in_file, $buffer);
261 my @output = ('first') ;
262 my @input = ($in_file);
263 ok &$Func(\@input, \@output, Append => $append), ' Compressed ok' ;
264
265 is $output[0], 'first', " Array[0] unchanged";
266 my $got = anyUncompress($output[1]);
267 $got = undef if ! defined $buffer && $got eq '' ;
268 is $got, $buffer, " Uncompressed matches original";
269 }
270
271 {
272 title "$TopType - From Buff to Filename content '$disp_content' Append $append" ;
273
274 my $lex = new LexFile my $out_file ;
275 ok ! -e $out_file, " Output file does not exist";
276 writeFile($out_file, $already);
277
278 ok &$Func(\$buffer, $out_file, Append => $append), ' Compressed ok' ;
279
280 ok -e $out_file, " Created output file";
281 my $got = anyUncompress($out_file, $already);
282 $got = undef if ! defined $buffer && $got eq '' ;
283 is $got, $buffer, " Uncompressed matches original";
284 }
285
286 {
287 title "$TopType - From Buff to Handle content '$disp_content' Append $append" ;
288
289 my $lex = new LexFile my $out_file ;
290
291 ok ! -e $out_file, " Output file does not exist";
292 writeFile($out_file, $already);
293 my $of = new IO::File ">>$out_file" ;
294 ok $of, " Created output filehandle" ;
295
296 ok &$Func(\$buffer, $of, AutoClose => 1, Append => $append), ' Compressed ok' ;
297
298 ok -e $out_file, " Created output file";
299 my $got = anyUncompress($out_file, $already);
300 $got = undef if ! defined $buffer && $got eq '' ;
301 is $got, $buffer, " Uncompressed matches original";
302 }
303
304
305 {
306 title "$TopType - From Filename to Filename content '$disp_content' Append $append" ;
307
308 my $lex = new LexFile(my $in_file, my $out_file) ;
309 writeFile($in_file, $buffer);
310
311 ok ! -e $out_file, " Output file does not exist";
312 writeFile($out_file, $already);
313
314 ok &$Func($in_file => $out_file, Append => $append), ' Compressed ok' ;
315
316 ok -e $out_file, " Created output file";
317 my $got = anyUncompress($out_file, $already);
318 $got = undef if ! defined $buffer && $got eq '' ;
319 is $got, $buffer, " Uncompressed matches original";
320
321 }
322
323 {
324 title "$TopType - From Filename to Handle content '$disp_content' Append $append" ;
325
326 my $lex = new LexFile(my $in_file, my $out_file) ;
327 writeFile($in_file, $buffer);
328
329 ok ! -e $out_file, " Output file does not exist";
330 writeFile($out_file, $already);
331 my $out = new IO::File ">>$out_file" ;
332
333 ok &$Func($in_file, $out, AutoClose => 1, Append => $append), ' Compressed ok' ;
334
335 ok -e $out_file, " Created output file";
336 my $got = anyUncompress($out_file, $already);
337 $got = undef if ! defined $buffer && $got eq '' ;
338 is $got, $buffer, " Uncompressed matches original";
339
340 }
341
342 {
343 title "$TopType - From Filename to Buffer content '$disp_content' Append $append" ;
344
345 my $lex = new LexFile(my $in_file, my $out_file) ;
346 writeFile($in_file, $buffer);
347
348 my $out = $already;
349
350 ok &$Func($in_file => \$out, Append => $append), ' Compressed ok' ;
351
352 my $got = anyUncompress(\$out, $already);
353 $got = undef if ! defined $buffer && $got eq '' ;
354 is $got, $buffer, " Uncompressed matches original";
355
356 }
357
358 {
359 title "$TopType - From Handle to Filename content '$disp_content' Append $append" ;
360
361 my $lex = new LexFile(my $in_file, my $out_file) ;
362 writeFile($in_file, $buffer);
363 my $in = new IO::File "<$in_file" ;
364
365 ok ! -e $out_file, " Output file does not exist";
366 writeFile($out_file, $already);
367
368 ok &$Func($in, $out_file, Append => $append), ' Compressed ok'
369 or diag "error is $$Error" ;
370
371 ok -e $out_file, " Created output file";
372 my $got = anyUncompress($out_file, $already);
373 $got = undef if ! defined $buffer && $got eq '' ;
374 is $buffer, $got, " Uncompressed matches original";
375
376 }
377
378 {
379 title "$TopType - From Handle to Handle content '$disp_content' Append $append" ;
380
381 my $lex = new LexFile(my $in_file, my $out_file) ;
382 writeFile($in_file, $buffer);
383 my $in = new IO::File "<$in_file" ;
384
385 ok ! -e $out_file, " Output file does not exist";
386 writeFile($out_file, $already);
387 my $out = new IO::File ">>$out_file" ;
388
389 ok &$Func($in, $out, AutoClose => 1, Append => $append), ' Compressed ok' ;
390
391 ok -e $out_file, " Created output file";
392 my $got = anyUncompress($out_file, $already);
393 $got = undef if ! defined $buffer && $got eq '' ;
394 is $buffer, $got, " Uncompressed matches original";
395
396 }
397
398 {
399 title "$TopType - From Handle to Buffer content '$disp_content' Append $append" ;
400
401 my $lex = new LexFile(my $in_file, my $out_file) ;
402 writeFile($in_file, $buffer);
403 my $in = new IO::File "<$in_file" ;
404
405 my $out = $already ;
406
407 ok &$Func($in, \$out, Append => $append), ' Compressed ok' ;
408
409 my $got = anyUncompress(\$out, $already);
410 $got = undef if ! defined $buffer && $got eq '' ;
411 is $buffer, $got, " Uncompressed matches original";
412
413 }
414
415 {
416 title "$TopType - From stdin (via '-') to Buffer content '$disp_content' Append $append" ;
417
418 my $lex = new LexFile(my $in_file, my $out_file) ;
419 writeFile($in_file, $buffer);
420
421 open(SAVEIN, "<&STDIN");
422 my $dummy = fileno SAVEIN ;
423 ok open(STDIN, "<$in_file"), " redirect STDIN";
424
425 my $out = $already;
426
427 ok &$Func('-', \$out, Append => $append), ' Compressed ok'
428 or diag $$Error ;
429
430 open(STDIN, "<&SAVEIN");
431
432 my $got = anyUncompress(\$out, $already);
433 $got = undef if ! defined $buffer && $got eq '' ;
434 is $buffer, $got, " Uncompressed matches original";
435
436 }
437
438 }
439 }
440 }
441
442 foreach my $bit ($CompressClass)
443 {
444 my $Error = getErrorRef($bit);
445 my $Func = getTopFuncRef($bit);
446 my $TopType = getTopFuncName($bit);
447
448 my $TopTypeInverse = getInverse($bit);
449 my $FuncInverse = getTopFuncRef($TopTypeInverse);
450
451 my $lex = new LexFile(my $file1, my $file2) ;
452
453 writeFile($file1, "data1");
454 writeFile($file2, "data2");
455 my $of = new IO::File "<$file1" ;
456 ok $of, " Created output filehandle" ;
457
458 #my @input = ( undef, "", $file2, \undef, \'', \"abcde", $of) ;
459 #my @expected = ("", "", $file2, "", "", "abcde", "data1");
460 #my @uexpected = ("", "", "data2", "", "", "abcde", "data1");
461 #my @input = ( $file2, \"abcde", $of) ;
462 #my @expected = ( $file2, "abcde", "data1");
463 #my @uexpected = ("data2", "abcde", "data1");
464
465 my @input = ( $file1, $file2) ;
466 #my @expected = ( $file1, $file2);
467 my @expected = ("data1", "data2");
468 my @uexpected = ("data1", "data2");
469
470 my @keep = @input ;
471
472 {
473 title "$TopType - From Array Ref to Array Ref" ;
474
475 my @output = ('first') ;
476 ok &$Func(\@input, \@output, AutoClose => 0), ' Compressed ok' ;
477
478 is $output[0], 'first', " Array[0] unchanged";
479
480 is_deeply \@input, \@keep, " Input array not changed" ;
481 my @got = shift @output;
482 foreach (@output) { push @got, anyUncompress($_) }
483
484 is_deeply \@got, ['first', @expected], " Got Expected uncompressed data";
485
486 }
487
488 foreach my $ms (1, 0)
489 {
490 {
491 title "$TopType - From Array Ref to Buffer, MultiStream $ms" ;
492
493 # rewind the filehandle
494 $of->open("<$file1") ;
495
496 my $output ;
497 ok &$Func(\@input, \$output, MultiStream => $ms, AutoClose => 0), ' Compressed ok'
498 or diag $$Error;
499
500 my $got = anyUncompress([ \$output, MultiStream => $ms ]);
501
502 is $got, join('', @uexpected), " Got Expected uncompressed data";
503 my @headers = getHeaders(\$output);
504 is @headers, $ms ? @input : 1, " Header count ok";
505 }
506
507 {
508 title "$TopType - From Array Ref to Filename, MultiStream $ms" ;
509
510 my $lex = new LexFile( my $file3) ;
511
512 # rewind the filehandle
513 $of->open("<$file1") ;
514
515 my $output ;
516 ok &$Func(\@input, $file3, MultiStream => $ms, AutoClose => 0), ' Compressed ok' ;
517
518 my $got = anyUncompress([ $file3, MultiStream => $ms ]);
519
520 is $got, join('', @uexpected), " Got Expected uncompressed data";
521 my @headers = getHeaders($file3);
522 is @headers, $ms ? @input : 1, " Header count ok";
523 }
524
525 {
526 title "$TopType - From Array Ref to Filehandle, MultiStream $ms" ;
527
528 my $lex = new LexFile(my $file3) ;
529
530 my $fh3 = new IO::File ">$file3";
531
532 # rewind the filehandle
533 $of->open("<$file1") ;
534
535 my $output ;
536 ok &$Func(\@input, $fh3, MultiStream => $ms, AutoClose => 0), ' Compressed ok' ;
537
538 $fh3->close();
539
540 my $got = anyUncompress([ $file3, MultiStream => $ms ]);
541
542 is $got, join('', @uexpected), " Got Expected uncompressed data";
543 my @headers = getHeaders($file3);
544 is @headers, $ms ? @input : 1, " Header count ok";
545 }
546 }
547 }
548
549# foreach my $bit ($CompressClass)
550# {
551# my $Error = getErrorRef($bit);
552# my $Func = getTopFuncRef($bit);
553# my $TopType = getTopFuncName($bit);
554#
555# my $TopTypeInverse = getInverse($bit);
556# my $FuncInverse = getTopFuncRef($TopTypeInverse);
557#
558# my @inFiles = map { "in$_.tmp" } 1..4;
559# my @outFiles = map { "out$_.tmp" } 1..4;
560# my $lex = new LexFile(@inFiles, @outFiles);
561#
562# writeFile($_, "data $_") foreach @inFiles ;
563#
564# {
565# title "$TopType - Hash Ref: to filename" ;
566#
567# my $output ;
568# ok &$Func( { $inFiles[0] => $outFiles[0],
569# $inFiles[1] => $outFiles[1],
570# $inFiles[2] => $outFiles[2] } ), ' Compressed ok' ;
571#
572# foreach (0 .. 2)
573# {
574# my $got = anyUncompress($outFiles[$_]);
575# is $got, "data $inFiles[$_]", " Uncompressed $_ matches original";
576# }
577# }
578#
579# {
580# title "$TopType - Hash Ref: to buffer" ;
581#
582# my @buffer ;
583# ok &$Func( { $inFiles[0] => \$buffer[0],
584# $inFiles[1] => \$buffer[1],
585# $inFiles[2] => \$buffer[2] } ), ' Compressed ok' ;
586#
587# foreach (0 .. 2)
588# {
589# my $got = anyUncompress(\$buffer[$_]);
590# is $got, "data $inFiles[$_]", " Uncompressed $_ matches original";
591# }
592# }
593#
594# {
595# title "$TopType - Hash Ref: to undef" ;
596#
597# my @buffer ;
598# my %hash = ( $inFiles[0] => undef,
599# $inFiles[1] => undef,
600# $inFiles[2] => undef,
601# );
602#
603# ok &$Func( \%hash ), ' Compressed ok' ;
604#
605# foreach (keys %hash)
606# {
607# my $got = anyUncompress(\$hash{$_});
608# is $got, "data $_", " Uncompressed $_ matches original";
609# }
610# }
611#
612# {
613# title "$TopType - Filename to Hash Ref" ;
614#
615# my %output ;
616# ok &$Func( $inFiles[0] => \%output), ' Compressed ok' ;
617#
618# is keys %output, 1, " one pair in hash" ;
619# my ($k, $v) = each %output;
620# is $k, $inFiles[0], " key is '$inFiles[0]'";
621# my $got = anyUncompress($v);
622# is $got, "data $inFiles[0]", " Uncompressed matches original";
623# }
624#
625# {
626# title "$TopType - File Glob to Hash Ref" ;
627#
628# my %output ;
629# ok &$Func( '<in*.tmp>' => \%output), ' Compressed ok' ;
630#
631# is keys %output, 4, " four pairs in hash" ;
632# foreach my $fil (@inFiles)
633# {
634# ok exists $output{$fil}, " key '$fil' exists" ;
635# my $got = anyUncompress($output{$fil});
636# is $got, "data $fil", " Uncompressed matches original";
637# }
638# }
639#
640#
641# }
642
643# foreach my $bit ($CompressClass)
644# {
645# my $Error = getErrorRef($bit);
646# my $Func = getTopFuncRef($bit);
647# my $TopType = getTopFuncName($bit);
648#
649# my $TopTypeInverse = getInverse($bit);
650# my $FuncInverse = getTopFuncRef($TopTypeInverse);
651#
652# my @inFiles = map { "in$_.tmp" } 1..4;
653# my @outFiles = map { "out$_.tmp" } 1..4;
654# my $lex = new LexFile(@inFiles, @outFiles);
655#
656# writeFile($_, "data $_") foreach @inFiles ;
657#
658#
659#
660# # if (0)
661# # {
662# # title "$TopType - Hash Ref to Array Ref" ;
663# #
664# # my @output = ('first') ;
665# # ok &$Func( { \@input, \@output } , AutoClose => 0), ' Compressed ok' ;
666# #
667# # is $output[0], 'first', " Array[0] unchanged";
668# #
669# # is_deeply \@input, \@keep, " Input array not changed" ;
670# # my @got = shift @output;
671# # foreach (@output) { push @got, anyUncompress($_) }
672# #
673# # is_deeply \@got, ['first', @expected], " Got Expected uncompressed data";
674# #
675# # }
676# #
677# # if (0)
678# # {
679# # title "$TopType - From Array Ref to Buffer" ;
680# #
681# # # rewind the filehandle
682# # $of->open("<$file1") ;
683# #
684# # my $output ;
685# # ok &$Func(\@input, \$output, AutoClose => 0), ' Compressed ok' ;
686# #
687# # my $got = anyUncompress(\$output);
688# #
689# # is $got, join('', @expected), " Got Expected uncompressed data";
690# # }
691# #
692# # if (0)
693# # {
694# # title "$TopType - From Array Ref to Filename" ;
695# #
696# # my ($file3) = ("file3");
697# # my $lex = new LexFile($file3) ;
698# #
699# # # rewind the filehandle
700# # $of->open("<$file1") ;
701# #
702# # my $output ;
703# # ok &$Func(\@input, $file3, AutoClose => 0), ' Compressed ok' ;
704# #
705# # my $got = anyUncompress($file3);
706# #
707# # is $got, join('', @expected), " Got Expected uncompressed data";
708# # }
709# #
710# # if (0)
711# # {
712# # title "$TopType - From Array Ref to Filehandle" ;
713# #
714# # my ($file3) = ("file3");
715# # my $lex = new LexFile($file3) ;
716# #
717# # my $fh3 = new IO::File ">$file3";
718# #
719# # # rewind the filehandle
720# # $of->open("<$file1") ;
721# #
722# # my $output ;
723# # ok &$Func(\@input, $fh3, AutoClose => 0), ' Compressed ok' ;
724# #
725# # $fh3->close();
726# #
727# # my $got = anyUncompress($file3);
728# #
729# # is $got, join('', @expected), " Got Expected uncompressed data";
730# # }
731# }
732
733 foreach my $bit ($CompressClass
734 )
735 {
736 my $Error = getErrorRef($bit);
737 my $Func = getTopFuncRef($bit);
738 my $TopType = getTopFuncName($bit);
739
740 for my $files ( [qw(a1)], [qw(a1 a2 a3)] )
741 {
742
743 my $tmpDir1 = 'tmpdir1';
744 my $tmpDir2 = 'tmpdir2';
745 my $lex = new LexDir($tmpDir1, $tmpDir2) ;
746
747 mkdir $tmpDir1, 0777;
748 mkdir $tmpDir2, 0777;
749
750 ok -d $tmpDir1, " Temp Directory $tmpDir1 exists";
751 #ok ! -d $tmpDir2, " Temp Directory $tmpDir2 does not exist";
752
753 my @files = map { "$tmpDir1/$_.tmp" } @$files ;
754 foreach (@files) { writeFile($_, "abc $_") }
755
756 my @expected = map { "abc $_" } @files ;
757 my @outFiles = map { s/$tmpDir1/$tmpDir2/; $_ } @files ;
758
759 {
760 title "$TopType - From FileGlob to FileGlob files [@$files]" ;
761
762 ok &$Func("<$tmpDir1/a*.tmp>" => "<$tmpDir2/a#1.tmp>"), ' Compressed ok'
763 or diag $$Error ;
764
765 my @copy = @expected;
766 for my $file (@outFiles)
767 {
768 is anyUncompress($file), shift @copy, " got expected from $file" ;
769 }
770
771 is @copy, 0, " got all files";
772 }
773
774 {
775 title "$TopType - From FileGlob to Array files [@$files]" ;
776
777 my @buffer = ('first') ;
778 ok &$Func("<$tmpDir1/a*.tmp>" => \@buffer), ' Compressed ok'
779 or diag $$Error ;
780
781 is shift @buffer, 'first';
782
783 my @copy = @expected;
784 for my $buffer (@buffer)
785 {
786 is anyUncompress($buffer), shift @copy, " got expected " ;
787 }
788
789 is @copy, 0, " got all files";
790 }
791
792 foreach my $ms (0, 1)
793 {
794 {
795 title "$TopType - From FileGlob to Buffer files [@$files], MS $ms" ;
796
797 my $buffer ;
798 ok &$Func("<$tmpDir1/a*.tmp>" => \$buffer,
799 MultiStream => $ms), ' Compressed ok'
800 or diag $$Error ;
801
802 #hexDump(\$buffer);
803
804 my $got = anyUncompress([ \$buffer, MultiStream => $ms ]);
805
806 is $got, join("", @expected), " got expected" ;
807 my @headers = getHeaders(\$buffer);
808 is @headers, $ms ? @files : 1, " Header count ok";
809 }
810
811 {
812 title "$TopType - From FileGlob to Filename files [@$files], MS $ms" ;
813
814 my $filename = "abcde";
815 my $lex = new LexFile($filename) ;
816
817 ok &$Func("<$tmpDir1/a*.tmp>" => $filename,
818 MultiStream => $ms), ' Compressed ok'
819 or diag $$Error ;
820
821 #hexDump(\$buffer);
822
823 my $got = anyUncompress([$filename, MultiStream => $ms]);
824
825 is $got, join("", @expected), " got expected" ;
826 my @headers = getHeaders($filename);
827 is @headers, $ms ? @files : 1, " Header count ok";
828 }
829
830 {
831 title "$TopType - From FileGlob to Filehandle files [@$files], MS $ms" ;
832
833 my $filename = "abcde";
834 my $lex = new LexFile($filename) ;
835 my $fh = new IO::File ">$filename";
836
837 ok &$Func("<$tmpDir1/a*.tmp>" => $fh,
838 MultiStream => $ms, AutoClose => 1), ' Compressed ok'
839 or diag $$Error ;
840
841 #hexDump(\$buffer);
842
843 my $got = anyUncompress([$filename, MultiStream => $ms]);
844
845 is $got, join("", @expected), " got expected" ;
846 my @headers = getHeaders($filename);
847 is @headers, $ms ? @files : 1, " Header count ok";
848 }
849 }
850 }
851
852 }
853
854 foreach my $bit ($UncompressClass,
25f0751f 855 'IO::Uncompress::AnyUncompress',
1a6a8453 856 )
857 {
858 my $Error = getErrorRef($bit);
859 my $Func = getTopFuncRef($bit);
860 my $TopType = getTopFuncName($bit);
861
862 my $buffer = "abcde" ;
863 my $buffer2 = "ABCDE" ;
864 my $keep_orig = $buffer;
865
25f0751f 866 my $comp = compressBuffer(getTopFuncName($UncompressClass), $buffer) ;
867 my $comp2 = compressBuffer(getTopFuncName($UncompressClass), $buffer2) ;
1a6a8453 868 my $keep_comp = $comp;
869
870 my $incumbent = "incumbent data" ;
871
872 for my $append (0, 1)
873 {
874 my $expected = $buffer ;
875 $expected = $incumbent . $buffer if $append ;
876
877 {
878 title "$TopType - From Buff to Buff, Append($append)" ;
879
880 my $output ;
881 $output = $incumbent if $append ;
882 ok &$Func(\$comp, \$output, Append => $append), ' Uncompressed ok' ;
883
884 is $keep_comp, $comp, " Input buffer not changed" ;
885 is $output, $expected, " Uncompressed matches original";
886 }
887
888 {
889 title "$TopType - From Buff to Array, Append($append)" ;
890
891 my @output = ('first');
892 #$output = $incumbent if $append ;
893 ok &$Func(\$comp, \@output, Append => $append), ' Uncompressed ok' ;
894
895 is $keep_comp, $comp, " Input buffer not changed" ;
896 is $output[0], 'first', " Uncompressed matches original";
897 is ${ $output[1] }, $buffer, " Uncompressed matches original"
898 or diag $output[1] ;
899 is @output, 2, " only 2 elements in the array" ;
900 }
901
902 {
903 title "$TopType - From Buff to Filename, Append($append)" ;
904
905 my $lex = new LexFile(my $out_file) ;
906 if ($append)
907 { writeFile($out_file, $incumbent) }
908 else
909 { ok ! -e $out_file, " Output file does not exist" }
910
911 ok &$Func(\$comp, $out_file, Append => $append), ' Uncompressed ok' ;
912
913 ok -e $out_file, " Created output file";
914 my $content = readFile($out_file) ;
915
916 is $keep_comp, $comp, " Input buffer not changed" ;
917 is $content, $expected, " Uncompressed matches original";
918 }
919
920 {
921 title "$TopType - From Buff to Handle, Append($append)" ;
922
923 my $lex = new LexFile(my $out_file) ;
924 my $of ;
925 if ($append) {
926 writeFile($out_file, $incumbent) ;
927 $of = new IO::File "+< $out_file" ;
928 }
929 else {
930 ok ! -e $out_file, " Output file does not exist" ;
931 $of = new IO::File "> $out_file" ;
932 }
933 isa_ok $of, 'IO::File', ' $of' ;
934
935 ok &$Func(\$comp, $of, Append => $append, AutoClose => 1), ' Uncompressed ok' ;
936
937 ok -e $out_file, " Created output file";
938 my $content = readFile($out_file) ;
939
940 is $keep_comp, $comp, " Input buffer not changed" ;
941 is $content, $expected, " Uncompressed matches original";
942 }
943
944 {
945 title "$TopType - From Filename to Filename, Append($append)" ;
946
947 my $lex = new LexFile(my $in_file, my $out_file) ;
948 if ($append)
949 { writeFile($out_file, $incumbent) }
950 else
951 { ok ! -e $out_file, " Output file does not exist" }
952
953 writeFile($in_file, $comp);
954
955 ok &$Func($in_file, $out_file, Append => $append), ' Uncompressed ok' ;
956
957 ok -e $out_file, " Created output file";
958 my $content = readFile($out_file) ;
959
960 is $keep_comp, $comp, " Input buffer not changed" ;
961 is $content, $expected, " Uncompressed matches original";
962 }
963
964 {
965 title "$TopType - From Filename to Handle, Append($append)" ;
966
967 my $lex = new LexFile(my $in_file, my $out_file) ;
968 my $out ;
969 if ($append) {
970 writeFile($out_file, $incumbent) ;
971 $out = new IO::File "+< $out_file" ;
972 }
973 else {
974 ok ! -e $out_file, " Output file does not exist" ;
975 $out = new IO::File "> $out_file" ;
976 }
977 isa_ok $out, 'IO::File', ' $out' ;
978
979 writeFile($in_file, $comp);
980
981 ok &$Func($in_file, $out, Append => $append, AutoClose => 1), ' Uncompressed ok' ;
982
983 ok -e $out_file, " Created output file";
984 my $content = readFile($out_file) ;
985
986 is $keep_comp, $comp, " Input buffer not changed" ;
987 is $content, $expected, " Uncompressed matches original";
988 }
989
990 {
991 title "$TopType - From Filename to Buffer, Append($append)" ;
992
993 my $lex = new LexFile(my $in_file) ;
994 writeFile($in_file, $comp);
995
996 my $output ;
997 $output = $incumbent if $append ;
998
999 ok &$Func($in_file, \$output, Append => $append), ' Uncompressed ok' ;
1000
1001 is $keep_comp, $comp, " Input buffer not changed" ;
1002 is $output, $expected, " Uncompressed matches original";
1003 }
1004
1005 {
1006 title "$TopType - From Handle to Filename, Append($append)" ;
1007
1008 my $lex = new LexFile(my $in_file, my $out_file) ;
1009 if ($append)
1010 { writeFile($out_file, $incumbent) }
1011 else
1012 { ok ! -e $out_file, " Output file does not exist" }
1013
1014 writeFile($in_file, $comp);
1015 my $in = new IO::File "<$in_file" ;
1016
1017 ok &$Func($in, $out_file, Append => $append), ' Uncompressed ok' ;
1018
1019 ok -e $out_file, " Created output file";
1020 my $content = readFile($out_file) ;
1021
1022 is $keep_comp, $comp, " Input buffer not changed" ;
1023 is $content, $expected, " Uncompressed matches original";
1024 }
1025
1026 {
1027 title "$TopType - From Handle to Handle, Append($append)" ;
1028
1029 my $lex = new LexFile(my $in_file, my $out_file) ;
1030 my $out ;
1031 if ($append) {
1032 writeFile($out_file, $incumbent) ;
1033 $out = new IO::File "+< $out_file" ;
1034 }
1035 else {
1036 ok ! -e $out_file, " Output file does not exist" ;
1037 $out = new IO::File "> $out_file" ;
1038 }
1039 isa_ok $out, 'IO::File', ' $out' ;
1040
1041 writeFile($in_file, $comp);
1042 my $in = new IO::File "<$in_file" ;
1043
1044 ok &$Func($in, $out, Append => $append, AutoClose => 1), ' Uncompressed ok' ;
1045
1046 ok -e $out_file, " Created output file";
1047 my $content = readFile($out_file) ;
1048
1049 is $keep_comp, $comp, " Input buffer not changed" ;
1050 is $content, $expected, " Uncompressed matches original";
1051 }
1052
1053 {
1054 title "$TopType - From Filename to Buffer, Append($append)" ;
1055
1056 my $lex = new LexFile(my $in_file) ;
1057 writeFile($in_file, $comp);
1058 my $in = new IO::File "<$in_file" ;
1059
1060 my $output ;
1061 $output = $incumbent if $append ;
1062
1063 ok &$Func($in, \$output, Append => $append), ' Uncompressed ok' ;
1064
1065 is $keep_comp, $comp, " Input buffer not changed" ;
1066 is $output, $expected, " Uncompressed matches original";
1067 }
1068
1069 {
1070 title "$TopType - From stdin (via '-') to Buffer content, Append($append) " ;
1071
1072 my $lex = new LexFile(my $in_file) ;
1073 writeFile($in_file, $comp);
1074
1075 open(SAVEIN, "<&STDIN");
1076 my $dummy = fileno SAVEIN ;
1077 ok open(STDIN, "<$in_file"), " redirect STDIN";
1078
1079 my $output ;
1080 $output = $incumbent if $append ;
1081
1082 ok &$Func('-', \$output, Append => $append), ' Uncompressed ok'
1083 or diag $$Error ;
1084
1085 open(STDIN, "<&SAVEIN");
1086
1087 is $keep_comp, $comp, " Input buffer not changed" ;
1088 is $output, $expected, " Uncompressed matches original";
1089 }
1090 }
1091
1092 {
1093 title "$TopType - From Handle to Buffer, InputLength" ;
1094
1095 my $lex = new LexFile(my $in_file, my $out_file) ;
1096 my $out ;
1097
1098 my $expected = $buffer ;
1099 my $appended = 'appended';
1100 my $len_appended = length $appended;
1101 writeFile($in_file, $comp . $appended . $comp . $appended) ;
1102 my $in = new IO::File "<$in_file" ;
1103
1104 ok &$Func($in, \$out, Transparent => 0, InputLength => length $comp), ' Uncompressed ok' ;
1105
1106 is $out, $expected, " Uncompressed matches original";
1107
1108 my $buff;
1109 is $in->read($buff, $len_appended), $len_appended, " Length of Appended data ok";
1110 is $buff, $appended, " Appended data ok";
1111
1112 $out = '';
1113 ok &$Func($in, \$out, Transparent => 0, InputLength => length $comp), ' Uncompressed ok' ;
1114
1115 is $out, $expected, " Uncompressed matches original";
1116
1117 $buff = '';
1118 is $in->read($buff, $len_appended), $len_appended, " Length of Appended data ok";
1119 is $buff, $appended, " Appended data ok";
1120 }
1121
1122 for my $stdin ('-', *STDIN) # , \*STDIN)
1123 {
1124 title "$TopType - From stdin (via $stdin) to Buffer content, InputLength" ;
1125
1126 my $lex = new LexFile my $in_file ;
1127 my $expected = $buffer ;
1128 my $appended = 'appended';
1129 my $len_appended = length $appended;
1130 writeFile($in_file, $comp . $appended ) ;
1131
1132 open(SAVEIN, "<&STDIN");
1133 my $dummy = fileno SAVEIN ;
1134 ok open(STDIN, "<$in_file"), " redirect STDIN";
1135
1136 my $output ;
1137
1138 ok &$Func($stdin, \$output, Transparent => 0, InputLength => length $comp), ' Uncompressed ok'
1139 or diag $$Error ;
1140
1141 my $buff ;
1142 is read(STDIN, $buff, $len_appended), $len_appended, " Length of Appended data ok";
1143
1144 is $output, $expected, " Uncompressed matches original";
1145 is $buff, $appended, " Appended data ok";
1146
1147 open(STDIN, "<&SAVEIN");
1148 }
1149 }
1150
1151 foreach my $bit ($UncompressClass,
25f0751f 1152 'IO::Uncompress::AnyUncompress',
1a6a8453 1153 )
1154 {
1155 # TODO -- Add Append mode tests
1156
1157 my $Error = getErrorRef($bit);
1158 my $Func = getTopFuncRef($bit);
1159 my $TopType = getTopFuncName($bit);
1160
1161 my $buffer = "abcde" ;
1162 my $keep_orig = $buffer;
1163
25f0751f 1164 my $null = compressBuffer(getTopFuncName($UncompressClass), "") ;
1165 my $undef = compressBuffer(getTopFuncName($UncompressClass), undef) ;
1166 my $comp = compressBuffer(getTopFuncName($UncompressClass), $buffer) ;
1a6a8453 1167 my $keep_comp = $comp;
1168
1169 my $incumbent = "incumbent data" ;
1170
1171 my $lex = new LexFile(my $file1, my $file2) ;
1172
25f0751f 1173 writeFile($file1, compressBuffer(getTopFuncName($UncompressClass),"data1"));
1174 writeFile($file2, compressBuffer(getTopFuncName($UncompressClass),"data2"));
1a6a8453 1175
1176 my $of = new IO::File "<$file1" ;
1177 ok $of, " Created output filehandle" ;
1178
1179 #my @input = ($file2, \$undef, \$null, \$comp, $of) ;
1180 #my @expected = ('data2', '', '', 'abcde', 'data1');
1181 my @input = ($file1, $file2);
1182 my @expected = ('data1', 'data2');
1183
1184 my @keep = @input ;
1185
1186 {
1187 title "$TopType - From ArrayRef to Buffer" ;
1188
1189 my $output ;
1190 ok &$Func(\@input, \$output, AutoClose => 0), ' UnCompressed ok' ;
1191
1192 is $output, join('', @expected)
1193 }
1194
1195 {
1196 title "$TopType - From ArrayRef to Filename" ;
1197
1198 my $lex = new LexFile my $output;
1199 $of->open("<$file1") ;
1200
1201 ok &$Func(\@input, $output, AutoClose => 0), ' UnCompressed ok' ;
1202
1203 is readFile($output), join('', @expected)
1204 }
1205
1206 {
1207 title "$TopType - From ArrayRef to Filehandle" ;
1208
1209 my $lex = new LexFile my $output;
1210 my $fh = new IO::File ">$output" ;
1211 $of->open("<$file1") ;
1212
1213 ok &$Func(\@input, $fh, AutoClose => 0), ' UnCompressed ok' ;
1214 $fh->close;
1215
1216 is readFile($output), join('', @expected)
1217 }
1218
1219 {
1220 title "$TopType - From Array Ref to Array Ref" ;
1221
1222 my @output = (\'first') ;
1223 $of->open("<$file1") ;
1224 ok &$Func(\@input, \@output, AutoClose => 0), ' UnCompressed ok' ;
1225
1226 is_deeply \@input, \@keep, " Input array not changed" ;
1227 is_deeply [map { defined $$_ ? $$_ : "" } @output],
1228 ['first', @expected],
1229 " Got Expected uncompressed data";
1230
1231 }
1232 }
1233
1234 foreach my $bit ($UncompressClass,
25f0751f 1235 'IO::Uncompress::AnyUncompress',
1a6a8453 1236 )
1237 {
1238 # TODO -- Add Append mode tests
1239
1240 my $Error = getErrorRef($bit);
1241 my $Func = getTopFuncRef($bit);
1242 my $TopType = getTopFuncName($bit);
1243
1244 my $tmpDir1 = 'tmpdir1';
1245 my $tmpDir2 = 'tmpdir2';
1246 my $lex = new LexDir($tmpDir1, $tmpDir2) ;
1247
1248 mkdir $tmpDir1, 0777;
1249 mkdir $tmpDir2, 0777;
1250
1251 ok -d $tmpDir1, " Temp Directory $tmpDir1 exists";
1252 #ok ! -d $tmpDir2, " Temp Directory $tmpDir2 does not exist";
1253
1254 my @files = map { "$tmpDir1/$_.tmp" } qw( a1 a2 a3) ;
25f0751f 1255 foreach (@files) { writeFile($_, compressBuffer(getTopFuncName($UncompressClass), "abc $_")) }
1a6a8453 1256
1257 my @expected = map { "abc $_" } @files ;
1258 my @outFiles = map { s/$tmpDir1/$tmpDir2/; $_ } @files ;
1259
1260 {
1261 title "$TopType - From FileGlob to FileGlob" ;
1262
1263 ok &$Func("<$tmpDir1/a*.tmp>" => "<$tmpDir2/a#1.tmp>"), ' UnCompressed ok'
1264 or diag $$Error ;
1265
1266 my @copy = @expected;
1267 for my $file (@outFiles)
1268 {
1269 is readFile($file), shift @copy, " got expected from $file" ;
1270 }
1271
1272 is @copy, 0, " got all files";
1273 }
1274
1275 {
1276 title "$TopType - From FileGlob to Arrayref" ;
1277
1278 my @output = (\'first');
1279 ok &$Func("<$tmpDir1/a*.tmp>" => \@output), ' UnCompressed ok'
1280 or diag $$Error ;
1281
1282 my @copy = ('first', @expected);
1283 for my $data (@output)
1284 {
1285 is $$data, shift @copy, " got expected data" ;
1286 }
1287
1288 is @copy, 0, " got all files";
1289 }
1290
1291 {
1292 title "$TopType - From FileGlob to Buffer" ;
1293
1294 my $output ;
1295 ok &$Func("<$tmpDir1/a*.tmp>" => \$output), ' UnCompressed ok'
1296 or diag $$Error ;
1297
1298 is $output, join('', @expected), " got expected uncompressed data";
1299 }
1300
1301 {
1302 title "$TopType - From FileGlob to Filename" ;
1303
1304 my $lex = new LexFile my $output ;
1305 ok ! -e $output, " $output does not exist" ;
1306 ok &$Func("<$tmpDir1/a*.tmp>" => $output), ' UnCompressed ok'
1307 or diag $$Error ;
1308
1309 ok -e $output, " $output does exist" ;
1310 is readFile($output), join('', @expected), " got expected uncompressed data";
1311 }
1312
1313 {
1314 title "$TopType - From FileGlob to Filehandle" ;
1315
1316 my $output = 'abc' ;
1317 my $lex = new LexFile $output ;
1318 my $fh = new IO::File ">$output" ;
1319 ok &$Func("<$tmpDir1/a*.tmp>" => $fh, AutoClose => 1), ' UnCompressed ok'
1320 or diag $$Error ;
1321
1322 ok -e $output, " $output does exist" ;
1323 is readFile($output), join('', @expected), " got expected uncompressed data";
1324 }
1325
1326 }
1327
1328 foreach my $TopType ($CompressClass
1329 # TODO -- add the inflate classes
1330 )
1331 {
1332 my $Error = getErrorRef($TopType);
1333 my $Func = getTopFuncRef($TopType);
1334 my $Name = getTopFuncName($TopType);
1335
1336 title "More write tests" ;
1337
1338 my $lex = new LexFile(my $file1, my $file2, my $file3) ;
1339
1340 writeFile($file1, "F1");
1341 writeFile($file2, "F2");
1342 writeFile($file3, "F3");
1343
1344# my @data = (
1345# [ '[\"ab", \"cd"]', "abcd" ],
1346#
1347# [ '[\"a", $fh1, \"bc"]', "aF1bc"],
1348# ) ;
1349#
1350#
1351# foreach my $data (@data)
1352# {
1353# my ($send, $get) = @$data ;
1354#
1355# my $fh1 = new IO::File "< $file1" ;
1356# my $fh2 = new IO::File "< $file2" ;
1357# my $fh3 = new IO::File "< $file3" ;
1358#
1359# title "$send";
1360# my ($copy);
1361# eval "\$copy = $send";
1362# my $Answer ;
1363# ok &$Func($copy, \$Answer), " $Name ok";
1364#
1365# my $got = anyUncompress(\$Answer);
1366# is $got, $get, " got expected output" ;
1367# ok ! $$Error, " no error"
1368# or diag "Error is $$Error";
1369#
1370# }
1371
1372 title "Array Input Error tests" ;
1373
1374 my @data = (
1375 [ '[]', "empty array reference"],
1376 [ '[[]]', "unknown input parameter"],
1377 [ '[[[]]]', "unknown input parameter"],
1378 [ '[[\"ab"], [\"cd"]]', "unknown input parameter"],
1379 [ '[\""]', "not a filename"],
1380 [ '[\undef]', "not a filename"],
1381 [ '[\"abcd"]', "not a filename"],
1382 [ '[\&xx]', "unknown input parameter"],
1383 [ '[$fh2]', "not a filename"],
1384 ) ;
1385
1386
1387 foreach my $data (@data)
1388 {
1389 my ($send, $get) = @$data ;
1390
1391 my $fh1 = new IO::File "< $file1" ;
1392 my $fh2 = new IO::File "< $file2" ;
1393 my $fh3 = new IO::File "< $file3" ;
1394
1395 title "$send";
1396 my($copy);
1397 eval "\$copy = $send";
1398 my $Answer ;
1399 my $a ;
1400 eval { $a = &$Func($copy, \$Answer) };
1401 ok ! $a, " $Name fails";
1402
1403 is $$Error, $get, " got error message";
1404
1405 }
1406
1407 @data = (
1408 '[""]',
1409 '[undef]',
1410 ) ;
1411
1412
1413 foreach my $send (@data)
1414 {
1415 title "$send";
1416 my($copy);
1417 eval "\$copy = $send";
1418 my $Answer ;
1419 eval { &$Func($copy, \$Answer) } ;
1420 like $@, mkErr("^$TopFuncName: input filename is undef or null string"),
1421 " got error message";
1422
1423 }
1424 }
1425
1426}
1427
1428# TODO add more error cases
1429
14301;