示例#1
0
def machine_mem_cstr_test():
    mem = MockMemory()
    data = "hello, world"
    mem.w_cstr(0, data)
    assert mem.r_cstr(0) == data
    empty = ""
    mem.w_cstr(100, empty)
    assert mem.r_cstr(100) == empty
示例#2
0
def machine_mem_cstr_test():
  mem = MockMemory()
  data = "hello, world"
  mem.w_cstr(0, data)
  assert mem.r_cstr(0) == data
  empty = ""
  mem.w_cstr(100, empty)
  assert mem.r_cstr(100) == empty
示例#3
0
def mem_cache_cstr_read_test():
  mem = MockMemory()
  data = "hello, world"
  mem.w_cstr(0x100, data)
  assert mem.r_cstr(0x100) == data
  empty = ""
  mem.w_cstr(0x120, empty)
  assert mem.r_cstr(0x120) == empty
  # to cache
  cmem = MemoryCache(0x100, 0x100)
  cmem.read_cache(mem)
  assert cmem.r_cstr(0x100) == data
  assert cmem.r_cstr(0x120) == empty
示例#4
0
def mem_cache_cstr_read_test():
    mem = MockMemory()
    data = "hello, world"
    mem.w_cstr(0x100, data)
    assert mem.r_cstr(0x100) == data
    empty = ""
    mem.w_cstr(0x120, empty)
    assert mem.r_cstr(0x120) == empty
    # to cache
    cmem = MemoryCache(0x100, 0x100)
    cmem.read_cache(mem)
    assert cmem.r_cstr(0x100) == data
    assert cmem.r_cstr(0x120) == empty
示例#5
0
def atypes_cstring_empty_test():
    mem = MockMemory()
    alloc = MemoryAlloc(mem)
    # empty string
    txt = ""
    cs = CString.alloc(alloc, txt)
    assert cs
    assert mem.r_cstr(cs.get_addr()) == txt
    assert cs.get_string() == txt
    assert cs == txt
    assert cs == cs.get_addr()
    cs.free()
    assert alloc.is_all_free()
示例#6
0
def atypes_cstring_empty_test():
  mem = MockMemory()
  alloc = MemoryAlloc(mem)
  # empty string
  txt = ""
  cs = CString.alloc(alloc, txt)
  assert cs
  assert mem.r_cstr(cs.get_addr()) == txt
  assert cs.get_string() == txt
  assert cs == txt
  assert cs == cs.get_addr()
  cs.free()
  assert alloc.is_all_free()
示例#7
0
def mem_cache_cstr_write_test():
  mem = MemoryCache(0x100, 0x100)
  data = "hello, world"
  mem.w_cstr(0x100, data)
  assert mem.r_cstr(0x100) == data
  empty = ""
  mem.w_cstr(0x120, empty)
  assert mem.r_cstr(0x120) == empty
  # to main
  main_mem = MockMemory()
  mem.write_cache(main_mem)
  assert main_mem.r_cstr(0x100) == data
  assert main_mem.r_cstr(0x120) == empty
示例#8
0
def mem_cache_cstr_write_test():
    mem = MemoryCache(0x100, 0x100)
    data = "hello, world"
    mem.w_cstr(0x100, data)
    assert mem.r_cstr(0x100) == data
    empty = ""
    mem.w_cstr(0x120, empty)
    assert mem.r_cstr(0x120) == empty
    # to main
    main_mem = MockMemory()
    mem.write_cache(main_mem)
    assert main_mem.r_cstr(0x100) == data
    assert main_mem.r_cstr(0x120) == empty
示例#9
0
def atypes_cstring_base_test():
    mem = MockMemory()
    alloc = MemoryAlloc(mem)
    # simple string
    txt = "hello, world!"
    cs = CString.alloc(alloc, txt)
    assert cs
    assert mem.r_cstr(cs.get_addr()) == txt
    assert cs.get_string() == txt
    assert cs == txt
    assert cs == cs.get_addr()
    assert cs == CString(mem, cs.get_addr())
    cs.free()
    assert alloc.is_all_free()
示例#10
0
def atypes_cstring_base_test():
  mem = MockMemory()
  alloc = MemoryAlloc(mem)
  # simple string
  txt = "hello, world!"
  cs = CString.alloc(alloc, txt)
  assert cs
  assert mem.r_cstr(cs.get_addr()) == txt
  assert cs.get_string() == txt
  assert cs == txt
  assert cs == cs.get_addr()
  assert cs == CString(mem, cs.get_addr())
  cs.free()
  assert alloc.is_all_free()