~ubuntu-branches/ubuntu/maverick/swig1.3/maverick

« back to all changes in this revision

Viewing changes to Examples/test-suite/ruby/unions_runme.rb

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Landschoff
  • Date: 2002-03-29 01:56:07 UTC
  • Revision ID: james.westby@ubuntu.com-20020329015607-c0wt03xu8oy9ioj7
Tags: upstream-1.3.11
ImportĀ upstreamĀ versionĀ 1.3.11

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
5
require 'unions'
 
6
 
 
7
# Create new instances of SmallStruct and BigStruct for later use
 
8
small = Unions::SmallStruct.new()
 
9
small.jill = 200
 
10
 
 
11
big = Unions::BigStruct.new()
 
12
big.smallstruct = small
 
13
big.jack = 300
 
14
 
 
15
# Use SmallStruct then BigStruct to setup EmbeddedUnionTest.
 
16
# Ensure values in EmbeddedUnionTest are set correctly for each.
 
17
eut = Unions::EmbeddedUnionTest.new()
 
18
 
 
19
# First check the SmallStruct in EmbeddedUnionTest
 
20
eut.number = 1
 
21
eut.uni.small = small
 
22
Jill1 = eut.uni.small.jill
 
23
if (Jill1 != 200)
 
24
    print "Runtime test1 failed. eut.uni.small.jill=" , Jill1 , "\n"
 
25
    exit 1
 
26
end
 
27
 
 
28
Num1 = eut.number
 
29
if (Num1 != 1)
 
30
    print "Runtime test2 failed. eut.number=" , Num1 , "\n"
 
31
    exit 1
 
32
end
 
33
 
 
34
# Secondly check the BigStruct in EmbeddedUnionTest
 
35
eut.number = 2
 
36
eut.uni.big = big
 
37
Jack1 = eut.uni.big.jack
 
38
if (Jack1 != 300)
 
39
    print "Runtime test3 failed. eut.uni.big.jack=" , Jack1 , "\n"
 
40
    exit 1
 
41
end
 
42
 
 
43
Jill2 = eut.uni.big.smallstruct.jill
 
44
if (Jill2 != 200)
 
45
    print "Runtime test4 failed. eut.uni.big.smallstruct.jill=" , Jill2 , "\n"
 
46
    exit 1
 
47
end
 
48
 
 
49
Num2 = eut.number
 
50
if (Num2 != 2)
 
51
    print "Runtime test5 failed. eut.number=" , Num2 , "\n"
 
52
    exit 1
 
53
end
 
54