Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/tcl8.5.2/tests/registry.test @ 47

Last change on this file since 47 was 25, checked in by landauf, 17 years ago

added tcl to libs

File size: 28.2 KB
Line 
1# registry.test --
2#
3# This file contains a collection of tests for the registry command.
4# Sourcing this file into Tcl runs the tests and generates output for
5# errors.  No output means no errors were found.
6#
7# In order for these tests to run, the registry package must be on the
8# auto_path or the registry package must have been loaded already.
9#
10# Copyright (c) 1997 by Sun Microsystems, Inc.  All rights reserved.
11# Copyright (c) 1998-1999 by Scriptics Corporation.
12#
13# RCS: @(#) $Id: registry.test,v 1.21 2007/04/20 13:39:04 dkf Exp $
14
15if {[lsearch [namespace children] ::tcltest] == -1} {
16    package require tcltest 2
17    namespace import -force ::tcltest::*
18}
19
20testConstraint reg 0
21if {[testConstraint win]} {
22    catch {
23        # Is the registry extension already static to this shell?
24        if [catch {load {} Registry; set ::reglib {}}] {
25            # try the location given to use on the commandline to tcltest
26            ::tcltest::loadTestedCommands
27            load $::reglib Registry
28        }
29        testConstraint reg 1
30    }
31}
32
33# determine the current locale
34testConstraint english [expr {
35    [llength [info commands testlocale]]
36    && [string match "English*" [testlocale all ""]]
37}]
38
39test registry-1.1 {argument parsing for registry command} {win reg} {
40    list [catch {registry} msg] $msg
41} {1 {wrong # args: should be "registry option ?arg arg ...?"}}
42test registry-1.2 {argument parsing for registry command} {win reg} {
43    list [catch {registry foo} msg] $msg
44} {1 {bad option "foo": must be broadcast, delete, get, keys, set, type, or values}}
45
46test registry-1.3 {argument parsing for registry command} {win reg} {
47    list [catch {registry d} msg] $msg
48} {1 {wrong # args: should be "registry delete keyName ?valueName?"}}
49test registry-1.4 {argument parsing for registry command} {win reg} {
50    list [catch {registry delete} msg] $msg
51} {1 {wrong # args: should be "registry delete keyName ?valueName?"}}
52test registry-1.5 {argument parsing for registry command} {win reg} {
53    list [catch {registry delete foo bar baz} msg] $msg
54} {1 {wrong # args: should be "registry delete keyName ?valueName?"}}
55
56test registry-1.6 {argument parsing for registry command} {win reg} {
57    list [catch {registry g} msg] $msg
58} {1 {wrong # args: should be "registry get keyName valueName"}}
59test registry-1.7 {argument parsing for registry command} {win reg} {
60    list [catch {registry get} msg] $msg
61} {1 {wrong # args: should be "registry get keyName valueName"}}
62test registry-1.8 {argument parsing for registry command} {win reg} {
63    list [catch {registry get foo} msg] $msg
64} {1 {wrong # args: should be "registry get keyName valueName"}}
65test registry-1.9 {argument parsing for registry command} {win reg} {
66    list [catch {registry get foo bar baz} msg] $msg
67} {1 {wrong # args: should be "registry get keyName valueName"}}
68
69test registry-1.10 {argument parsing for registry command} {win reg} {
70    list [catch {registry k} msg] $msg
71} {1 {wrong # args: should be "registry keys keyName ?pattern?"}}
72test registry-1.11 {argument parsing for registry command} {win reg} {
73    list [catch {registry keys} msg] $msg
74} {1 {wrong # args: should be "registry keys keyName ?pattern?"}}
75test registry-1.12 {argument parsing for registry command} {win reg} {
76    list [catch {registry keys foo bar baz} msg] $msg
77} {1 {wrong # args: should be "registry keys keyName ?pattern?"}}
78
79test registry-1.13 {argument parsing for registry command} {win reg} {
80    list [catch {registry s} msg] $msg
81} {1 {wrong # args: should be "registry set keyName ?valueName data ?type??"}}
82test registry-1.14 {argument parsing for registry command} {win reg} {
83    list [catch {registry set} msg] $msg
84} {1 {wrong # args: should be "registry set keyName ?valueName data ?type??"}}
85test registry-1.15 {argument parsing for registry command} {win reg} {
86    list [catch {registry set foo bar} msg] $msg
87} {1 {wrong # args: should be "registry set keyName ?valueName data ?type??"}}
88test registry-1.16 {argument parsing for registry command} {win reg} {
89    list [catch {registry set foo bar baz blat gorp} msg] $msg
90} {1 {wrong # args: should be "registry set keyName ?valueName data ?type??"}}
91
92test registry-1.17 {argument parsing for registry command} {win reg} {
93    list [catch {registry t} msg] $msg
94} {1 {wrong # args: should be "registry type keyName valueName"}}
95test registry-1.18 {argument parsing for registry command} {win reg} {
96    list [catch {registry type} msg] $msg
97} {1 {wrong # args: should be "registry type keyName valueName"}}
98test registry-1.19 {argument parsing for registry command} {win reg} {
99    list [catch {registry type foo} msg] $msg
100} {1 {wrong # args: should be "registry type keyName valueName"}}
101test registry-1.20 {argument parsing for registry command} {win reg} {
102    list [catch {registry type foo bar baz} msg] $msg
103} {1 {wrong # args: should be "registry type keyName valueName"}}
104
105test registry-1.21 {argument parsing for registry command} {win reg} {
106    list [catch {registry v} msg] $msg
107} {1 {wrong # args: should be "registry values keyName ?pattern?"}}
108test registry-1.22 {argument parsing for registry command} {win reg} {
109    list [catch {registry values} msg] $msg
110} {1 {wrong # args: should be "registry values keyName ?pattern?"}}
111test registry-1.23 {argument parsing for registry command} {win reg} {
112    list [catch {registry values foo bar baz} msg] $msg
113} {1 {wrong # args: should be "registry values keyName ?pattern?"}}
114
115test registry-2.1 {DeleteKey: bad key} {win reg} {
116    list [catch {registry delete foo} msg] $msg
117} {1 {bad root name "foo": must be HKEY_LOCAL_MACHINE, HKEY_USERS, HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_CURRENT_CONFIG, HKEY_PERFORMANCE_DATA, or HKEY_DYN_DATA}}
118test registry-2.2 {DeleteKey: bad key} {win reg} {
119    list [catch {registry delete HKEY_CLASSES_ROOT} msg] $msg
120} {1 {bad key: cannot delete root keys}}
121test registry-2.3 {DeleteKey: bad key} {win reg} {
122    list [catch {registry delete HKEY_CLASSES_ROOT\\} msg] $msg
123} {1 {bad key: cannot delete root keys}}
124test registry-2.4 {DeleteKey: subkey at root level} {win reg} {
125    registry set HKEY_CLASSES_ROOT\\TclFoobar
126    registry delete HKEY_CLASSES_ROOT\\TclFoobar
127    registry keys HKEY_CLASSES_ROOT TclFoobar
128} {}
129test registry-2.5 {DeleteKey: subkey below root level} {win reg} {
130    registry set HKEY_CLASSES_ROOT\\TclFoobar\\test
131    registry delete HKEY_CLASSES_ROOT\\TclFoobar\\test
132    set result [registry keys HKEY_CLASSES_ROOT TclFoobar\\test]
133    registry delete HKEY_CLASSES_ROOT\\TclFoobar
134    set result
135} {}
136test registry-2.6 {DeleteKey: recursive delete} {win reg} {
137    registry set HKEY_CLASSES_ROOT\\TclFoobar\\test1
138    registry set HKEY_CLASSES_ROOT\\TclFoobar\\test2\\test3
139    registry delete HKEY_CLASSES_ROOT\\TclFoobar
140    set result [registry keys HKEY_CLASSES_ROOT TclFoobar]
141    set result
142} {}
143test registry-2.7 {DeleteKey: trailing backslashes} {win reg english} {
144    registry set HKEY_CLASSES_ROOT\\TclFoobar\\baz
145    list [catch {registry delete HKEY_CLASSES_ROOT\\TclFoobar\\} msg] $msg
146} {1 {unable to delete key: The configuration registry key is invalid.}}
147test registry-2.8 {DeleteKey: failure} {win reg} {
148    registry delete HKEY_CLASSES_ROOT\\TclFoobar
149    registry delete HKEY_CLASSES_ROOT\\TclFoobar
150} {}
151test registry-2.9 {DeleteKey: unicode} {win reg} {
152    registry delete HKEY_CLASSES_ROOT\\TclFoobar
153    registry set HKEY_CLASSES_ROOT\\TclFoobar\\test\u00c7bar\\a
154    registry set HKEY_CLASSES_ROOT\\TclFoobar\\test\u00c7bar\\b
155    registry delete HKEY_CLASSES_ROOT\\TclFoobar\\test\u00c7bar
156    set result [registry keys HKEY_CLASSES_ROOT\\TclFoobar]
157    registry delete HKEY_CLASSES_ROOT\\TclFoobar
158    set result
159} {}
160
161test registry-3.1 {DeleteValue} {win reg} {
162    registry delete HKEY_CLASSES_ROOT\\TclFoobar
163    registry set HKEY_CLASSES_ROOT\\TclFoobar\\baz test1 blort
164    registry set HKEY_CLASSES_ROOT\\TclFoobar\\baz test2 blat
165    registry delete HKEY_CLASSES_ROOT\\TclFoobar\\baz test1
166    set result [registry values HKEY_CLASSES_ROOT\\TclFoobar\\baz]
167    registry delete HKEY_CLASSES_ROOT\\TclFoobar
168    set result
169} test2
170test registry-3.2 {DeleteValue: bad key} {win reg english} {
171    registry delete HKEY_CLASSES_ROOT\\TclFoobar
172    list [catch {registry delete HKEY_CLASSES_ROOT\\TclFoobar test} msg] $msg
173} {1 {unable to open key: The system cannot find the file specified.}}
174test registry-3.3 {DeleteValue: bad value} {win reg english} {
175    registry delete HKEY_CLASSES_ROOT\\TclFoobar
176    registry set HKEY_CLASSES_ROOT\\TclFoobar\\baz test2 blort
177    set result [list [catch {registry delete HKEY_CLASSES_ROOT\\TclFoobar test1} msg] $msg]
178    registry delete HKEY_CLASSES_ROOT\\TclFoobar
179    set result
180} {1 {unable to delete value "test1" from key "HKEY_CLASSES_ROOT\TclFoobar": The system cannot find the file specified.}}
181test registry-3.4 {DeleteValue: Unicode} {win reg} {
182    registry delete HKEY_CLASSES_ROOT\\TclFoobar
183    registry set HKEY_CLASSES_ROOT\\TclFoobar\\\u00c7baz \u00c7test1 blort
184    registry set HKEY_CLASSES_ROOT\\TclFoobar\\\u00c7baz test2 blat
185    registry delete HKEY_CLASSES_ROOT\\TclFoobar\\\u00c7baz \u00c7test1
186    set result [registry values HKEY_CLASSES_ROOT\\TclFoobar\\\u00c7baz]
187    registry delete HKEY_CLASSES_ROOT\\TclFoobar
188    set result
189} test2
190
191test registry-4.1 {GetKeyNames: bad key} {win reg english} {
192    registry delete HKEY_CLASSES_ROOT\\TclFoobar
193    list [catch {registry keys HKEY_CLASSES_ROOT\\TclFoobar} msg] $msg
194} {1 {unable to open key: The system cannot find the file specified.}}
195test registry-4.2 {GetKeyNames} {win reg} {
196    registry delete HKEY_CLASSES_ROOT\\TclFoobar
197    registry set HKEY_CLASSES_ROOT\\TclFoobar\\baz
198    set result [registry keys HKEY_CLASSES_ROOT\\TclFoobar]
199    registry delete HKEY_CLASSES_ROOT\\TclFoobar
200    set result
201} {baz}
202test registry-4.3 {GetKeyNames: remote key} {win reg nonPortable english} {
203    set hostname [info hostname]
204    registry set \\\\$hostname\\HKEY_CLASSES_ROOT\\TclFoobar\\baz
205    set result [registry keys \\\\gaspode\\HKEY_CLASSES_ROOT\\TclFoobar]
206    registry delete \\\\$hostname\\HKEY_CLASSES_ROOT\\TclFoobar
207    set result
208} {baz}
209test registry-4.4 {GetKeyNames: empty key} {win reg} {
210    registry delete HKEY_CLASSES_ROOT\\TclFoobar
211    registry set HKEY_CLASSES_ROOT\\TclFoobar
212    set result [registry keys HKEY_CLASSES_ROOT\\TclFoobar]
213    registry delete HKEY_CLASSES_ROOT\\TclFoobar
214    set result
215} {}
216test registry-4.5 {GetKeyNames: patterns} {win reg} {
217    registry delete HKEY_CLASSES_ROOT\\TclFoobar
218    registry set HKEY_CLASSES_ROOT\\TclFoobar\\baz
219    registry set HKEY_CLASSES_ROOT\\TclFoobar\\blat
220    registry set HKEY_CLASSES_ROOT\\TclFoobar\\foo
221    set result [lsort [registry keys HKEY_CLASSES_ROOT\\TclFoobar b*]]
222    registry delete HKEY_CLASSES_ROOT\\TclFoobar
223    set result
224} {baz blat}
225test registry-4.6 {GetKeyNames: names with spaces} {win reg} {
226    registry delete HKEY_CLASSES_ROOT\\TclFoobar
227    registry set HKEY_CLASSES_ROOT\\TclFoobar\\baz\ bar
228    registry set HKEY_CLASSES_ROOT\\TclFoobar\\blat
229    registry set HKEY_CLASSES_ROOT\\TclFoobar\\foo
230    set result [lsort [registry keys HKEY_CLASSES_ROOT\\TclFoobar b*]]
231    registry delete HKEY_CLASSES_ROOT\\TclFoobar
232    set result
233} {{baz bar} blat}
234test registry-4.7 {GetKeyNames: Unicode} {win reg english} {
235    registry delete HKEY_CLASSES_ROOT\\TclFoobar
236    registry set HKEY_CLASSES_ROOT\\TclFoobar\\baz\u00c7bar
237    registry set HKEY_CLASSES_ROOT\\TclFoobar\\blat
238    registry set HKEY_CLASSES_ROOT\\TclFoobar\\foo
239    set result [lsort [registry keys HKEY_CLASSES_ROOT\\TclFoobar b*]]
240    registry delete HKEY_CLASSES_ROOT\\TclFoobar
241    set result
242} "baz\u00c7bar blat"
243test registry-4.8 {GetKeyNames: Unicode} {win reg nt} {
244    registry delete HKEY_CLASSES_ROOT\\TclFoobar
245    registry set HKEY_CLASSES_ROOT\\TclFoobar\\baz\u30b7bar
246    registry set HKEY_CLASSES_ROOT\\TclFoobar\\blat
247    registry set HKEY_CLASSES_ROOT\\TclFoobar\\foo
248    set result [lsort [registry keys HKEY_CLASSES_ROOT\\TclFoobar b*]]
249    registry delete HKEY_CLASSES_ROOT\\TclFoobar
250    set result
251} "baz\u30b7bar blat"
252test registry-4.9 {GetKeyNames: very long key [Bug 1682211]} {*}{
253    -constraints {win reg}
254    -setup {
255        registry set HKEY_CLASSES_ROOT\\TclFoobar\\a
256        registry set HKEY_CLASSES_ROOT\\TclFoobar\\b[string repeat x 254]
257        registry set HKEY_CLASSES_ROOT\\TclFoobar\\c
258    }
259    -body {
260        lsort [registry keys HKEY_CLASSES_ROOT\\TclFoobar]
261    }
262    -cleanup {
263        registry delete HKEY_CLASSES_ROOT\\TclFoobar
264    }} \
265    -result [list a b[string repeat x 254] c]
266
267test registry-5.1 {GetType} {win reg english} {
268    registry delete HKEY_CLASSES_ROOT\\TclFoobar
269    list [catch {registry type HKEY_CLASSES_ROOT\\TclFoobar val1} msg] $msg
270} {1 {unable to open key: The system cannot find the file specified.}}
271test registry-5.2 {GetType} {win reg english} {
272    registry set HKEY_CLASSES_ROOT\\TclFoobar
273    list [catch {registry type HKEY_CLASSES_ROOT\\TclFoobar val1} msg] $msg
274} {1 {unable to get type of value "val1" from key "HKEY_CLASSES_ROOT\TclFoobar": The system cannot find the file specified.}}
275test registry-5.3 {GetType} {win reg} {
276    registry set HKEY_CLASSES_ROOT\\TclFoobar val1 foobar none
277    set result [registry type HKEY_CLASSES_ROOT\\TclFoobar val1]
278    registry delete HKEY_CLASSES_ROOT\\TclFoobar
279    set result
280} none
281test registry-5.4 {GetType} {win reg} {
282    registry set HKEY_CLASSES_ROOT\\TclFoobar val1 foobar
283    set result [registry type HKEY_CLASSES_ROOT\\TclFoobar val1]
284    registry delete HKEY_CLASSES_ROOT\\TclFoobar
285    set result
286} sz
287test registry-5.5 {GetType} {win reg} {
288    registry set HKEY_CLASSES_ROOT\\TclFoobar val1 foobar sz
289    set result [registry type HKEY_CLASSES_ROOT\\TclFoobar val1]
290    registry delete HKEY_CLASSES_ROOT\\TclFoobar
291    set result
292} sz
293test registry-5.6 {GetType} {win reg} {
294    registry set HKEY_CLASSES_ROOT\\TclFoobar val1 foobar expand_sz
295    set result [registry type HKEY_CLASSES_ROOT\\TclFoobar val1]
296    registry delete HKEY_CLASSES_ROOT\\TclFoobar
297    set result
298} expand_sz
299test registry-5.7 {GetType} {win reg} {
300    registry set HKEY_CLASSES_ROOT\\TclFoobar val1 1 binary
301    set result [registry type HKEY_CLASSES_ROOT\\TclFoobar val1]
302    registry delete HKEY_CLASSES_ROOT\\TclFoobar
303    set result
304} binary
305test registry-5.8 {GetType} {win reg} {
306    registry set HKEY_CLASSES_ROOT\\TclFoobar val1 1 dword
307    set result [registry type HKEY_CLASSES_ROOT\\TclFoobar val1]
308    registry delete HKEY_CLASSES_ROOT\\TclFoobar
309    set result
310} dword
311test registry-5.9 {GetType} {win reg} {
312    registry set HKEY_CLASSES_ROOT\\TclFoobar val1 1 dword_big_endian
313    set result [registry type HKEY_CLASSES_ROOT\\TclFoobar val1]
314    registry delete HKEY_CLASSES_ROOT\\TclFoobar
315    set result
316} dword_big_endian
317test registry-5.10 {GetType} {win reg} {
318    registry set HKEY_CLASSES_ROOT\\TclFoobar val1 1 link
319    set result [registry type HKEY_CLASSES_ROOT\\TclFoobar val1]
320    registry delete HKEY_CLASSES_ROOT\\TclFoobar
321    set result
322} link
323test registry-5.11 {GetType} {win reg} {
324    registry set HKEY_CLASSES_ROOT\\TclFoobar val1 foobar multi_sz
325    set result [registry type HKEY_CLASSES_ROOT\\TclFoobar val1]
326    registry delete HKEY_CLASSES_ROOT\\TclFoobar
327    set result
328} multi_sz
329test registry-5.12 {GetType} {win reg} {
330    registry set HKEY_CLASSES_ROOT\\TclFoobar val1 1 resource_list
331    set result [registry type HKEY_CLASSES_ROOT\\TclFoobar val1]
332    registry delete HKEY_CLASSES_ROOT\\TclFoobar
333    set result
334} resource_list
335test registry-5.13 {GetType: unknown types} {win reg} {
336    registry set HKEY_CLASSES_ROOT\\TclFoobar val1 1 24
337    set result [registry type HKEY_CLASSES_ROOT\\TclFoobar val1]
338    registry delete HKEY_CLASSES_ROOT\\TclFoobar
339    set result
340} 24
341test registry-5.14 {GetType: Unicode} {win reg} {
342    registry set HKEY_CLASSES_ROOT\\TclFoobar va\u00c7l1 1 24
343    set result [registry type HKEY_CLASSES_ROOT\\TclFoobar va\u00c7l1]
344    registry delete HKEY_CLASSES_ROOT\\TclFoobar
345    set result
346} 24
347
348test registry-6.1 {GetValue} {win reg english} {
349    registry delete HKEY_CLASSES_ROOT\\TclFoobar
350    list [catch {registry get HKEY_CLASSES_ROOT\\TclFoobar val1} msg] $msg
351} {1 {unable to open key: The system cannot find the file specified.}}
352test registry-6.2 {GetValue} {win reg english} {
353    registry set HKEY_CLASSES_ROOT\\TclFoobar
354    list [catch {registry get HKEY_CLASSES_ROOT\\TclFoobar val1} msg] $msg
355} {1 {unable to get value "val1" from key "HKEY_CLASSES_ROOT\TclFoobar": The system cannot find the file specified.}}
356test registry-6.3 {GetValue} {win reg} {
357    registry set HKEY_CLASSES_ROOT\\TclFoobar val1 foobar none
358    set result [registry get HKEY_CLASSES_ROOT\\TclFoobar val1]
359    registry delete HKEY_CLASSES_ROOT\\TclFoobar
360    set result
361} foobar
362test registry-6.4 {GetValue} {win reg} {
363    registry set HKEY_CLASSES_ROOT\\TclFoobar val1 foobar
364    set result [registry get HKEY_CLASSES_ROOT\\TclFoobar val1]
365    registry delete HKEY_CLASSES_ROOT\\TclFoobar
366    set result
367} foobar
368test registry-6.5 {GetValue} {win reg} {
369    registry set HKEY_CLASSES_ROOT\\TclFoobar val1 foobar sz
370    set result [registry get HKEY_CLASSES_ROOT\\TclFoobar val1]
371    registry delete HKEY_CLASSES_ROOT\\TclFoobar
372    set result
373} foobar
374test registry-6.6 {GetValue} {win reg} {
375    registry set HKEY_CLASSES_ROOT\\TclFoobar val1 foobar expand_sz
376    set result [registry get HKEY_CLASSES_ROOT\\TclFoobar val1]
377    registry delete HKEY_CLASSES_ROOT\\TclFoobar
378    set result
379} foobar
380test registry-6.7 {GetValue} {win reg} {
381    registry set HKEY_CLASSES_ROOT\\TclFoobar val1 1 binary
382    set result [registry get HKEY_CLASSES_ROOT\\TclFoobar val1]
383    registry delete HKEY_CLASSES_ROOT\\TclFoobar
384    set result
385} 1
386test registry-6.8 {GetValue} {win reg} {
387    registry set HKEY_CLASSES_ROOT\\TclFoobar val1 0x20 dword
388    set result [registry get HKEY_CLASSES_ROOT\\TclFoobar val1]
389    registry delete HKEY_CLASSES_ROOT\\TclFoobar
390    set result
391} 32
392test registry-6.9 {GetValue} {win reg} {
393    registry set HKEY_CLASSES_ROOT\\TclFoobar val1 0x20 dword_big_endian
394    set result [registry get HKEY_CLASSES_ROOT\\TclFoobar val1]
395    registry delete HKEY_CLASSES_ROOT\\TclFoobar
396    set result
397} 32
398test registry-6.10 {GetValue} {win reg} {
399    registry set HKEY_CLASSES_ROOT\\TclFoobar val1 1 link
400    set result [registry get HKEY_CLASSES_ROOT\\TclFoobar val1]
401    registry delete HKEY_CLASSES_ROOT\\TclFoobar
402    set result
403} 1
404test registry-6.11 {GetValue} {win reg} {
405    registry set HKEY_CLASSES_ROOT\\TclFoobar val1 foobar multi_sz
406    set result [registry get HKEY_CLASSES_ROOT\\TclFoobar val1]
407    registry delete HKEY_CLASSES_ROOT\\TclFoobar
408    set result
409} foobar
410test registry-6.12 {GetValue} {win reg} {
411    registry set HKEY_CLASSES_ROOT\\TclFoobar val1 {foo\ bar baz} multi_sz
412    set result [registry get HKEY_CLASSES_ROOT\\TclFoobar val1]
413    registry delete HKEY_CLASSES_ROOT\\TclFoobar
414    set result
415} {{foo bar} baz}
416test registry-6.13 {GetValue} {win reg} {
417    registry set HKEY_CLASSES_ROOT\\TclFoobar val1 {} multi_sz
418    set result [registry get HKEY_CLASSES_ROOT\\TclFoobar val1]
419    registry delete HKEY_CLASSES_ROOT\\TclFoobar
420    set result
421} {}
422test registry-6.14 {GetValue: truncation of multivalues with null elements} \
423        {win reg} {
424    registry set HKEY_CLASSES_ROOT\\TclFoobar val1 {a {} b} multi_sz
425    set result [registry get HKEY_CLASSES_ROOT\\TclFoobar val1]
426    registry delete HKEY_CLASSES_ROOT\\TclFoobar
427    set result
428} a
429test registry-6.15 {GetValue} {win reg} {
430    registry set HKEY_CLASSES_ROOT\\TclFoobar val1 1 resource_list
431    set result [registry get HKEY_CLASSES_ROOT\\TclFoobar val1]
432    registry delete HKEY_CLASSES_ROOT\\TclFoobar
433    set result
434} 1
435test registry-6.16 {GetValue: unknown types} {win reg} {
436    registry set HKEY_CLASSES_ROOT\\TclFoobar val1 1 24
437    set result [registry get HKEY_CLASSES_ROOT\\TclFoobar val1]
438    registry delete HKEY_CLASSES_ROOT\\TclFoobar
439    set result
440} 1
441test registry-6.17 {GetValue: Unicode value names} {win reg} {
442    registry set HKEY_CLASSES_ROOT\\TclFoobar val\u00c71 foobar multi_sz
443    set result [registry get HKEY_CLASSES_ROOT\\TclFoobar val\u00c71]
444    registry delete HKEY_CLASSES_ROOT\\TclFoobar
445    set result
446} foobar
447test registry-6.18 {GetValue: values with Unicode strings} {win reg nt} {
448    registry set HKEY_CLASSES_ROOT\\TclFoobar val1 {foo ba\u30b7r baz} multi_sz
449    set result [registry get HKEY_CLASSES_ROOT\\TclFoobar val1]
450    registry delete HKEY_CLASSES_ROOT\\TclFoobar
451    set result
452} "foo ba\u30b7r baz"
453test registry-6.19 {GetValue: values with Unicode strings} {win reg english} {
454    registry set HKEY_CLASSES_ROOT\\TclFoobar val1 {foo ba\u00c7r baz} multi_sz
455    set result [registry get HKEY_CLASSES_ROOT\\TclFoobar val1]
456    registry delete HKEY_CLASSES_ROOT\\TclFoobar
457    set result
458} "foo ba\u00c7r baz"
459test registry-6.20 {GetValue: values with Unicode strings with embedded nulls} {win reg} {
460    registry set HKEY_CLASSES_ROOT\\TclFoobar val1 {foo ba\u0000r baz} multi_sz
461    set result [registry get HKEY_CLASSES_ROOT\\TclFoobar val1]
462    registry delete HKEY_CLASSES_ROOT\\TclFoobar
463    set result
464} "foo ba r baz"
465
466test registry-7.1 {GetValueNames: bad key} {win reg english} {
467    registry delete HKEY_CLASSES_ROOT\\TclFoobar
468    list [catch {registry values HKEY_CLASSES_ROOT\\TclFoobar} msg] $msg
469} {1 {unable to open key: The system cannot find the file specified.}}
470test registry-7.2 {GetValueNames} {win reg} {
471    registry delete HKEY_CLASSES_ROOT\\TclFoobar
472    registry set HKEY_CLASSES_ROOT\\TclFoobar baz foobar
473    set result [registry values HKEY_CLASSES_ROOT\\TclFoobar]
474    registry delete HKEY_CLASSES_ROOT\\TclFoobar
475    set result
476} baz
477test registry-7.3 {GetValueNames} {win reg} {
478    registry delete HKEY_CLASSES_ROOT\\TclFoobar
479    registry set HKEY_CLASSES_ROOT\\TclFoobar baz foobar1
480    registry set HKEY_CLASSES_ROOT\\TclFoobar blat foobar2
481    registry set HKEY_CLASSES_ROOT\\TclFoobar {} foobar3
482    set result [lsort [registry values HKEY_CLASSES_ROOT\\TclFoobar]]
483    registry delete HKEY_CLASSES_ROOT\\TclFoobar
484    set result
485} {{} baz blat}
486test registry-7.4 {GetValueNames: remote key} {win reg nonPortable english} {
487    set hostname [info hostname]
488    registry set \\\\$hostname\\HKEY_CLASSES_ROOT\\TclFoobar baz blat
489    set result [registry values \\\\$hostname\\HKEY_CLASSES_ROOT\\TclFoobar]
490    registry delete \\\\$hostname\\HKEY_CLASSES_ROOT\\TclFoobar
491    set result
492} baz
493test registry-7.5 {GetValueNames: empty key} {win reg} {
494    registry delete HKEY_CLASSES_ROOT\\TclFoobar
495    registry set HKEY_CLASSES_ROOT\\TclFoobar
496    set result [registry values HKEY_CLASSES_ROOT\\TclFoobar]
497    registry delete HKEY_CLASSES_ROOT\\TclFoobar
498    set result
499} {}
500test registry-7.6 {GetValueNames: patterns} {win reg} {
501    registry delete HKEY_CLASSES_ROOT\\TclFoobar
502    registry set HKEY_CLASSES_ROOT\\TclFoobar baz foobar1
503    registry set HKEY_CLASSES_ROOT\\TclFoobar blat foobar2
504    registry set HKEY_CLASSES_ROOT\\TclFoobar foo foobar3
505    set result [lsort [registry values HKEY_CLASSES_ROOT\\TclFoobar b*]]
506    registry delete HKEY_CLASSES_ROOT\\TclFoobar
507    set result
508} {baz blat}
509test registry-7.7 {GetValueNames: names with spaces} {win reg} {
510    registry delete HKEY_CLASSES_ROOT\\TclFoobar
511    registry set HKEY_CLASSES_ROOT\\TclFoobar baz\ bar foobar1
512    registry set HKEY_CLASSES_ROOT\\TclFoobar blat foobar2
513    registry set HKEY_CLASSES_ROOT\\TclFoobar foo foobar3
514    set result [lsort [registry values HKEY_CLASSES_ROOT\\TclFoobar b*]]
515    registry delete HKEY_CLASSES_ROOT\\TclFoobar
516    set result
517} {{baz bar} blat}
518
519test registry-8.1 {OpenSubKey} {win reg nonPortable english} {
520    # This test will only succeed if the current user does not have registry
521    # access on the specified machine.
522    list [catch {registry keys {\\mom\HKEY_LOCAL_MACHINE}} msg] $msg
523} {1 {unable to open key: Access is denied.}}
524test registry-8.2 {OpenSubKey} {win reg} {
525    registry delete HKEY_CLASSES_ROOT\\TclFoobar
526    registry set HKEY_CLASSES_ROOT\\TclFoobar
527    set result [registry keys HKEY_CLASSES_ROOT TclFoobar]
528    registry delete HKEY_CLASSES_ROOT\\TclFoobar
529    set result
530} TclFoobar
531test registry-8.3 {OpenSubKey} {win reg english} {
532    registry delete HKEY_CLASSES_ROOT\\TclFoobar
533    list [catch {registry keys HKEY_CLASSES_ROOT\\TclFoobar} msg] $msg
534} {1 {unable to open key: The system cannot find the file specified.}}
535
536test registry-9.1 {ParseKeyName: bad keys} {win reg} {
537    list [catch {registry values \\} msg] $msg
538} "1 {bad key \"\\\": must start with a valid root}"
539test registry-9.2 {ParseKeyName: bad keys} {win reg} {
540    list [catch {registry values \\foobar} msg] $msg
541} {1 {bad key "\foobar": must start with a valid root}}
542test registry-9.3 {ParseKeyName: bad keys} {win reg} {
543    list [catch {registry values \\\\} msg] $msg
544} {1 {bad root name "": must be HKEY_LOCAL_MACHINE, HKEY_USERS, HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_CURRENT_CONFIG, HKEY_PERFORMANCE_DATA, or HKEY_DYN_DATA}}
545test registry-9.4 {ParseKeyName: bad keys} {win reg} {
546    list [catch {registry values \\\\\\} msg] $msg
547} {1 {bad root name "": must be HKEY_LOCAL_MACHINE, HKEY_USERS, HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_CURRENT_CONFIG, HKEY_PERFORMANCE_DATA, or HKEY_DYN_DATA}}
548test registry-9.5 {ParseKeyName: bad keys} {win reg english nt} {
549    list [catch {registry values \\\\\\HKEY_CLASSES_ROOT} msg] $msg
550} {1 {unable to open key: The network address is invalid.}}
551test registry-9.6 {ParseKeyName: bad keys} {win reg} {
552    list [catch {registry values \\\\gaspode} msg] $msg
553} {1 {bad root name "": must be HKEY_LOCAL_MACHINE, HKEY_USERS, HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_CURRENT_CONFIG, HKEY_PERFORMANCE_DATA, or HKEY_DYN_DATA}}
554test registry-9.7 {ParseKeyName: bad keys} {win reg} {
555    list [catch {registry values foobar} msg] $msg
556} {1 {bad root name "foobar": must be HKEY_LOCAL_MACHINE, HKEY_USERS, HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_CURRENT_CONFIG, HKEY_PERFORMANCE_DATA, or HKEY_DYN_DATA}}
557test registry-9.8 {ParseKeyName: null keys} {win reg} {
558    list [catch {registry delete HKEY_CLASSES_ROOT\\} msg] $msg
559} {1 {bad key: cannot delete root keys}}
560test registry-9.9 {ParseKeyName: null keys} {win reg english} {
561    list [catch {registry keys HKEY_CLASSES_ROOT\\TclFoobar\\baz} msg] $msg
562} {1 {unable to open key: The system cannot find the file specified.}}
563
564test registry-10.1 {RecursiveDeleteKey} {win reg} {
565    registry delete HKEY_CLASSES_ROOT\\TclFoobar
566    registry set HKEY_CLASSES_ROOT\\TclFoobar\\test1
567    registry set HKEY_CLASSES_ROOT\\TclFoobar\\test2\\test3
568    registry delete HKEY_CLASSES_ROOT\\TclFoobar
569    set result [registry keys HKEY_CLASSES_ROOT TclFoobar]
570    set result
571} {}
572test registry-10.2 {RecursiveDeleteKey} {win reg} {
573    registry delete HKEY_CLASSES_ROOT\\TclFoobar
574    registry set HKEY_CLASSES_ROOT\\TclFoobar\\test1
575    registry set HKEY_CLASSES_ROOT\\TclFoobar\\test2\\test3
576    set result [registry delete HKEY_CLASSES_ROOT\\TclFoobar\\test2\\test4]
577    registry delete HKEY_CLASSES_ROOT\\TclFoobar
578    set result
579} {}
580
581test registry-11.1 {SetValue: recursive creation} {win reg} {
582    registry delete HKEY_CLASSES_ROOT\\TclFoobar
583    registry set HKEY_CLASSES_ROOT\\TclFoobar\\baz blat foobar
584    set result [registry get HKEY_CLASSES_ROOT\\TclFoobar\\baz blat]
585} foobar
586test registry-11.2 {SetValue: modification} {win reg} {
587    registry delete HKEY_CLASSES_ROOT\\TclFoobar
588    registry set HKEY_CLASSES_ROOT\\TclFoobar\\baz blat foobar
589    registry set HKEY_CLASSES_ROOT\\TclFoobar\\baz blat frob
590    set result [registry get HKEY_CLASSES_ROOT\\TclFoobar\\baz blat]
591} frob
592test registry-11.3 {SetValue: failure} {win reg nonPortable english} {
593    # This test will only succeed if the current user does not have registry
594    # access on the specified machine.
595    list [catch {registry set {\\mom\HKEY_CLASSES_ROOT\TclFoobar} bar foobar} msg] $msg
596} {1 {unable to open key: Access is denied.}}
597
598test registry-12.1 {BroadcastValue} {win reg} {
599    list [catch {registry broadcast} msg] $msg
600} {1 {wrong # args: should be "registry broadcast keyName ?-timeout millisecs?"}}
601test registry-12.2 {BroadcastValue} {win reg} {
602    list [catch {registry broadcast "" -time} msg] $msg
603} {1 {wrong # args: should be "registry broadcast keyName ?-timeout millisecs?"}}
604test registry-12.3 {BroadcastValue} {win reg} {
605    list [catch {registry broadcast "" - 500} msg] $msg
606} {1 {wrong # args: should be "registry broadcast keyName ?-timeout millisecs?"}}
607test registry-12.4 {BroadcastValue} {win reg} {
608    list [catch {registry broadcast {Environment}} msg] $msg
609} {0 {1 0}}
610test registry-12.5 {BroadcastValue} {win reg} {
611    list [catch {registry b {}} msg] $msg
612} {0 {1 0}}
613
614# cleanup
615::tcltest::cleanupTests
616return
617
618# Local Variables:
619# mode: tcl
620# tcl-indent-level: 4
621# fill-column: 78
622# End:
Note: See TracBrowser for help on using the repository browser.