mirror of https://github.com/pret/pokecrystal.git
vba - example unit testing of roms
This commit is contained in:
parent
caa1dc10dd
commit
f0767fb15a
|
@ -74,6 +74,7 @@ import re
|
||||||
from array import array
|
from array import array
|
||||||
import string
|
import string
|
||||||
from copy import copy
|
from copy import copy
|
||||||
|
import unittest
|
||||||
|
|
||||||
# for converting bytes to readable text
|
# for converting bytes to readable text
|
||||||
from chars import chars
|
from chars import chars
|
||||||
|
@ -558,20 +559,12 @@ def call(bank, address):
|
||||||
print "actual memory values: " + str(get_memory_range(registers.sp , 2))
|
print "actual memory values: " + str(get_memory_range(registers.sp , 2))
|
||||||
print "wrong value at " + hex(registers.sp) + " expected " + hex(value) + " but got " + hex(get_memory_at(registers.sp))
|
print "wrong value at " + hex(registers.sp) + " expected " + hex(value) + " but got " + hex(get_memory_at(registers.sp))
|
||||||
|
|
||||||
#registers.af = (bank << 8) | (registers.af & 0xff)
|
if bank != 1:
|
||||||
#registers.hl = address
|
registers["af"] = (bank << 8) | (registers["af"] & 0xFF)
|
||||||
#registers.pc = 0x2d63 # FarJump
|
registers["hl"] = address
|
||||||
|
registers["pc"] = 0x2d63 # FarJump
|
||||||
#registers2 = get_registers()
|
else:
|
||||||
#registers2[5] = 0xc4a0
|
registers["pc"] = address
|
||||||
#registers2[4] = 0x1276
|
|
||||||
#registers2[0] = address
|
|
||||||
#set_registers(registers2)
|
|
||||||
|
|
||||||
registers["hl"] = 0xc4a0
|
|
||||||
registers["de"] = 0x1276
|
|
||||||
registers["pc"] = address
|
|
||||||
#print "registers.pc is: " + hex(registers.pc)
|
|
||||||
|
|
||||||
class crystal:
|
class crystal:
|
||||||
"""
|
"""
|
||||||
|
@ -816,3 +809,31 @@ class crystal:
|
||||||
|
|
||||||
set_memory(memory)
|
set_memory(memory)
|
||||||
|
|
||||||
|
class TestEmulator(unittest.TestCase):
|
||||||
|
state = load_state("cheating-12")
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
load_rom()
|
||||||
|
set_state(self.state)
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
shutdown()
|
||||||
|
|
||||||
|
def test_PlaceString(self):
|
||||||
|
call(1, 0x1078)
|
||||||
|
|
||||||
|
# where to draw the text
|
||||||
|
registers["hl"] = 0xc4a0
|
||||||
|
|
||||||
|
# what text to read from
|
||||||
|
registers["de"] = 0x1276
|
||||||
|
|
||||||
|
nstep(10)
|
||||||
|
|
||||||
|
text = crystal.get_text()
|
||||||
|
|
||||||
|
self.assertTrue("TRAINER" in text)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue