~ubuntu-branches/ubuntu/edgy/rpm/edgy

« back to all changes in this revision

Viewing changes to db/test/hsearch.tcl

  • Committer: Bazaar Package Importer
  • Author(s): Joey Hess
  • Date: 2002-01-22 20:56:57 UTC
  • Revision ID: james.westby@ubuntu.com-20020122205657-l74j50mr9z8ofcl5
Tags: upstream-4.0.3
ImportĀ upstreamĀ versionĀ 4.0.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# See the file LICENSE for redistribution information.
 
2
#
 
3
# Copyright (c) 1996-2001
 
4
#       Sleepycat Software.  All rights reserved.
 
5
#
 
6
# $Id: hsearch.tcl,v 11.8 2001/01/25 18:23:04 bostic Exp $
 
7
#
 
8
# Historic Hsearch interface test.
 
9
# Use the first 1000 entries from the dictionary.
 
10
# Insert each with self as key and data; retrieve each.
 
11
# After all are entered, retrieve all; compare output to original.
 
12
# Then reopen the file, re-retrieve everything.
 
13
# Finally, delete everything.
 
14
proc hsearch { { nentries 1000 } } {
 
15
        source ./include.tcl
 
16
 
 
17
        puts "HSEARCH interfaces test: $nentries"
 
18
 
 
19
        # Create the database and open the dictionary
 
20
        set t1 $testdir/t1
 
21
        set t2 $testdir/t2
 
22
        set t3 $testdir/t3
 
23
        cleanup $testdir NULL
 
24
 
 
25
        error_check_good hcreate [berkdb hcreate $nentries] 0
 
26
        set did [open $dict]
 
27
        set count 0
 
28
 
 
29
        puts "\tHSEARCH.a: put/get loop"
 
30
        # Here is the loop where we put and get each key/data pair
 
31
        while { [gets $did str] != -1 && $count < $nentries } {
 
32
                set ret [berkdb hsearch $str $str enter]
 
33
                error_check_good hsearch:enter $ret 0
 
34
 
 
35
                set d [berkdb hsearch $str 0 find]
 
36
                error_check_good hsearch:find $d $str
 
37
                incr count
 
38
        }
 
39
        close $did
 
40
 
 
41
        puts "\tHSEARCH.b: re-get loop"
 
42
        set did [open $dict]
 
43
        # Here is the loop where we retrieve each key
 
44
        while { [gets $did str] != -1 && $count < $nentries } {
 
45
                set d [berkdb hsearch $str 0 find]
 
46
                error_check_good hsearch:find $d $str
 
47
                incr count
 
48
        }
 
49
        close $did
 
50
        error_check_good hdestroy [berkdb hdestroy] 0
 
51
}