PageRenderTime 16ms CodeModel.GetById 1ms app.highlight 11ms RepoModel.GetById 2ms app.codeStats 0ms

/trunk/Examples/test-suite/python/template_default_arg_runme.py

#
Python | 98 lines | 59 code | 33 blank | 6 comment | 19 complexity | 10cb937518bd8f2a68f3dd40838908bf MD5 | raw file
 1import template_default_arg
 2
 3
 4helloInt = template_default_arg.Hello_int()
 5helloInt.foo(template_default_arg.Hello_int.hi)
 6
 7
 8x = template_default_arg.X_int()
 9if (x.meth(20.0, 200) != 200):
10  raise RuntimeError, ("X_int test 1 failed")
11if (x.meth(20) != 20):
12  raise RuntimeError, ("X_int test 2 failed")
13if (x.meth() != 0):
14  raise RuntimeError, ("X_int test 3 failed")
15
16
17
18y = template_default_arg.Y_unsigned()
19if (y.meth(20.0, 200) != 200):
20  raise RuntimeError, ("Y_unsigned test 1 failed")
21if (y.meth(20) != 20):
22  raise RuntimeError, ("Y_unsigned test 2 failed")
23if (y.meth() != 0):
24  raise RuntimeError, ("Y_unsigned test 3 failed")
25
26
27
28x = template_default_arg.X_longlong()
29x = template_default_arg.X_longlong(20.0)
30x = template_default_arg.X_longlong(20.0, 200L)
31
32
33x = template_default_arg.X_int()
34x = template_default_arg.X_int(20.0)
35x = template_default_arg.X_int(20.0, 200)
36
37
38x = template_default_arg.X_hello_unsigned()
39x = template_default_arg.X_hello_unsigned(20.0)
40x = template_default_arg.X_hello_unsigned(20.0, template_default_arg.Hello_int())
41
42
43y = template_default_arg.Y_hello_unsigned()
44y.meth(20.0, template_default_arg.Hello_int())
45y.meth(template_default_arg.Hello_int())
46y.meth()
47
48
49
50fz = template_default_arg.Foo_Z_8()
51x = template_default_arg.X_Foo_Z_8()
52fzc = x.meth(fz)
53
54
55# Templated functions
56
57# plain function: int ott(Foo<int>)
58if (template_default_arg.ott(template_default_arg.Foo_int()) != 30):
59  raise RuntimeError, ("ott test 1 failed")
60
61# %template(ott) ott<int, int>
62if (template_default_arg.ott() != 10):
63  raise RuntimeError, ("ott test 2 failed")
64if (template_default_arg.ott(1) != 10):
65  raise RuntimeError, ("ott test 3 failed")
66if (template_default_arg.ott(1, 1) != 10):
67  raise RuntimeError, ("ott test 4 failed")
68
69if (template_default_arg.ott("hi") != 20):
70  raise RuntimeError, ("ott test 5 failed")
71if (template_default_arg.ott("hi", 1) != 20):
72  raise RuntimeError, ("ott test 6 failed")
73if (template_default_arg.ott("hi", 1, 1) != 20):
74  raise RuntimeError, ("ott test 7 failed")
75
76# %template(ott) ott<const char *>
77if (template_default_arg.ottstring(template_default_arg.Hello_int(), "hi") != 40):
78  raise RuntimeError, ("ott test 8 failed")
79
80if (template_default_arg.ottstring(template_default_arg.Hello_int()) != 40):
81  raise RuntimeError, ("ott test 9 failed")
82
83# %template(ott) ott<int>
84if (template_default_arg.ottint(template_default_arg.Hello_int(), 1) != 50):
85  raise RuntimeError, ("ott test 10 failed")
86
87if (template_default_arg.ottint(template_default_arg.Hello_int()) != 50):
88  raise RuntimeError, ("ott test 11 failed")
89
90# %template(ott) ott<double>
91if (template_default_arg.ott(template_default_arg.Hello_int(), 1.0) != 60):
92  raise RuntimeError, ("ott test 12 failed")
93
94if (template_default_arg.ott(template_default_arg.Hello_int()) != 60):
95  raise RuntimeError, ("ott test 13 failed")
96
97
98