/[Search-TokyoDystopia]/t/10-tci.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

Diff of /t/10-tci.t

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

t/10-xs.t revision 6 by dpavlin, Sun Aug 17 22:37:16 2008 UTC t/10-tci.t revision 31 by dpavlin, Tue Sep 2 15:28:58 2008 UTC
# Line 5  use strict; Line 5  use strict;
5    
6  use blib;  use blib;
7    
8  use Test::More tests => 8;  use Test::More tests => 36;
9  use Test::Exception;  use Test::Exception;
10  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
11    
# Line 13  BEGIN { Line 13  BEGIN {
13  use_ok( 'Search::TokyoDystopia' );  use_ok( 'Search::TokyoDystopia' );
14  }  }
15    
16    my $path = 'casket';
17    
18  cmp_ok( $Search::TokyoDystopia::debug, '==', 0, '$debug' );  cmp_ok( $Search::TokyoDystopia::debug, '==', 0, '$debug' );
19    
20  cmp_ok( Search::TokyoDystopia::errmsg(0), 'eq', 'success', 'errmsg' );  cmp_ok( tcidberrmsg(0), 'eq', 'success', 'tcidberrmsg' );
21    
22    ok( my $idb = tcidbnew, 'tcidbnew' );   # FIXME check better
23    
24    ok( ! tcidbdel( $idb ), 'tcidbdel' );
25    
26    ok( $idb = tcidbnew, 'tcidbnew again' );
27    
28    is( tcidbecode( $idb ), 0, 'tcidbecode' );
29    
30    ok( tcidbtune( $idb, 0, 0, 0, IDBTLARGE | IDBTDEFLATE ), 'tcidbtune' );
31    
32    ok( tcidbsetcache( $idb, 0, 0 ), 'tcidbsetcache' );
33    
34    ok( tcidbsetfwmmax( $idb, 0 ), 'tcidbsetfwmmax' );
35    
36    ok( tcidbopen( $idb, $path, IDBOWRITER | IDBOCREAT | IDBOTRUNC ), "tcidbopen $path" );
37    
38    ok( tcidbclose( $idb ), 'tcidbclose' );
39    
40    ok( tcidbopen( $idb, $path, IDBOWRITER | IDBOCREAT ), "tcidbopen $path again" );
41    
42    ok( tcidbput( $idb, 1, 'foobar' ), 'tcidbput' );
43    
44    ok( tcidbout( $idb, 1, ), 'tcidbout' );
45    
46    ok( tcidbput( $idb, 42, 'some data' ), 'tcidbput again' );
47    is( tcidbget( $idb, 42 ), 'some data', 'tcidbget' );
48    ok( ! tcidbget( $idb, 1 ), 'tcidbget non-existing' );
49    
50    is_deeply( tcidbsearch( $idb, 'some', IDBSSUBSTR ), [ 42 ], 'tcidbsearch' );
51    ok( tcidbput( $idb, 65536, 'some more data' ), 'tcidbput more data' );
52    is_deeply( tcidbsearch( $idb, 'some', IDBSSUBSTR ), [ 42, 65536 ], 'tcidbsearch' );
53    
54    is_deeply( tcidbsearch2( $idb, 'some' ), [ 42, 65536 ], 'tcidbsearch2' );
55    
56    ok( tcidbiterinit( $idb ), 'tcidbiterinit' );
57    
58    my @ids;
59    
60    while ( my $id = tcidbiternext( $idb ) ) {
61            ok( $id, "tcidbiternext $id" );
62            push @ids, $id;
63    }
64    
65    # order is not defined, so we need to sort it
66    is_deeply( [ sort @ids ], [ 42, 65536 ], 'all records' );
67    
68    ok( tcidbsync( $idb ), 'tcidbsync' );
69    
70    ok( tcidboptimize( $idb ), 'tcidboptimize' );
71    
72    my $copy_path = $path . '-copy';
73    
74    ok( tcidbcopy( $idb, $copy_path ), "tcidbcopy $copy_path" );
75    ok( -e $copy_path, 'copy exists' );
76    
77    is( tcidbpath( $idb ), $path, 'tcidbpath' );
78    
79    is( tcidbrnum( $idb ), 2, 'tcidbrnum' );
80    
81  ok( my $db = Search::TokyoDystopia::new, 'new' );       # FIXME check better  ok( my $file_size = tcidbfsiz( $idb ), 'tcidbfsiz' );
82    
83  ok( ! Search::TokyoDystopia::del( $db ), 'del' );  ok( tcidbvanish( $idb ), 'tcidbvanish' );
84    
85  ok( $db = Search::TokyoDystopia::new, 'new again' );  is( tcidbrnum( $idb ), 0, 'tcidbrnum' );
86    
87  is( Search::TokyoDystopia::ecode( $db ), 0, 'ecode' );  cmp_ok( tcidbfsiz( $idb ), '<', $file_size, 'tcidbfsiz' );
88    
89  is( Search::TokyoDystopia::tune( $db, 0, 0, 0, 0  ), 1, 'tune' );  diag tcidberrmsg( tcidbecode( $idb ) );

Legend:
Removed from v.6  
changed lines
  Added in v.31

  ViewVC Help
Powered by ViewVC 1.1.26