blob: e88b19f3440803d5ebdc31ff969e8631bcc7daf8 (
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
|
# uuid.test: tests for the uuid package -*- tcl -*-
#
# $Id: uuid.test,v 1.6 2006/10/09 21:41:42 andreas_kupries Exp $
# -------------------------------------------------------------------------
source [file join \
[file dirname [file dirname [file join [pwd] [info script]]]] \
devtools testutilities.tcl]
testsNeedTcl 8.5
testsNeedTcltest 1.0
testing {
useLocal uuid.tcl uuid
}
# -------------------------------------------------------------------------
# Handle multiple implementation testing
#
array set preserve [array get ::uuid::accel]
proc implementations {} {
variable ::uuid::accel
foreach {a v} [array get accel] {if {$v} {lappend r $a}}
lappend r tcl; set r
}
proc select_implementation {impl} {
variable ::uuid::accel
foreach e [array names accel] { set accel($e) 0 }
if {[string compare "tcl" $impl] != 0} {
set accel($impl) 1
}
}
proc reset_implementation {} {
variable ::uuid::accel
array set accel [array get ::preserve]
}
# -------------------------------------------------------------------------
# Setup any constraints
#
# -------------------------------------------------------------------------
# Now the package specific tests....
# -------------------------------------------------------------------------
if {[::uuid::LoadAccelerator critcl]} {
puts "> critcl based"
}
puts "> pure Tcl"
# -------------------------------------------------------------------------
foreach impl [implementations] {
select_implementation $impl
test uuid-1.0-$impl "uuid requires args" {
list [catch {uuid::uuid} msg]
} {1}
test uuid-1.1-$impl "uuid generate should create a 36 char string uuid" {
list [catch {string length [uuid::uuid generate]} msg] $msg
} {0 36}
test uuid-1.2-$impl "uuid comparison of uuid with self should be true" {
list [catch {
set a [uuid::uuid generate]
uuid::uuid equal $a $a
} msg] $msg
} {0 1}
test uuid-1.3-$impl "uuid comparison of two different\
uuids should be false" {
list [catch {
set a [uuid::uuid generate]
set b [uuid::uuid generate]
uuid::uuid equal $a $b
} msg] $msg
} {0 0}
reset_implementation
}
# -------------------------------------------------------------------------
testsuiteCleanup
# -------------------------------------------------------------------------
# Local Variables:
# mode: tcl
# indent-tabs-mode: nil
# End:
|