/[Search-TokyoDystopia]/t/12-tcj.t
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /t/12-tcj.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 38 - (show annotations)
Sun Sep 21 21:27:40 2008 UTC (12 years, 3 months ago) by dpavlin
File MIME type: application/x-troff
File size: 2034 byte(s)
- skip close/open of empty database because of segfault
- tcjdbrnum
1 #!/usr/bin/perl
2
3 use warnings;
4 use strict;
5
6 use blib;
7
8 use Test::More tests => 30;
9 use Test::Exception;
10 use Data::Dump qw/dump/;
11
12 BEGIN {
13 use_ok( 'Search::TokyoDystopia' );
14 }
15
16 my $path = 'casket-jdb';
17
18 cmp_ok( $Search::TokyoDystopia::debug, '==', 0, '$debug' );
19
20 cmp_ok( tcjdberrmsg(0), 'eq', 'success', 'tcjdberrmsg' );
21
22 ok( my $jdb = tcjdbnew, 'tcjdbnew' ); # FIXME check better
23
24 ok( ! tcjdbdel( $jdb ), 'tcjdbdel' );
25
26 ok( $jdb = tcjdbnew, 'tcjdbnew again' );
27
28 is( tcjdbecode( $jdb ), 0, 'tcjdbecode' );
29
30 ok( tcjdbtune( $jdb, 0, 0, 0, JDBTLARGE | JDBTDEFLATE ), 'tcjdbtune' );
31
32 ok( tcjdbsetcache( $jdb, 0, 0 ), 'tcjdbsetcache' );
33
34 ok( tcjdbsetfwmmax( $jdb, 0 ), 'tcjdbsetfwmmax' );
35
36 ok( tcjdbopen( $jdb, $path, JDBOWRITER | JDBOCREAT | JDBOTRUNC ), "tcjdbopen $path" );
37
38 SKIP: {
39 skip 'close on empty database makes next open segfault', 2;
40
41 ok( tcjdbclose( $jdb ), 'tcjdbclose' );
42
43 ok( tcjdbopen( $jdb, $path, JDBOWRITER | JDBOCREAT ), "tcjdbopen $path again" );
44
45 }
46
47 ok( tcjdbput( $jdb, 1, [ 'foobar' ] ), 'tcjdbput' );
48 diag tcjdberrmsg( tcjdbecode( $jdb ) );
49
50 ok( tcjdbout( $jdb, 1 ), 'tcjdbout' );
51
52 ok( tcjdbput( $jdb, 42, [ 'some', 'data' ] ), 'tcjdbput again' );
53
54 ok( tcjdbput2( $jdb, 99, 'some more data again', ' ' ), 'tcjdbput2' );
55
56 is_deeply( tcjdbsearch( $jdb, 'some', JDBSSUBSTR ), [ 42 ], 'tcjdbsearch' );
57 ok( tcjdbput( $jdb, 65536, [ 'some', 'more', 'data' ] ), 'tcjdbput more data' );
58 is_deeply( tcjdbsearch( $jdb, 'some', JDBSSUBSTR ), [ 42, 65536 ], 'tcjdbsearch' );
59
60 ok( tcjdbsync( $jdb ), 'tcjdbsync' );
61
62 ok( tcjdboptimize( $jdb ), 'tcjdboptimize' );
63
64 my $copy_path = $path . '-copy';
65
66 ok( tcjdbcopy( $jdb, $copy_path ), "tcjdbcopy $copy_path" );
67 ok( -e $copy_path, 'copy exists' );
68
69 is( tcjdbpath( $jdb ), $path, 'tcjdbpath' );
70
71 is( tcjdbrnum( $jdb ), 3, 'tcjdbrnum' );
72
73 ok( my $file_size = tcjdbfsiz( $jdb ), 'tcjdbfsiz' );
74
75 ok( tcjdbvanish( $jdb ), 'tcjdbvanish' );
76
77 is( tcjdbrnum( $jdb ), 0, 'tcjdbrnum' );
78
79 cmp_ok( tcjdbfsiz( $jdb ), '<=', $file_size, 'tcjdbfsiz' );
80
81 diag tcjdberrmsg( tcjdbecode( $jdb ) );

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26