Пример #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"