Пример #1
0
def test_memory_write(initial_size, memory_offset, data):
    # Arrange
    machine_state = MachineState(0)
    machine_state.memory = [0]*initial_size

    # Act
    machine_state.memory_write(memory_offset, data)

    # Assert
    assert len(machine_state.memory) == max(initial_size, memory_offset+len(data))
    assert machine_state.memory[memory_offset:memory_offset+len(data)] == data
Пример #2
0
def test_memory_extension(initial_size, start, extension_size):
    # Arrange
    machine_state = MachineState(0)
    machine_state.memory = [0] * initial_size

    # Act
    machine_state.mem_extend(start, extension_size)

    # Assert
    assert machine_state.memory_size == len(machine_state.memory)
    assert machine_state.memory_size == max(initial_size, start + extension_size)