-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathtestChannelPutGet.py
More file actions
287 lines (236 loc) · 8.49 KB
/
testChannelPutGet.py
File metadata and controls
287 lines (236 loc) · 8.49 KB
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
#!/usr/bin/env python
from pvaccess import Channel
from pvaccess import PvBoolean
from pvaccess import PvByte
from pvaccess import PvUByte
from pvaccess import PvShort
from pvaccess import PvUShort
from pvaccess import PvInt
from pvaccess import PvUInt
from pvaccess import PvLong
from pvaccess import PvULong
from pvaccess import PvFloat
from pvaccess import PvDouble
from pvaccess import PvString
from testUtility import TestUtility
class TestChannelPutGet:
#
# Boolean PutGet
#
def testPutGet_PvBoolean(self):
value = TestUtility.getRandomBoolean()
c = TestUtility.getBooleanChannel()
value2 = c.putGet(PvBoolean(value)).getPyObject()
assert(value == value2)
# put() must be done using strings 'true'/'false'
def testPutGet_Boolean(self):
value = TestUtility.getRandomBooleanString()
c = TestUtility.getBooleanChannel()
value2 = c.putGet(value).getPyObject()
TestUtility.assertBooleanEquality(value,value2)
def testPutGetBoolean_Boolean(self):
value = TestUtility.getRandomBoolean()
c = TestUtility.getBooleanChannel()
value2 = c.putGetBoolean(value).getPyObject()
assert(value == value2)
#
# Byte PutGet
#
# python chars are unsigned
def testPutGet_PvByte(self):
value = chr(TestUtility.getRandomUByte())
c = TestUtility.getByteChannel()
value2 = c.putGet(PvByte(value)).getPyObject()
assert(value == value2)
# put(byte) must be done using integers
# we need to compare result in python chars, which are unsigned
def testPutGet_Byte(self):
value = TestUtility.getRandomByte()
c = TestUtility.getByteChannel()
value2 = c.putGet(value).getPyObject()
TestUtility.assertCharEquality(value,value2)
def testPutGetByte_Byte(self):
value = chr(TestUtility.getRandomUByte())
c = TestUtility.getByteChannel()
value2 = c.putGetByte(value).getPyObject()
assert(value == value2)
#
# UByte PutGet
#
def testPutGet_PvUByte(self):
value = TestUtility.getRandomUByte()
c = TestUtility.getUByteChannel()
value2 = c.putGet(PvUByte(value)).getPyObject()
assert(value == value2)
def testPutGet_UByte(self):
value = TestUtility.getRandomUByte()
c = TestUtility.getUByteChannel()
value2 = c.putGet(value).getPyObject()
assert(value == value2)
def testPutGetUByte_UByte(self):
value = TestUtility.getRandomUByte()
c = TestUtility.getUByteChannel()
value2 = c.putGetUByte(value).getPyObject()
assert(value == value2)
#
# Short PutGet
#
def testPutGet_PvShort(self):
value = TestUtility.getRandomShort()
c = TestUtility.getShortChannel()
value2 = c.putGet(PvShort(value)).getPyObject()
assert(value == value2)
def testPutGet_Short(self):
value = TestUtility.getRandomShort()
c = TestUtility.getShortChannel()
value2 = c.putGet(value).getPyObject()
assert(value == value2)
def testPutGetShort_Short(self):
value = TestUtility.getRandomShort()
c = TestUtility.getShortChannel()
value2 = c.putGetShort(value).getPyObject()
assert(value == value2)
#
# UShort PutGet
#
def testPutGet_PvUShort(self):
value = TestUtility.getRandomUShort()
c = TestUtility.getUShortChannel()
value2 = c.putGet(PvUShort(value)).getPyObject()
assert(value == value2)
def testPutGet_UShort(self):
value = TestUtility.getRandomUShort()
c = TestUtility.getUShortChannel()
value2 = c.putGet(value).getPyObject()
assert(value == value2)
def testPutGetUShort_UShort(self):
value = TestUtility.getRandomUShort()
c = TestUtility.getUShortChannel()
value2 = c.putGetUShort(value).getPyObject()
assert(value == value2)
#
# Int PutGet
#
def testPutGet_PvInt(self):
value = TestUtility.getRandomInt()
c = TestUtility.getIntChannel()
value2 = c.putGet(PvInt(value)).getPyObject()
assert(value == value2)
def testPutGet_Int(self):
value = TestUtility.getRandomInt()
c = TestUtility.getIntChannel()
value2 = c.putGet(value).getPyObject()
assert(value == value2)
def testPutGetInt_Int(self):
value = TestUtility.getRandomInt()
c = TestUtility.getIntChannel()
value2 = c.putGetInt(value).getPyObject()
assert(value == value2)
#
# UInt PutGet
#
def testPutGet_PvUInt(self):
value = TestUtility.getRandomUInt()
c = TestUtility.getUIntChannel()
value2 = c.putGet(PvUInt(value)).getPyObject()
assert(value == value2)
def testPutGet_UInt(self):
value = TestUtility.getRandomUInt()
c = TestUtility.getUIntChannel()
value2 = c.putGet(value).getPyObject()
assert(value == value2)
def testPutGetUInt_UInt(self):
value = TestUtility.getRandomUInt()
c = TestUtility.getUIntChannel()
value2 = c.putGetUInt(value).getPyObject()
assert(value == value2)
#
# Long PutGet
#
def testPutGet_PvLong(self):
value = TestUtility.getRandomLong()
c = TestUtility.getLongChannel()
value2 = c.putGet(PvLong(value)).getPyObject()
assert(value == value2)
def testPutGet_Long(self):
value = TestUtility.getRandomLong()
c = TestUtility.getLongChannel()
value2 = c.putGet(value).getPyObject()
assert(value == value2)
def testPutGetLong_Long(self):
value = TestUtility.getRandomLong()
c = TestUtility.getLongChannel()
value2 = c.putGetLong(value).getPyObject()
assert(value == value2)
#
# ULong PutGet
#
def testPutGet_PvULong(self):
value = TestUtility.getRandomULong()
c = TestUtility.getULongChannel()
value2 = c.putGet(PvULong(value)).getPyObject()
assert(value == value2)
def testPutGet_ULong(self):
value = TestUtility.getRandomPositiveLong()
c = TestUtility.getULongChannel()
value2 = c.putGet(value).getPyObject()
assert(value == value2)
def testPutGetULong_ULong(self):
value = TestUtility.getRandomPositiveLong()
c = TestUtility.getULongChannel()
value2 = c.putGetULong(value).getPyObject()
assert(value == value2)
#
# Float PutGet
#
def testPutGet_PvFloat(self):
value = TestUtility.getRandomFloat()
c = TestUtility.getFloatChannel()
value2 = c.putGet(PvFloat(value)).getPyObject()
TestUtility.assertFloatEquality(value, value2)
def testPutGet_Float(self):
value = TestUtility.getRandomFloat()
c = TestUtility.getFloatChannel()
value2 = c.putGet(value).getPyObject()
TestUtility.assertFloatEquality(value, value2)
def testPutGetFloat_Float(self):
value = TestUtility.getRandomFloat()
c = TestUtility.getFloatChannel()
value2 = c.putGetFloat(value).getPyObject()
TestUtility.assertFloatEquality(value, value2)
#
# Double PutGet
#
def testPutGet_PvDouble(self):
value = TestUtility.getRandomDouble()
c = TestUtility.getDoubleChannel()
value2 = c.putGet(PvDouble(value)).getPyObject()
TestUtility.assertDoubleEquality(value, value2)
def testPutGet_Double(self):
value = TestUtility.getRandomDouble()
c = TestUtility.getDoubleChannel()
value2 = c.putGet(value).getPyObject()
TestUtility.assertDoubleEquality(value, value2)
def testPutGetDouble_Double(self):
value = TestUtility.getRandomDouble()
c = TestUtility.getDoubleChannel()
value2 = c.putGetDouble(value).getPyObject()
TestUtility.assertDoubleEquality(value, value2)
#
# String PutGet
#
def testPutGet_PvString(self):
value = TestUtility.getRandomString()
c = TestUtility.getStringChannel()
value2 = c.putGet(PvString(value)).getPyObject()
assert(value == value2)
def testPutGet_String(self):
value = TestUtility.getRandomString()
c = TestUtility.getStringChannel()
value2 = c.putGet(value).getPyObject()
assert(value == value2)
def testPutGetString_String(self):
value = TestUtility.getRandomString()
c = TestUtility.getStringChannel()
value2 = c.putGetString(value).getPyObject()
assert(value == value2)