PageRenderTime 45ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/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. # This is the union runtime testcase. It ensures that values within a
  2. # union embedded within a struct can be set and read correctly.
  3. if [ catch { load ./unions[info sharedlibextension] unions} err_msg ] {
  4. puts stderr "Could not load shared object:\n$err_msg"
  5. }
  6. # Create new instances of SmallStruct and BigStruct for later use
  7. SmallStruct small
  8. small configure -jill 200
  9. BigStruct big
  10. big configure -smallstruct [small cget -this]
  11. big configure -jack 300
  12. # Use SmallStruct then BigStruct to setup EmbeddedUnionTest.
  13. # Ensure values in EmbeddedUnionTest are set correctly for each.
  14. EmbeddedUnionTest eut
  15. # First check the SmallStruct in EmbeddedUnionTest
  16. eut configure -number 1
  17. #eut.uni.small = small
  18. EmbeddedUnionTest_uni_small_set [EmbeddedUnionTest_uni_get [eut cget -this] ] [small cget -this]
  19. #Jill1 = eut.uni.small.jill
  20. set Jill1 [SmallStruct_jill_get [EmbeddedUnionTest_uni_small_get [EmbeddedUnionTest_uni_get [eut cget -this] ] ] ]
  21. if {$Jill1 != 200} {
  22. puts stderr "Runtime test1 failed. eut.uni.small.jill=$Jill1"
  23. exit 1
  24. }
  25. set Num1 [eut cget -number]
  26. if {$Num1 != 1} {
  27. puts stderr "Runtime test2 failed. eut.number=$Num1"
  28. exit 1
  29. }
  30. # Secondly check the BigStruct in EmbeddedUnionTest
  31. eut configure -number 2
  32. #eut.uni.big = big
  33. EmbeddedUnionTest_uni_big_set [EmbeddedUnionTest_uni_get [eut cget -this] ] [big cget -this]
  34. #Jack1 = eut.uni.big.jack
  35. set Jack1 [BigStruct_jack_get [EmbeddedUnionTest_uni_big_get [EmbeddedUnionTest_uni_get [eut cget -this] ] ] ]
  36. if {$Jack1 != 300} {
  37. puts stderr "Runtime test3 failed. eut.uni.big.jack=$Jack1"
  38. exit 1
  39. }
  40. #Jill2 = eut.uni.big.smallstruct.jill
  41. set Jill2 [SmallStruct_jill_get [BigStruct_smallstruct_get [EmbeddedUnionTest_uni_big_get [EmbeddedUnionTest_uni_get [eut cget -this] ] ] ] ]
  42. if {$Jill2 != 200} {
  43. puts stderr "Runtime test4 failed. eut.uni.big.smallstruct.jill=$Jill2"
  44. exit 1
  45. }
  46. set Num2 [eut cget -number]
  47. if {$Num2 != 2} {
  48. puts stderr "Runtime test5 failed. eut.number=$Num2"
  49. exit 1
  50. }