blob: 74e5373da9458261c5119883c951a532ba702132 (
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
# **********************************************************************
#
# Copyright (c) 2003-2010 ZeroC, Inc. All rights reserved.
#
# This copy of Ice is licensed to you under the terms described in the
# ICE_LICENSE file included in this distribution.
#
# **********************************************************************
import Ice, Test
def test(b):
if not b:
raise RuntimeError('test assertion failed')
def allTests():
print "testing default values...",
v = Test.Struct1()
test(not v.boolFalse)
test(v.boolTrue)
test(v.b == 254)
test(v.s == 16000)
test(v.i == 3)
test(v.l == 4)
test(v.f == 5.1)
test(v.d == 6.2)
test(v.str == "foo \\ \"bar\n \r\n\t\013\f\007\b? \007 \007")
test(v.c1 == Test.Color.red)
test(v.c2 == Test.Color.green)
test(v.c3 == Test.Color.blue)
test(v.nc1 == Test.Nested.Color.red)
test(v.nc2 == Test.Nested.Color.green)
test(v.nc3 == Test.Nested.Color.blue)
test(v.noDefault == '')
v = Test.Struct2()
test(v.boolTrue == Test.ConstBool)
test(v.b == Test.ConstByte)
test(v.s == Test.ConstShort)
test(v.i == Test.ConstInt)
test(v.l == Test.ConstLong)
test(v.f == Test.ConstFloat)
test(v.d == Test.ConstDouble)
test(v.str == Test.ConstString)
test(v.c1 == Test.ConstColor1)
test(v.c2 == Test.ConstColor2)
test(v.c3 == Test.ConstColor3)
test(v.nc1 == Test.ConstNestedColor1)
test(v.nc2 == Test.ConstNestedColor2)
test(v.nc3 == Test.ConstNestedColor3)
v = Test.Base()
test(not v.boolFalse)
test(v.boolTrue)
test(v.b == 1)
test(v.s == 2)
test(v.i == 3)
test(v.l == 4)
test(v.f == 5.1)
test(v.d == 6.2)
test(v.str == "foo \\ \"bar\n \r\n\t\013\f\007\b? \007 \007")
test(v.noDefault == '')
v = Test.Derived()
test(not v.boolFalse)
test(v.boolTrue)
test(v.b == 1)
test(v.s == 2)
test(v.i == 3)
test(v.l == 4)
test(v.f == 5.1)
test(v.d == 6.2)
test(v.str == "foo \\ \"bar\n \r\n\t\013\f\007\b? \007 \007")
test(v.c1 == Test.Color.red)
test(v.c2 == Test.Color.green)
test(v.c3 == Test.Color.blue)
test(v.nc1 == Test.Nested.Color.red)
test(v.nc2 == Test.Nested.Color.green)
test(v.nc3 == Test.Nested.Color.blue)
test(v.noDefault == '')
v = Test.BaseEx()
test(not v.boolFalse)
test(v.boolTrue)
test(v.b == 1)
test(v.s == 2)
test(v.i == 3)
test(v.l == 4)
test(v.f == 5.1)
test(v.d == 6.2)
test(v.str == "foo \\ \"bar\n \r\n\t\013\f\007\b? \007 \007")
test(v.noDefault == '')
v = Test.DerivedEx()
test(not v.boolFalse)
test(v.boolTrue)
test(v.b == 1)
test(v.s == 2)
test(v.i == 3)
test(v.l == 4)
test(v.f == 5.1)
test(v.d == 6.2)
test(v.str == "foo \\ \"bar\n \r\n\t\013\f\007\b? \007 \007")
test(v.noDefault == '')
test(v.c1 == Test.Color.red)
test(v.c2 == Test.Color.green)
test(v.c3 == Test.Color.blue)
test(v.nc1 == Test.Nested.Color.red)
test(v.nc2 == Test.Nested.Color.green)
test(v.nc3 == Test.Nested.Color.blue)
print "ok"
|