mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-26 08:49:37 +00:00
Adds a very basic shadowing test.
For the record, I'm aware that there's a lot here that I'm not testing. I think the smart move is to get towards a running machine and see which configurations it actually tries to set up, then follow along with appropriate testing; it might cause me to discover a flaw in my comprehension before I've made the same mistake in both the code and a test.
This commit is contained in:
parent
e44f95a882
commit
bdda84dfde
@ -29,36 +29,40 @@ namespace {
|
||||
_memoryMap.set_storage(_ram, _rom);
|
||||
}
|
||||
|
||||
- (void)write:(uint8_t)value address:(uint32_t)address {
|
||||
const auto ®ion = MemoryMapRegion(_memoryMap, address);
|
||||
MemoryMapWrite(_memoryMap, region, address, &value);
|
||||
}
|
||||
|
||||
- (uint8_t)readAddress:(uint32_t)address {
|
||||
const auto ®ion = MemoryMapRegion(_memoryMap, address);
|
||||
uint8_t value;
|
||||
MemoryMapRead(region, address, &value);
|
||||
return value;
|
||||
}
|
||||
|
||||
- (void)testHigherRAM {
|
||||
// Fill memory via the map.
|
||||
for(int address = 0x020000; address < 0x800000; ++address) {
|
||||
const auto ®ion = MemoryMapRegion(_memoryMap, address);
|
||||
const uint8_t value = uint8_t(address ^ (address >> 8));
|
||||
MemoryMapWrite(_memoryMap, region, address, &value);
|
||||
[self write:value address:address];
|
||||
}
|
||||
|
||||
// Test by direct access.
|
||||
for(int address = 0x020000; address < 0x800000; ++address) {
|
||||
const uint8_t value = uint8_t(address ^ (address >> 8));
|
||||
XCTAssertEqual(_ram[address], value);
|
||||
XCTAssertEqual([self readAddress:address], value);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)testROMReadonly {
|
||||
- (void)testROMIsReadonly {
|
||||
_rom[0] = 0xc0;
|
||||
|
||||
// Test that ROM can be read in the correct location.
|
||||
const uint32_t address = 0xfc0000;
|
||||
const auto ®ion = MemoryMapRegion(_memoryMap, address);
|
||||
uint8_t value;
|
||||
MemoryMapRead(region, address, &value);
|
||||
|
||||
XCTAssertEqual(value, 0xc0);
|
||||
XCTAssertEqual([self readAddress:0xfc0000], 0xc0);
|
||||
|
||||
// Try writing to it, and check that nothing happened.
|
||||
value = 0xfc;
|
||||
MemoryMapWrite(_memoryMap, region, address, &value);
|
||||
|
||||
[self write:0xfc address:0xfc0000];
|
||||
XCTAssertEqual(_rom[0], 0xc0);
|
||||
}
|
||||
|
||||
@ -66,11 +70,7 @@ namespace {
|
||||
_rom.back() = 0xa8;
|
||||
auto test_bank = [self](uint32_t bank) {
|
||||
const uint32_t address = bank | 0x00ffff;
|
||||
const auto ®ion = MemoryMapRegion(_memoryMap, address);
|
||||
uint8_t value;
|
||||
MemoryMapRead(region, address, &value);
|
||||
XCTAssertEqual(value, 0xa8);
|
||||
|
||||
XCTAssertEqual([self readAddress:address], 0xa8);
|
||||
};
|
||||
|
||||
test_bank(0x000000);
|
||||
@ -79,4 +79,11 @@ namespace {
|
||||
test_bank(0xe10000);
|
||||
}
|
||||
|
||||
- (void)testShadowing {
|
||||
[self write:0xab address:0x000400];
|
||||
[self write:0xcd address:0x010400];
|
||||
XCTAssertEqual([self readAddress:0xe00400], 0xab);
|
||||
XCTAssertEqual([self readAddress:0xe10400], 0xcd);
|
||||
}
|
||||
|
||||
@end
|
||||
|
Loading…
Reference in New Issue
Block a user