summaryrefslogtreecommitdiff
path: root/Examples/test-suite/ruby/apply_strings_runme.rb
blob: 299b96bb669568e4269d245dc4a32aae6f3d8dbc (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
#!/usr/bin/env ruby
#
# Put script description here.
#
# 
# 
# 
#

require 'swig_assert'
require 'apply_strings'

include Apply_strings

begin
  x = UcharPtr.new
  swig_assert( fail, "UcharPtr should not be defined")
rescue NameError
end

ptr = 'a'
['UCharFunction', 'SCharFunction', 'CUCharFunction',
 'CSCharFunction'].each do |m|
  val = Apply_strings.send(m, ptr)
  swig_assert( "val == ptr", binding )
end


['CharFunction', 'CCharFunction'].each do |m|
  begin
    val = Apply_strings.send(m, ptr)
    swig_assert( false, nil, "Apply_strings.#{m} should raise TypeError" )
  rescue TypeError
  end
end

ptr = 'a'
foo = DirectorTest.new
['UCharFunction', 'SCharFunction', 'CUCharFunction',
 'CSCharFunction'].each do |m|
  val = foo.send(m, ptr)
  swig_assert( "val == ptr", binding, "DirectorTest.#{m}" )
end


['CharFunction', 'CCharFunction'].each do |m|
  begin
    val = foo.send(m, ptr)
    swig_assert( false, nil, "DirectorTest.#{m} should raise TypeError" )
  rescue TypeError
  end
end


# ary = Apply_strings.DigitsGlobalB
# { 0 => 'A',
#   1 => 'B',
#   2 => 'B' }.each do |k,v|
#   val = ary[k]
#   swig_assert( val == v, "Apply_strings.DigitsGlobalB[#{k}] #{val} != #{v}")
# end