Beispiel #1
0
def test_double_component_subtract_from_contents():
    H = Component("H")
    L = Component("L")
    HL = DoubleComponent("HL", L, H)

    H.set_contents(0)
    L.set_contents(1)

    carry_flag = HL.subtract_from_contents(1)
    assert HL.get_contents() == 0
    assert carry_flag == 0

    HL.set_contents_value(1000)
    carry_flag = HL.subtract_from_contents(1000)
    assert HL.get_contents() == 0
    assert carry_flag == 0

    HL.set_contents_value(1001)
    carry_flag = HL.subtract_from_contents(2)
    assert HL.get_contents() == 999
    assert carry_flag == 0

    HL.set_contents_value(1)
    carry_flag = HL.subtract_from_contents(2)
    assert HL.get_contents() == 65535
    assert carry_flag == 1
Beispiel #2
0
def test_double_components_set_contents_value():
    H = Component("H")
    L = Component("L")
    HL = DoubleComponent("HL", L, H)

    H.set_contents(0)
    L.set_contents(0)

    HL.set_contents_value(1)
    assert HL.get_contents() == 1

    HL.set_contents_value(1000)
    assert HL.get_contents() == 1000

    HL.set_contents_value(0)
    assert HL.get_contents() == 0