예제 #1
0
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
예제 #2
0
 def m2i(self, pkt, x):
     return float_type.decode(x)
예제 #3
0
def test_too_big():
    with pytest.raises(ValueError):
        float_type.decode(0xffffffffffffffffffff)
예제 #4
0
def test_encode_decode_identity(num):
    assert float_type.decode(float_type.encode(num)) == num
예제 #5
0
def test_negative():
    assert float_type.decode(0x00ffffff) == -1
예제 #6
0
def test_basic():
    assert float_type.decode(1) == 1
예제 #7
0
def test_negative_infinity():
    neginf = float_type.decode(0x00800002)
    assert neginf < 0
    assert math.isinf(neginf)
예제 #8
0
def test_positive_infinity():
    posinf = float_type.decode(0x007ffffe)
    assert posinf > 0
    assert math.isinf(posinf)
예제 #9
0
def test_inferred_special_values():
    assert math.isnan(float_type.decode(0x007fffff))
    assert math.isnan(
        float_type.decode(0x00800000))  # "Not at this resolution"