~ubuntu-branches/ubuntu/maverick/evolution-data-server/maverick-proposed

« back to all changes in this revision

Viewing changes to libdb/perl/BerkeleyDB/t/db-3.1.t

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2010-05-17 17:02:06 UTC
  • mfrom: (1.1.79 upstream) (1.6.12 experimental)
  • Revision ID: james.westby@ubuntu.com-20100517170206-4ufr52vwrhh26yh0
Tags: 2.30.1-1ubuntu1
* Merge from debian experimental. Remaining change:
  (LP: #42199, #229669, #173703, #360344, #508494)
  + debian/control:
    - add Vcs-Bzr tag
    - don't use libgnome
    - Use Breaks instead of Conflicts against evolution 2.25 and earlier.
  + debian/evolution-data-server.install,
    debian/patches/45_libcamel_providers_version.patch:
    - use the upstream versioning, not a Debian-specific one 
  + debian/libedata-book1.2-dev.install, debian/libebackend-1.2-dev.install,
    debian/libcamel1.2-dev.install, debian/libedataserverui1.2-dev.install:
    - install html documentation
  + debian/rules:
    - don't build documentation it's shipped with the tarball

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!./perl -w
2
 
 
3
 
# ID: %I%, %G%   
4
 
 
5
 
use strict ;
6
 
 
7
 
BEGIN {
8
 
    unless(grep /blib/, @INC) {
9
 
        chdir 't' if -d 't';
10
 
        @INC = '../lib' if -d '../lib';
11
 
    }
12
 
}
13
 
 
14
 
use BerkeleyDB; 
15
 
use t::util ;
16
 
 
17
 
BEGIN
18
 
{
19
 
    if ($BerkeleyDB::db_version < 3.1) {
20
 
        print "1..0 # Skipping test, this needs Berkeley DB 3.1.x or better\n" ;
21
 
        exit 0 ;
22
 
    }
23
 
}     
24
 
 
25
 
print "1..35\n";
26
 
 
27
 
my $Dfile = "dbhash.tmp";
28
 
my $Dfile2 = "dbhash2.tmp";
29
 
my $Dfile3 = "dbhash3.tmp";
30
 
unlink $Dfile;
31
 
 
32
 
umask(0) ;
33
 
 
34
 
 
35
 
 
36
 
{
37
 
    # c_count
38
 
 
39
 
    my $lex = new LexFile $Dfile ;
40
 
    my %hash ;
41
 
    ok 1, my $db = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile,
42
 
                                      -Property  => DB_DUP,
43
 
                                      -Flags    => DB_CREATE ;
44
 
 
45
 
    $hash{'Wall'} = 'Larry' ;
46
 
    $hash{'Wall'} = 'Stone' ;
47
 
    $hash{'Smith'} = 'John' ;
48
 
    $hash{'Wall'} = 'Brick' ;
49
 
    $hash{'Wall'} = 'Brick' ;
50
 
    $hash{'mouse'} = 'mickey' ;
51
 
 
52
 
    ok 2, keys %hash == 6 ;
53
 
 
54
 
    # create a cursor
55
 
    ok 3, my $cursor = $db->db_cursor() ;
56
 
 
57
 
    my $key = "Wall" ;
58
 
    my $value ;
59
 
    ok 4, $cursor->c_get($key, $value, DB_SET) == 0 ;
60
 
    ok 5, $key eq "Wall" && $value eq "Larry" ;
61
 
 
62
 
    my $count ;
63
 
    ok 6, $cursor->c_count($count) == 0 ;
64
 
    ok 7, $count == 4 ;
65
 
 
66
 
    $key = "Smith" ;
67
 
    ok 8, $cursor->c_get($key, $value, DB_SET) == 0 ;
68
 
    ok 9, $key eq "Smith" && $value eq "John" ;
69
 
 
70
 
    ok 10, $cursor->c_count($count) == 0 ;
71
 
    ok 11, $count == 1 ;
72
 
 
73
 
 
74
 
    undef $db ;
75
 
    undef $cursor ;
76
 
    untie %hash ;
77
 
 
78
 
}
79
 
 
80
 
{
81
 
    # db_key_range
82
 
 
83
 
    my $lex = new LexFile $Dfile ;
84
 
    my %hash ;
85
 
    ok 12, my $db = tie %hash, 'BerkeleyDB::Btree', -Filename => $Dfile,
86
 
                                      -Property  => DB_DUP,
87
 
                                      -Flags    => DB_CREATE ;
88
 
 
89
 
    $hash{'Wall'} = 'Larry' ;
90
 
    $hash{'Wall'} = 'Stone' ;
91
 
    $hash{'Smith'} = 'John' ;
92
 
    $hash{'Wall'} = 'Brick' ;
93
 
    $hash{'Wall'} = 'Brick' ;
94
 
    $hash{'mouse'} = 'mickey' ;
95
 
 
96
 
    ok 13, keys %hash == 6 ;
97
 
 
98
 
    my $key = "Wall" ;
99
 
    my ($less, $equal, $greater) ;
100
 
    ok 14, $db->db_key_range($key, $less, $equal, $greater) == 0 ;
101
 
 
102
 
    ok 15, $less != 0 ;
103
 
    ok 16, $equal != 0 ;
104
 
    ok 17, $greater != 0 ;
105
 
 
106
 
    $key = "Smith" ;
107
 
    ok 18, $db->db_key_range($key, $less, $equal, $greater) == 0 ;
108
 
 
109
 
    ok 19, $less == 0 ;
110
 
    ok 20, $equal != 0 ;
111
 
    ok 21, $greater != 0 ;
112
 
 
113
 
    $key = "NotThere" ;
114
 
    ok 22, $db->db_key_range($key, $less, $equal, $greater) == 0 ;
115
 
 
116
 
    ok 23, $less == 0 ;
117
 
    ok 24, $equal == 0 ;
118
 
    ok 25, $greater == 1 ;
119
 
 
120
 
    undef $db ;
121
 
    untie %hash ;
122
 
 
123
 
}
124
 
 
125
 
{
126
 
    # rename
127
 
 
128
 
    my $lex = new LexFile $Dfile ;
129
 
  
130
 
    ok 26, my $db1 = new BerkeleyDB::Hash -Filename => $Dfile, 
131
 
                                        -Subname  => "fred" ,
132
 
                                        -Flags    => DB_CREATE ;
133
 
 
134
 
    ok 27, my $db2 = new BerkeleyDB::Btree -Filename => $Dfile, 
135
 
                                        -Subname  => "joe" ,
136
 
                                        -Flags    => DB_CREATE ;
137
 
 
138
 
    # Add a k/v pair
139
 
    my %data = qw(
140
 
                        red     sky
141
 
                        blue    sea
142
 
                        black   heart
143
 
                        yellow  belley
144
 
                        green   grass
145
 
                ) ;
146
 
 
147
 
    ok 28, addData($db1, %data) ;
148
 
    ok 29, addData($db2, %data) ;
149
 
 
150
 
    undef $db1 ;
151
 
    undef $db2 ;
152
 
 
153
 
    # now rename 
154
 
    ok 30, BerkeleyDB::db_rename(-Filename => $Dfile, 
155
 
                              -Subname => "fred",
156
 
                              -Newname => "harry") == 0;
157
 
  
158
 
    ok 31, my $db3 = new BerkeleyDB::Hash -Filename => $Dfile, 
159
 
                                        -Subname  => "harry" ;
160
 
 
161
 
}
162
 
 
163
 
{
164
 
    # verify
165
 
 
166
 
    my $lex = new LexFile $Dfile, $Dfile2 ;
167
 
  
168
 
    ok 32, my $db1 = new BerkeleyDB::Hash -Filename => $Dfile, 
169
 
                                        -Subname  => "fred" ,
170
 
                                        -Flags    => DB_CREATE ;
171
 
 
172
 
    # Add a k/v pair
173
 
    my %data = qw(
174
 
                        red     sky
175
 
                        blue    sea
176
 
                        black   heart
177
 
                        yellow  belley
178
 
                        green   grass
179
 
                ) ;
180
 
 
181
 
    ok 33, addData($db1, %data) ;
182
 
 
183
 
    undef $db1 ;
184
 
 
185
 
    # now verify 
186
 
    ok 34, BerkeleyDB::db_verify(-Filename => $Dfile, 
187
 
                              -Subname => "fred",
188
 
                              ) == 0;
189
 
 
190
 
    # now verify & dump
191
 
    ok 35, BerkeleyDB::db_verify(-Filename => $Dfile, 
192
 
                              -Subname => "fred",
193
 
                              -Outfile => $Dfile2,
194
 
                              ) == 0;
195
 
  
196
 
}
197
 
 
198
 
# db_remove with env
199