/[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 37 - (show annotations)
Sun Sep 21 20:16:39 2008 UTC (10 years, 9 months ago) by dpavlin
File MIME type: application/x-troff
File size: 2040 byte(s)
first cut at simple API which currently segfaults after second open :-(
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 ok( tcjdbclose( $jdb ), 'tcjdbclose' );
39 diag tcjdberrmsg( tcjdbecode( $jdb ) );
40
41 ok( tcjdbopen( $jdb, $path, JDBOWRITER | JDBOCREAT ), "tcjdbopen $path again" );
42 diag tcjdberrmsg( tcjdbecode( $jdb ) );
43
44 ok( tcjdbput( $jdb, 1, [ 'foobar' ] ), 'tcjdbput' );
45 diag tcjdberrmsg( tcjdbecode( $jdb ) );
46
47 ok( tcjdbout( $jdb, 1 ), 'tcjdbout' );
48
49 ok( tcjdbput( $jdb, 42, [ 'some', 'data' ] ), 'tcjdbput again' );
50
51 ok( tcjdbput2( $jdb, 99, 'some more data again', ' ' ), 'tcjdbput2' );
52
53 is_deeply( tcjdbsearch( $jdb, 'some', JDBSSUBSTR ), [ 42 ], 'tcjdbsearch' );
54 ok( tcjdbput( $jdb, 65536, [ 'some', 'more', 'data' ] ), 'tcjdbput more data' );
55 is_deeply( tcjdbsearch( $jdb, 'some', JDBSSUBSTR ), [ 42, 65536 ], 'tcjdbsearch' );
56
57 ok( tcjdbsync( $jdb ), 'tcjdbsync' );
58
59 ok( tcjdboptimize( $jdb ), 'tcjdboptimize' );
60
61 my $copy_path = $path . '-copy';
62
63 ok( tcjdbcopy( $jdb, $copy_path ), "tcjdbcopy $copy_path" );
64 ok( -e $copy_path, 'copy exists' );
65
66 is( tcjdbpath( $jdb ), $path, 'tcjdbpath' );
67
68 is( tcjdbtnum( $jdb ), 13, 'tcjdbtnum' );
69
70 ok( my $file_size = tcjdbfsiz( $jdb ), 'tcjdbfsiz' );
71
72 ok( tcjdbvanish( $jdb ), 'tcjdbvanish' );
73
74 is( tcjdbrnum( $jdb ), 0, 'tcjdbrnum' );
75
76 cmp_ok( tcjdbfsiz( $jdb ), '<=', $file_size, 'tcjdbfsiz' );
77
78 diag tcjdberrmsg( tcjdbecode( $jdb ) );

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26