1 |
dpavlin |
1 |
#!/usr/bin/perl -w |
2 |
|
|
|
3 |
|
|
use strict; |
4 |
|
|
|
5 |
|
|
use Test::More tests => 9; |
6 |
|
|
use Test::Exception; |
7 |
|
|
use File::Temp qw/ :mktemp /; |
8 |
|
|
use blib; |
9 |
|
|
|
10 |
|
|
BEGIN { use_ok('SWISH::Split') }; |
11 |
|
|
|
12 |
|
|
my %param; |
13 |
|
|
|
14 |
|
|
throws_ok { SWISH::Split->open(%param) } qr/slice_name/, "slice_name"; |
15 |
|
|
|
16 |
|
|
sub slice_1st_char { |
17 |
|
|
return substr($_[0],0,1); |
18 |
|
|
}; |
19 |
|
|
|
20 |
|
|
use Data::Dumper; |
21 |
|
|
print Dumper(\&slice_1st_char); |
22 |
|
|
|
23 |
|
|
$param{'slice_name'} = \&slice_1st_char; |
24 |
|
|
throws_ok { SWISH::Split->open(%param) } qr/slices/, "slices"; |
25 |
|
|
|
26 |
|
|
$param{'slices'} = 3; |
27 |
|
|
throws_ok { SWISH::Split->open(%param) } qr/index/, "index"; |
28 |
|
|
|
29 |
|
|
ok($param{'index'} = mkstemp("/tmp/swishXXXXX"), "make temp index"); |
30 |
|
|
throws_ok { SWISH::Split->open(%param) } qr/dir/, "dir"; |
31 |
|
|
|
32 |
|
|
ok($param{'index'} = mkdtemp("/tmp/swishXXXXX"), "make temp index"); |
33 |
|
|
ok(my $i=SWISH::Split->open(%param), "open"); |
34 |
|
|
|
35 |
|
|
# methods test |
36 |
|
|
|
37 |
|
|
|
38 |
|
|
|
39 |
|
|
# internal functions test |
40 |
|
|
|
41 |
|
|
cmp_ok($i->in_slice("swishpath"), '==', 2, "open"); |
42 |
|
|
|