summaryrefslogtreecommitdiffstats
path: root/tcl8.6/pkgs/thread2.8.4/tests/tsv.test
blob: d25b0529712ce36f522ef80848408a0821d69710 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package require tcltest
namespace import ::tcltest::*
tcltest::loadTestedCommands
package require Thread

set backends {gdbm lmdb}

foreach b $backends {
    testConstraint have_$b [expr {$b in [tsv::handlers]}]
}

foreach backend $backends {
    set db "data"
    file delete -force $db
    set ::handle $backend:$db

    proc setup {} {
        tsv::array bind a $::handle
    }
    proc cleanup {} {
        tsv::array unbind a
    }

    test tsv-$backend-1.0 {tsv::array isboud} \
    -constraints have_$backend \
    -setup {
        setup
    } -body {
        tsv::array isbound a
    } -cleanup {
        cleanup
    } -result {1}

    test tsv-$backend-1.1 {tsv::array bind - empty} \
    -constraints have_$backend \
    -setup {
        setup
    } -body {
        tsv::array names b
    } -cleanup {
       cleanup
    } -result {}

    test tsv-$backend-1.2 {tsv::set} \
    -constraints have_$backend \
    -setup {
        setup
    } -body {
        tsv::set a Key Val
    } -cleanup {
        cleanup
    } -result {Val}

    test tsv-$backend-1.3 {tsv::get - previously set was persisted} \
    -constraints have_$backend \
    -setup {
        setup
    } -body {
        tsv::get a Key
    } -cleanup {
        cleanup
    } -result {Val}

    test tsv-$backend-1.4 {tsv::array names - previously set was persisted} \
    -constraints have_$backend \
    -setup {
        setup
    } -body {
        tsv::array names a
    } -cleanup {
        cleanup
    } -result {Key}

    test tsv-$backend-1.5 {tsv::exists - previously set exists} \
    -constraints have_$backend \
    -setup {
        setup
    } -body {
        tsv::exists a Key
    } -cleanup {
        cleanup
    } -result {1}

    test tsv-$backend-1.6 {tsv::pop - get previously set} \
    -constraints have_$backend \
    -setup {
        setup
    } -body {
        tsv::pop a Key
    } -cleanup {
        cleanup
    } -result {Val}

    test tsv-$backend-1.7 {tsv::exists - popped was removed} \
    -constraints have_$backend \
    -setup {
        setup
    } -body {
        tsv::exists a Key
    } -cleanup {
        cleanup
    } -result {0}

    file delete -force $db
}

::tcltest::cleanupTests