Add more tests for Common and Core/MMIO

This commit is contained in:
Pierre Bourdon
2014-03-09 14:27:04 +01:00
parent 2e70ff2441
commit aabd524142
7 changed files with 240 additions and 0 deletions

View File

@ -23,6 +23,15 @@ TEST(UniqueID, UniqueEnough)
}
}
TEST(IsMMIOAddress, SpecialAddresses)
{
// WG Pipe address, should not be handled by MMIO.
EXPECT_FALSE(MMIO::IsMMIOAddress(0xCC008000));
// Memory zone used by games using the "MMU Speedhack".
EXPECT_FALSE(MMIO::IsMMIOAddress(0xE0000000));
}
class MappingTest : public testing::Test
{
protected:
@ -75,3 +84,27 @@ TEST_F(MappingTest, ReadWriteDirect)
val32 += 1; m_mapping->Write(0xCC001234, val32);
}
}
TEST_F(MappingTest, ReadWriteComplex)
{
bool read_called = false, write_called = false;
m_mapping->Register(0xCC001234,
MMIO::ComplexRead<u8>([&read_called](u32 addr) {
EXPECT_EQ(0xCC001234, addr);
read_called = true;
return 0x12;
}),
MMIO::ComplexWrite<u8>([&write_called](u32 addr, u8 val) {
EXPECT_EQ(0xCC001234, addr);
EXPECT_EQ(0x34, val);
write_called = true;
})
);
u8 val; m_mapping->Read(0xCC001234, &val); EXPECT_EQ(0x12, val);
m_mapping->Write(0xCC001234, (u8)0x34);
EXPECT_TRUE(read_called);
EXPECT_TRUE(write_called);
}