예제 #1
0
def machine_mem_block_test():
    mem = MockMemory()
    data = b"hello, world!"
    mem.w_block(0, data)
    assert mem.r_block(0, len(data)) == data
    bdata = bytearray(data)
    mem.w_block(0x100, bdata)
    assert mem.r_block(0x100, len(bdata)) == bdata
    mem.clear_block(0x200, 100, 42)
    assert mem.r_block(0x200, 100) == bytes([42] * 100)
    mem.copy_block(0x200, 0x300, 20)
    assert mem.r_block(0x300, 21) == bytes([42] * 20) + b"\0"
예제 #2
0
def machine_mem_block_test():
  mem = MockMemory()
  data = "hello, world!"
  mem.w_block(0, data)
  assert mem.r_block(0, len(data)) == data
  bdata = bytearray(data)
  mem.w_block(0x100, bdata)
  assert mem.r_block(0x100, len(bdata)) == bdata
  mem.clear_block(0x200, 100, 42)
  assert mem.r_block(0x200, 100) == chr(42) * 100
  mem.copy_block(0x200, 0x300, 20)
  assert mem.r_block(0x300, 21) == chr(42) * 20 + chr(0)
예제 #3
0
def mem_cache_block_read_test():
  mem = MockMemory()
  data = "hello, world!"
  mem.w_block(0x100, data)
  assert mem.r_block(0x100, len(data)) == data
  bdata = bytearray(data)
  mem.w_block(0x180, bdata)
  assert mem.r_block(0x180, len(bdata)) == bdata
  mem.clear_block(0x200, 100, 42)
  assert mem.r_block(0x200, 100) == chr(42) * 100
  mem.copy_block(0x200, 0x300, 20)
  assert mem.r_block(0x300, 21) == chr(42) * 20 + chr(0)
  # write to main mem
  cmem = MemoryCache(0x100, 0x220)
  cmem.read_cache(mem)
  assert cmem.r_block(0x100, len(data)) == data
  assert cmem.r_block(0x180, len(bdata)) == bdata
  assert cmem.r_block(0x200, 100) == chr(42) * 100
  assert cmem.r_block(0x300, 21) == chr(42) * 20 + chr(0)
예제 #4
0
def mem_cache_block_read_test():
    mem = MockMemory()
    data = "hello, world!"
    mem.w_block(0x100, data)
    assert mem.r_block(0x100, len(data)) == data
    bdata = bytearray(data)
    mem.w_block(0x180, bdata)
    assert mem.r_block(0x180, len(bdata)) == bdata
    mem.clear_block(0x200, 100, 42)
    assert mem.r_block(0x200, 100) == chr(42) * 100
    mem.copy_block(0x200, 0x300, 20)
    assert mem.r_block(0x300, 21) == chr(42) * 20 + chr(0)
    # write to main mem
    cmem = MemoryCache(0x100, 0x220)
    cmem.read_cache(mem)
    assert cmem.r_block(0x100, len(data)) == data
    assert cmem.r_block(0x180, len(bdata)) == bdata
    assert cmem.r_block(0x200, 100) == chr(42) * 100
    assert cmem.r_block(0x300, 21) == chr(42) * 20 + chr(0)