1 |
#!/usr/bin/perl -w |
2 |
|
3 |
use strict; |
4 |
|
5 |
use Test::More tests => 11; |
6 |
use Test::Exception; |
7 |
use File::Temp qw/ :mktemp /; |
8 |
use blib; |
9 |
|
10 |
BEGIN { use_ok('SWISH::Split') }; |
11 |
|
12 |
# FIXME debug |
13 |
system "rm -Rf /tmp/swish?????"; |
14 |
|
15 |
my %param; |
16 |
|
17 |
throws_ok { SWISH::Split->open(%param) } qr/slice_name/, "slice_name"; |
18 |
|
19 |
sub slice_1st_char { |
20 |
return substr($_[0],0,1); |
21 |
}; |
22 |
|
23 |
use Data::Dumper; |
24 |
print Dumper(\&slice_1st_char); |
25 |
|
26 |
$param{'slice_name'} = \&slice_1st_char; |
27 |
throws_ok { SWISH::Split->open(%param) } qr/slices/, "need slices"; |
28 |
|
29 |
$param{'slices'} = 3; |
30 |
throws_ok { SWISH::Split->open(%param) } qr/index/, "need index"; |
31 |
|
32 |
ok($param{'index'} = mktemp("/tmp/swishXXXXX"), "make temp name"); |
33 |
|
34 |
diag "index path: $param{'index'}\n"; |
35 |
|
36 |
ok(open(F, "> $param{'index'}"), "touch"); |
37 |
close(F); |
38 |
|
39 |
throws_ok { SWISH::Split->open(%param) } qr/dir/, "need dir"; |
40 |
|
41 |
ok(unlink($param{'index'}), "rm"); |
42 |
|
43 |
ok(mkdir($param{'index'}), "mkdir"); |
44 |
|
45 |
ok(my $i=SWISH::Split->open(%param), "open"); |
46 |
|
47 |
# methods test |
48 |
|
49 |
|
50 |
|
51 |
# internal functions test |
52 |
|
53 |
cmp_ok($i->in_slice("swishpath"), '==', 2, "open"); |
54 |
|