~ubuntu-branches/ubuntu/saucy/db/saucy-proposed

« back to all changes in this revision

Viewing changes to test/hsearch.tcl

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2010-11-05 15:02:09 UTC
  • mfrom: (13.1.12 sid)
  • Revision ID: james.westby@ubuntu.com-20101105150209-ppvyn0619pu014xo
Tags: 5.1.19-1ubuntu1
* Resynchronise with Debian.  Remaining changes:
  - Pass --build/--host to configure to support cross-building, and don't
    override CC.
  - Disable the Java build when cross-building, for now.

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