PageRenderTime 58ms CodeModel.GetById 33ms app.highlight 21ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/test-suite/ruby/li_std_pair_runme.rb

#
Ruby | 57 lines | 24 code | 7 blank | 26 comment | 19 complexity | f231f41f6668c2e124597b36d218a0c1 MD5 | raw file
 1#!/usr/bin/env ruby
 2#
 3# Put description here
 4#
 5# 
 6# 
 7# 
 8#
 9
10require 'swig_assert'
11
12require 'li_std_pair'
13include Li_std_pair
14
15swig_assert_each_line(<<'EOF', binding)
16#
17# Because of template specializations for pair<int, int>, these should return
18# an Array of size 2, where both elements are Fixnums.
19#
20intPair = makeIntPair(7, 6)
21intPair.instance_of?(Array)
22intPair.size == 2
23intPair[0] == 7 && intPair[1] == 6
24
25intPairConstRef = makeIntPairConstRef(7, 6)
26intPairConstRef.instance_of?(Array)
27intPairConstRef[0] == 7 && intPairConstRef[1] == 6
28
29#
30# Each of these should return a reference to a wrapped
31# std::pair<int, int> object (i.e. an IntPair instance).
32#
33intPairPtr = makeIntPairPtr(7, 6)
34intPairPtr.instance_of?(IntPair)
35intPairPtr[0] == 7 && intPairPtr[1] == 6
36
37intPairRef = makeIntPairRef(7, 6)
38intPairRef.instance_of?(IntPair)
39intPairRef[0] == 7 && intPairRef[1] == 6
40#
41# Now test various input typemaps. Each of the wrapped C++ functions
42# (product1, product2 and product3) is expecting an argument of a
43# different type (see li_std_pair.i). Typemaps should be in place to
44# convert this Array into the expected argument type.
45#
46product1(intPair) == 42
47product2(intPair) == 42
48product3(intPair) == 42
49
50#
51# Similarly, each of the input typemaps should know what to do
52# with an IntPair instance.
53#
54product1(intPairPtr) == 42
55product2(intPairPtr) == 42
56product3(intPairPtr) == 42
57EOF