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

« back to all changes in this revision

Viewing changes to libdb/perl/BerkeleyDB/t/examples3.t.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
 
use strict ; 
4
 
 
5
 
BEGIN {
6
 
    unless(grep /blib/, @INC) {
7
 
        chdir 't' if -d 't';
8
 
        @INC = '../lib' if -d '../lib';
9
 
    }
10
 
}
11
 
 
12
 
use BerkeleyDB; 
13
 
use t::util;
14
 
 
15
 
BEGIN 
16
 
{
17
 
    if ($BerkeleyDB::db_version < 3) {
18
 
        print "1..0 # Skipping test, this needs Berkeley DB 3.x or better\n" ;
19
 
        exit 0 ;
20
 
    }
21
 
}
22
 
 
23
 
 
24
 
print "1..2\n";
25
 
 
26
 
my $Dfile = "dbhash.tmp";
27
 
my $Dfile2 = "dbhash2.tmp";
28
 
my $Dfile3 = "dbhash3.tmp";
29
 
unlink $Dfile;
30
 
 
31
 
umask(0) ;
32
 
 
33
 
my $redirect = "xyzt" ;
34
 
 
35
 
 
36
 
{
37
 
my $redirect = "xyzt" ;
38
 
 {
39
 
 
40
 
    my $redirectObj = new Redirect $redirect ;
41
 
 
42
 
## BEGIN dupHash
43
 
    use strict ;
44
 
    use BerkeleyDB ;
45
 
    
46
 
    my $filename = "fruit" ;
47
 
    unlink $filename ;
48
 
    my $db = new BerkeleyDB::Hash 
49
 
                -Filename => $filename, 
50
 
                -Flags    => DB_CREATE,
51
 
                -Property  => DB_DUP
52
 
        or die "Cannot open file $filename: $! $BerkeleyDB::Error\n" ;
53
 
 
54
 
    # Add a few key/value pairs to the file
55
 
    $db->db_put("red", "apple") ;
56
 
    $db->db_put("orange", "orange") ;
57
 
    $db->db_put("green", "banana") ;
58
 
    $db->db_put("yellow", "banana") ;
59
 
    $db->db_put("red", "tomato") ;
60
 
    $db->db_put("green", "apple") ;
61
 
    
62
 
    # print the contents of the file
63
 
    my ($k, $v) = ("", "") ;
64
 
    my $cursor = $db->db_cursor() ;
65
 
    while ($cursor->c_get($k, $v, DB_NEXT) == 0)
66
 
      { print "$k -> $v\n" }
67
 
      
68
 
    undef $cursor ;
69
 
    undef $db ;
70
 
## END dupHash
71
 
    unlink $filename ;
72
 
 }
73
 
 
74
 
  #print "[" . docat($redirect) . "]" ;
75
 
  ok(1, docat_del($redirect) eq <<'EOM') ;
76
 
orange -> orange
77
 
yellow -> banana
78
 
red -> apple
79
 
red -> tomato
80
 
green -> banana
81
 
green -> apple
82
 
EOM
83
 
 
84
 
}
85
 
 
86
 
{
87
 
my $redirect = "xyzt" ;
88
 
 {
89
 
 
90
 
    my $redirectObj = new Redirect $redirect ;
91
 
 
92
 
## BEGIN dupSortHash
93
 
    use strict ;
94
 
    use BerkeleyDB ;
95
 
    
96
 
    my $filename = "fruit" ;
97
 
    unlink $filename ;
98
 
    my $db = new BerkeleyDB::Hash 
99
 
                -Filename => $filename, 
100
 
                -Flags    => DB_CREATE,
101
 
                -Property  => DB_DUP | DB_DUPSORT
102
 
        or die "Cannot open file $filename: $! $BerkeleyDB::Error\n" ;
103
 
 
104
 
    # Add a few key/value pairs to the file
105
 
    $db->db_put("red", "apple") ;
106
 
    $db->db_put("orange", "orange") ;
107
 
    $db->db_put("green", "banana") ;
108
 
    $db->db_put("yellow", "banana") ;
109
 
    $db->db_put("red", "tomato") ;
110
 
    $db->db_put("green", "apple") ;
111
 
    
112
 
    # print the contents of the file
113
 
    my ($k, $v) = ("", "") ;
114
 
    my $cursor = $db->db_cursor() ;
115
 
    while ($cursor->c_get($k, $v, DB_NEXT) == 0)
116
 
      { print "$k -> $v\n" }
117
 
      
118
 
    undef $cursor ;
119
 
    undef $db ;
120
 
## END dupSortHash
121
 
    unlink $filename ;
122
 
 }
123
 
 
124
 
  #print "[" . docat($redirect) . "]" ;
125
 
  ok(2, docat_del($redirect) eq <<'EOM') ;
126
 
orange -> orange
127
 
yellow -> banana
128
 
red -> apple
129
 
red -> tomato
130
 
green -> apple
131
 
green -> banana
132
 
EOM
133
 
 
134
 
}
135
 
 
136