Esempio n. 1
0
def test_new_tmp_val():
    """ Test new tmp val is different each time, and starts with the
    UNKNOWN_PREFIX
    """
    a, b = helpers.new_tmp_val(), helpers.new_tmp_val()
    assert a != b, "Values must be different"
    assert all(helpers.RE_UNK_PREFIX.match(x)
               for x in (a, b)), "Values do not conform the Reg.Exp."
Esempio n. 2
0
def test_H16_val():
    """ Test high value of an integer or unknown val is ok
    """
    # For an unknown 8 bit val, the high part is always 0
    assert helpers.is_unknown8(helpers.HI16_val(None))
    tmp8 = helpers.new_tmp_val()
    hi16 = helpers.HI16_val(tmp8)
    assert hi16 == '0'

    # For integers, it's just the high part
    assert helpers.HI16_val('255') == '0'
    assert helpers.HI16_val('256') == '1'

    # For normal unknowns16, the high part must be returned
    tmp16 = helpers.new_tmp_val16()
    assert helpers.HI16_val(tmp16) == tmp16.split(helpers.HL_SEP)[0]
    assert helpers.is_unknown8(helpers.HI16_val(tmp16))
    assert helpers.is_unknown8(
        helpers.HI16_val('_unknown'))  # An unknown expression
Esempio n. 3
0
def test_is_unknown16_half():
    a = '{}|3'.format(helpers.new_tmp_val())
    assert helpers.is_unknown16(a)
Esempio n. 4
0
def test_is_unknown16():
    assert helpers.is_unknown16(None)
    assert not helpers.is_unknown16(helpers.new_tmp_val())
    assert helpers.is_unknown16(helpers.new_tmp_val16())