# Copyright (c) 2010 bivio Software, Inc. All Rights Reserved. # # Visit http://www.bivio.biz for more info. # # This library is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation; either version 2.1 of the # License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; If not, you may get a copy from: # http://www.opensource.org/licenses/lgpl-license.html # # $Id: BerkeleyDB.bunit,v 1.2 2010/11/07 22:15:58 nagler Exp $ Unit(); my($res) = ''; my($name) = 'BerkeleyDB.tmp'; [ class() => [ db_destroy => [ $name => not_die(), ], db_exists => [ $name => 0, ], db_create_or_open => [ $name => not_die(), 'sub-dir/not-there' => DIE(), ], db_exists => [ $name => 1, ], ], sub {class()->db_create_or_open($name)} => [ get_values => [ x => qr{not found}, ], unsafe_get_values => [ x => [undef], ], put_key_values => [ [map(($_ => ord($_)), qw(x y z))] => not_die(), ], get_values => [ [qw(x y)] => [ord('x'), ord('y')], ], db_do_glob => [ [ '*', sub { assert_equals(ord('x'), shift->get_values('x')); assert_equals($name, $name); return 1; }, ] => not_die(), ], do_key_values => [ [sub { my($k, $v) = @_; assert_equals(ord($k), $v); $res .= $k; return 1; }] => sub { assert_equals('xyz', $res); return 1; }, ], delete_keys => [ [qw(x z)] => not_die(), ], unsafe_get_values => [ x => [undef], y => ord('y'), z => [undef], ], db_close => not_die(), db_close => not_die(), unsafe_get_values => [ y => DIE(), ], ], ];