Ejemplo n.º 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
Ejemplo n.º 2
0
 def m2i(self, pkt, x):
     return float_type.decode(x)
Ejemplo n.º 3
0
def test_too_big():
    with pytest.raises(ValueError):
        float_type.decode(0xffffffffffffffffffff)
Ejemplo n.º 4
0
def test_encode_decode_identity(num):
    assert float_type.decode(float_type.encode(num)) == num
Ejemplo n.º 5
0
def test_negative():
    assert float_type.decode(0x00ffffff) == -1
Ejemplo n.º 6
0
def test_basic():
    assert float_type.decode(1) == 1
Ejemplo n.º 7
0
def test_negative_infinity():
    neginf = float_type.decode(0x00800002)
    assert neginf < 0
    assert math.isinf(neginf)
Ejemplo n.º 8
0
def test_positive_infinity():
    posinf = float_type.decode(0x007ffffe)
    assert posinf > 0
    assert math.isinf(posinf)
Ejemplo n.º 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"