def test_documented_examples(): # PIPG-41 assert float_type.decode(0xfd007d00) == 32 assert float_type.decode(0xff000140) == 32 assert float_type.decode(0x01000140) == 3200 assert float_type.decode(0x02000020) == 3200
def m2i(self, pkt, x): return float_type.decode(x)
def test_too_big(): with pytest.raises(ValueError): float_type.decode(0xffffffffffffffffffff)
def test_encode_decode_identity(num): assert float_type.decode(float_type.encode(num)) == num
def test_negative(): assert float_type.decode(0x00ffffff) == -1
def test_basic(): assert float_type.decode(1) == 1
def test_negative_infinity(): neginf = float_type.decode(0x00800002) assert neginf < 0 assert math.isinf(neginf)
def test_positive_infinity(): posinf = float_type.decode(0x007ffffe) assert posinf > 0 assert math.isinf(posinf)
def test_inferred_special_values(): assert math.isnan(float_type.decode(0x007fffff)) assert math.isnan( float_type.decode(0x00800000)) # "Not at this resolution"