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