/[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 40 - (show annotations)
Sat Feb 14 17:36:46 2009 UTC (10 years, 3 months ago) by dpavlin
File MIME type: application/x-troff
File size: 2148 byte(s)
replace JBDSSUBSTR with JDBSFULL so that tcjdbsearch returns results
1 #!/usr/bin/perl
2
3 use warnings;
4 use strict;
5
6 use blib;
7
8 use Test::More tests => 32;
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
49 ok( tcjdbout( $jdb, 1 ), 'tcjdbout' );
50
51 ok( tcjdbput( $jdb, 42, [ 'some', 'data' ] ), 'tcjdbput again' );
52
53 ok( tcjdbput2( $jdb, 99, 'some more data again', ' ' ), 'tcjdbput2' );
54
55 is_deeply( tcjdbsearch( $jdb, 'some', JDBSFULL ), [ 42, 99 ], 'tcjdbsearch' );
56 is_deeply( tcjdbsearch2( $jdb, 'some' ), [ 42, 99 ], 'tcjdbsearch2' );
57
58 ok( tcjdbput( $jdb, 65536, [ 'some', 'more', 'data' ] ), 'tcjdbput more data' );
59 is_deeply( tcjdbsearch( $jdb, 'some', JDBSFULL ), [ 42, 99, 65536 ], 'tcjdbsearch' );
60 is_deeply( tcjdbsearch2( $jdb, 'some' ), [ 42, 99, 65536 ], 'tcjdbsearch2' );
61
62 ok( tcjdbsync( $jdb ), 'tcjdbsync' );
63
64 ok( tcjdboptimize( $jdb ), 'tcjdboptimize' );
65
66 my $copy_path = $path . '-copy';
67
68 ok( tcjdbcopy( $jdb, $copy_path ), "tcjdbcopy $copy_path" );
69 ok( -e $copy_path, 'copy exists' );
70
71 is( tcjdbpath( $jdb ), $path, 'tcjdbpath' );
72
73 is( tcjdbrnum( $jdb ), 3, 'tcjdbrnum' );
74
75 ok( my $file_size = tcjdbfsiz( $jdb ), 'tcjdbfsiz' );
76
77 ok( tcjdbvanish( $jdb ), 'tcjdbvanish' );
78
79 is( tcjdbrnum( $jdb ), 0, 'tcjdbrnum' );
80
81 cmp_ok( tcjdbfsiz( $jdb ), '<=', $file_size, 'tcjdbfsiz' );
82
83 diag tcjdberrmsg( tcjdbecode( $jdb ) );

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26