/tags/rel-1.3.35/Examples/test-suite/tcl/unions_runme.tcl
TCL | 63 lines | 38 code | 13 blank | 12 comment | 11 complexity | a6246207bfc8dda6bb08a73b25f6fbb5 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
1
2# This is the union runtime testcase. It ensures that values within a
3# union embedded within a struct can be set and read correctly.
4
5if [ catch { load ./unions[info sharedlibextension] unions} err_msg ] {
6 puts stderr "Could not load shared object:\n$err_msg"
7}
8
9# Create new instances of SmallStruct and BigStruct for later use
10SmallStruct small
11small configure -jill 200
12
13BigStruct big
14big configure -smallstruct [small cget -this]
15big configure -jack 300
16
17# Use SmallStruct then BigStruct to setup EmbeddedUnionTest.
18# Ensure values in EmbeddedUnionTest are set correctly for each.
19EmbeddedUnionTest eut
20
21# First check the SmallStruct in EmbeddedUnionTest
22eut configure -number 1
23
24#eut.uni.small = small
25EmbeddedUnionTest_uni_small_set [EmbeddedUnionTest_uni_get [eut cget -this] ] [small cget -this]
26
27#Jill1 = eut.uni.small.jill
28set Jill1 [SmallStruct_jill_get [EmbeddedUnionTest_uni_small_get [EmbeddedUnionTest_uni_get [eut cget -this] ] ] ]
29if {$Jill1 != 200} {
30 puts stderr "Runtime test1 failed. eut.uni.small.jill=$Jill1"
31 exit 1
32}
33
34set Num1 [eut cget -number]
35if {$Num1 != 1} {
36 puts stderr "Runtime test2 failed. eut.number=$Num1"
37 exit 1
38}
39
40# Secondly check the BigStruct in EmbeddedUnionTest
41eut configure -number 2
42#eut.uni.big = big
43EmbeddedUnionTest_uni_big_set [EmbeddedUnionTest_uni_get [eut cget -this] ] [big cget -this]
44#Jack1 = eut.uni.big.jack
45set Jack1 [BigStruct_jack_get [EmbeddedUnionTest_uni_big_get [EmbeddedUnionTest_uni_get [eut cget -this] ] ] ]
46if {$Jack1 != 300} {
47 puts stderr "Runtime test3 failed. eut.uni.big.jack=$Jack1"
48 exit 1
49}
50
51#Jill2 = eut.uni.big.smallstruct.jill
52set Jill2 [SmallStruct_jill_get [BigStruct_smallstruct_get [EmbeddedUnionTest_uni_big_get [EmbeddedUnionTest_uni_get [eut cget -this] ] ] ] ]
53if {$Jill2 != 200} {
54 puts stderr "Runtime test4 failed. eut.uni.big.smallstruct.jill=$Jill2"
55 exit 1
56}
57
58set Num2 [eut cget -number]
59if {$Num2 != 2} {
60 puts stderr "Runtime test5 failed. eut.number=$Num2"
61 exit 1
62}
63