def test_do_fill_with_no_args_shows_help(self): stdout = StringIO() mon = Monitor(stdout=stdout) mon.do_fill('') out = stdout.getvalue() self.assertTrue(out.startswith('fill <address_range>'))
def test_do_fill_with_no_args_shows_help(self): stdout = StringIO() mon = Monitor(stdout=stdout) mon.do_fill('') out = stdout.getvalue() self.assertTrue(out.startswith('fill <address_range>'))
def test_do_fill_bad_label_in_value_shows_error(self): stdout = StringIO() mon = Monitor(stdout=stdout) mon.do_fill('0 nonexistent') out = stdout.getvalue() self.assertTrue(out.startswith("Label not found: nonexistent"))
def test_do_fill_will_fill_one_address(self): stdout = StringIO() mon = Monitor(stdout=stdout) mon._mpu.memory[0xc000] = 0x00 mon.do_fill('c000 aa') self.assertEqual(0xAA, mon._mpu.memory[0xc000]) out = stdout.getvalue() self.assertTrue(out.startswith('Wrote +1 bytes from $c000 to $c000'))
def test_do_fill_will_fill_one_address(self): stdout = StringIO() mon = Monitor(stdout=stdout) mon._mpu.memory[0xc000] = 0x00 mon.do_fill('c000 aa') self.assertEqual(0xAA, mon._mpu.memory[0xc000]) out = stdout.getvalue() self.assertTrue(out.startswith('Wrote +1 bytes from $c000 to $c000'))
def test_external_memory(self): stdout = StringIO() memory = bytearray(65536) memory[10] = 0xff mon = Monitor(memory=memory, stdout=stdout, putc_addr=None, getc_addr=None) self.assertEqual(0xff, memory[10], "memory must remain untouched") mon.do_mem('0008:000c') mon.do_fill('0000:0020 ab') self.assertEqual(0xab, memory[10], "memory must have been modified") out = stdout.getvalue() self.assertTrue(out.startswith('0008: 00 00 ff 00 00'), "monitor must see pre-initialized memory")
def test_do_fill_will_fill_an_address_range_with_a_single_byte(self): stdout = StringIO() mon = Monitor(stdout=stdout) mon._mpu.memory[0xc000] = 0x00 mon._mpu.memory[0xc001] = 0x00 mon._mpu.memory[0xc002] = 0x00 mon.do_fill('c000:c001 aa') self.assertEqual(0xAA, mon._mpu.memory[0xc000]) self.assertEqual(0xAA, mon._mpu.memory[0xc001]) self.assertEqual(0x00, mon._mpu.memory[0xc002]) out = stdout.getvalue() self.assertTrue(out.startswith('Wrote +2 bytes from $c000 to $c001'))
def test_do_fill_will_fill_an_address_range_with_a_single_byte(self): stdout = StringIO() mon = Monitor(stdout=stdout) mon._mpu.memory[0xc000] = 0x00 mon._mpu.memory[0xc001] = 0x00 mon._mpu.memory[0xc002] = 0x00 mon.do_fill('c000:c001 aa') self.assertEqual(0xAA, mon._mpu.memory[0xc000]) self.assertEqual(0xAA, mon._mpu.memory[0xc001]) self.assertEqual(0x00, mon._mpu.memory[0xc002]) out = stdout.getvalue() self.assertTrue(out.startswith('Wrote +2 bytes from $c000 to $c001'))
def test_do_fill_will_fill_an_address_range_with_byte_sequence(self): stdout = StringIO() mon = Monitor(stdout=stdout) mon._mpu.memory[0xc000] = 0x00 mon._mpu.memory[0xc001] = 0x00 mon._mpu.memory[0xc002] = 0x00 mon._mpu.memory[0xc003] = 0x00 mon.do_fill('c000:c003 aa bb') self.assertEqual(0xAA, mon._mpu.memory[0xc000]) self.assertEqual(0xBB, mon._mpu.memory[0xc001]) self.assertEqual(0xAA, mon._mpu.memory[0xc002]) self.assertEqual(0xBB, mon._mpu.memory[0xc003]) out = stdout.getvalue() self.assertTrue(out.startswith('Wrote +4 bytes from $c000 to $c003'))
def test_do_fill_will_fill_an_address_range_with_byte_sequence(self): stdout = StringIO() mon = Monitor(stdout=stdout) mon._mpu.memory[0xc000] = 0x00 mon._mpu.memory[0xc001] = 0x00 mon._mpu.memory[0xc002] = 0x00 mon._mpu.memory[0xc003] = 0x00 mon.do_fill('c000:c003 aa bb') self.assertEqual(0xAA, mon._mpu.memory[0xc000]) self.assertEqual(0xBB, mon._mpu.memory[0xc001]) self.assertEqual(0xAA, mon._mpu.memory[0xc002]) self.assertEqual(0xBB, mon._mpu.memory[0xc003]) out = stdout.getvalue() self.assertTrue(out.startswith('Wrote +4 bytes from $c000 to $c003'))