--- t/10-xs.t 2008/08/18 17:26:01 15 +++ t/10-xs.t 2008/08/18 18:48:33 21 @@ -5,7 +5,7 @@ use blib; -use Test::More tests => 15; +use Test::More tests => 26; use Test::Exception; use Data::Dump qw/dump/; @@ -33,7 +33,7 @@ ok( tcidbsetfwmmax( $idb, 0 ), 'tcidbsetfwmmax' ); -ok( tcidbopen( $idb, $path, IDBOWRITER | IDBOCREAT ), "tcidbopen $path" ); +ok( tcidbopen( $idb, $path, IDBOWRITER | IDBOCREAT | IDBOTRUNC ), "tcidbopen $path" ); ok( tcidbclose( $idb ), 'tcidbclose' ); @@ -43,4 +43,26 @@ ok( tcidbout( $idb, 1, ), 'tcidbout' ); +ok( tcidbput( $idb, 42, 'some data' ), 'tcidbput again' ); +is( tcidbget( $idb, 42 ), 'some data', 'tcidbget' ); +ok( ! tcidbget( $idb, 1 ), 'tcidbget non-existing' ); + +is_deeply( tcidbsearch( $idb, 'some', IDBSSUBSTR ), [ 42 ], 'tcidbsearch' ); +ok( tcidbput( $idb, 65536, 'some more data' ), 'tcidbput more data' ); +is_deeply( tcidbsearch( $idb, 'some', IDBSSUBSTR ), [ 42, 65536 ], 'tcidbsearch' ); + +ok( tcidbiterinit( $idb ), 'tcidbiterinit' ); + +my @ids; + +while ( my $id = tcidbiternext( $idb ) ) { + ok( $id, "tcidbiternext $id" ); + push @ids, $id; +} + +# order is not defined, so we need to sort it +is_deeply( [ sort @ids ], [ 42, 65536 ], 'all records' ); + +ok( tcidbsync( $idb ), 'tcidbsync' ); + diag tcidberrmsg( tcidbecode( $idb ) );