import source from 1.3.40
[external/swig.git] / Examples / test-suite / octave / template_default_arg_runme.m
1 template_default_arg
2
3
4 helloInt = template_default_arg.Hello_int();
5 helloInt.foo(template_default_arg.Hello_int_hi);
6
7
8 x = template_default_arg.X_int();
9 if (x.meth(20.0, 200) != 200)
10   error("X_int test 1 failed")
11 endif
12 if (x.meth(20) != 20)
13   error("X_int test 2 failed")
14 endif
15 if (x.meth() != 0)
16   error("X_int test 3 failed")
17 endif
18
19
20
21 y = template_default_arg.Y_unsigned();
22 if (y.meth(20.0, 200) != 200)
23   error("Y_unsigned test 1 failed")
24 endif
25 if (y.meth(20) != 20)
26   error("Y_unsigned test 2 failed")
27 endif
28 if (y.meth() != 0)
29   error("Y_unsigned test 3 failed")
30 endif
31
32
33
34 x = template_default_arg.X_longlong();
35 x = template_default_arg.X_longlong(20.0);
36 x = template_default_arg.X_longlong(20.0, 200);
37
38
39 x = template_default_arg.X_int();
40 x = template_default_arg.X_int(20.0);
41 x = template_default_arg.X_int(20.0, 200);
42
43
44 x = template_default_arg.X_hello_unsigned();
45 x = template_default_arg.X_hello_unsigned(20.0);
46 x = template_default_arg.X_hello_unsigned(20.0, template_default_arg.Hello_int());
47
48
49 y = template_default_arg.Y_hello_unsigned();
50 y.meth(20.0, template_default_arg.Hello_int());
51 y.meth(template_default_arg.Hello_int());
52 y.meth();
53
54
55
56 fz = template_default_arg.Foo_Z_8();
57 x = template_default_arg.X_Foo_Z_8();
58 fzc = x.meth(fz);
59
60
61 # Templated functions
62
63 # plain function: int ott(Foo<int>)
64 if (template_default_arg.ott(template_default_arg.Foo_int()) != 30)
65   error("ott test 1 failed")
66 endif
67
68 # %template(ott) ott<int, int>
69 if (template_default_arg.ott() != 10)
70   error("ott test 2 failed")
71 endif
72 if (template_default_arg.ott(1) != 10)
73   error("ott test 3 failed")
74 endif
75 if (template_default_arg.ott(1, 1) != 10)
76   error("ott test 4 failed")
77 endif
78
79 if (template_default_arg.ott("hi") != 20)
80   error("ott test 5 failed")
81 endif
82 if (template_default_arg.ott("hi", 1) != 20)
83   error("ott test 6 failed")
84 endif
85 if (template_default_arg.ott("hi", 1, 1) != 20)
86   error("ott test 7 failed")
87 endif
88
89 # %template(ott) ott<const char *>
90 if (template_default_arg.ottstring(template_default_arg.Hello_int(), "hi") != 40)
91   error("ott test 8 failed")
92 endif
93
94 if (template_default_arg.ottstring(template_default_arg.Hello_int()) != 40)
95   error("ott test 9 failed")
96 endif
97
98 # %template(ott) ott<int>
99 if (template_default_arg.ottint(template_default_arg.Hello_int(), 1) != 50)
100   error("ott test 10 failed")
101 endif
102
103 if (template_default_arg.ottint(template_default_arg.Hello_int()) != 50)
104   error("ott test 11 failed")
105 endif
106
107 # %template(ott) ott<double>
108 if (template_default_arg.ott(template_default_arg.Hello_int(), 1.0) != 60)
109   error("ott test 12 failed")
110 endif
111
112 if (template_default_arg.ott(template_default_arg.Hello_int()) != 60)
113   error("ott test 13 failed")
114 endif
115
116
117