@@ -183,14 +183,33 @@ def test_unknown_data_type(self):
183183
184184class TestAlternativeRepresentations (unittest .TestCase ):
185185
186- def test_phys (self ):
186+ def test_phys_integer (self ):
187187 var = od .ODVariable ("Test INTEGER16" , 0x1000 )
188188 var .data_type = od .INTEGER16
189189 var .factor = 0.1
190+ self .assertAlmostEqual (var .decode_phys (128 ), 12.8 )
191+ self .assertEqual (var .encode_phys (- 0.1 ), - 1 )
190192
193+ def test_phys_real (self ):
194+ var = od .ODVariable ("Test REAL32" , 0x1000 )
195+ var .data_type = od .REAL32
196+ var .factor = 0.1
191197 self .assertAlmostEqual (var .decode_phys (128 ), 12.8 )
192198 self .assertEqual (var .encode_phys (- 0.1 ), - 1 )
193199
200+ def test_phys_boolean (self ):
201+ var = od .ODVariable ("Test BOOLEAN" , 0x1000 )
202+ var .data_type = od .BOOLEAN
203+ self .assertEqual (var .decode_phys (True ), True )
204+ self .assertEqual (var .decode_phys (False ), False )
205+ self .assertEqual (var .encode_phys (True ), True )
206+
207+ def test_phys_string (self ):
208+ var = od .ODVariable ("Test VISIBLE_STRING" , 0x1000 )
209+ var .data_type = od .VISIBLE_STRING
210+ self .assertEqual (var .decode_phys ('foo' ), 'foo' )
211+ self .assertEqual (var .encode_phys ('bar' ), 'bar' )
212+
194213 def test_phys_factor_1_int64_roundtrip (self ):
195214 """int64 values must survive encode_phys when factor is 1."""
196215 var = od .ODVariable ("Test UNSIGNED64" , 0x1000 )
0 commit comments