def test_union_i2c_smbus_data(self): u = union_i2c_smbus_data() # Fill array with values 1, 2, ... for k in range(I2C_SMBUS_BLOCK_MAX + 2): u.block[k] = k + 1 # Check that the union works self.assertEqual(u.byte, u.block[0], msg="Byte field differ") self.assertEqual(u.block[16], 17, msg="Array field does not match") # Set byte and se it reflected in the array u.byte = 255 self.assertEqual(u.block[0], 255, msg="Byte field not reflected in array") # Reset array to zeros and check word field for k in range(I2C_SMBUS_BLOCK_MAX + 2): u.block[k] = 0 u.word = 1607 self.assertNotEqual(0, u.word, msg="Word field is zero but should be non-zero") u.word = 0
def test_union_i2c_smbus_data(self): u = union_i2c_smbus_data() # Fill array with values 1, 2, ... for k in range(I2C_SMBUS_BLOCK_MAX+2): u.block[k] = k+1 # Check that the union works self.assertEqual(u.byte, u.block[0], msg="Byte field differ") self.assertEqual(u.block[16], 17, msg="Array field does not match") # Set byte and se it reflected in the array u.byte = 255 self.assertEqual(u.block[0], 255, msg="Byte field not reflected in array") # Reset array to zeros and check word field for k in range(I2C_SMBUS_BLOCK_MAX+2): u.block[k] = 0 u.word = 1607 self.assertNotEqual(0, u.word, msg="Word field is zero but should be non-zero") u.word = 0