diff options
| author | Pierre Bourdon <delroth@gmail.com> | 2014-03-09 14:51:53 +0100 |
|---|---|---|
| committer | Pierre Bourdon <delroth@gmail.com> | 2014-03-09 14:51:53 +0100 |
| commit | b003fd79d7bee1780d980465b03b23d0fd266e9e (patch) | |
| tree | de17b787e5270cc427ccb4325f0c291d58c6fcf1 /Source/UnitTests/Core | |
| parent | 0ea58cddf910cef48b1a08303831027b6ad01475 (diff) | |
| parent | aabd524142625647fdad84ecf2401ba6cadfcfa6 (diff) | |
Merge pull request #146 from delroth/tests
Add more tests for Common and Core/MMIO
Diffstat (limited to 'Source/UnitTests/Core')
| -rw-r--r-- | Source/UnitTests/Core/MMIOTest.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/Source/UnitTests/Core/MMIOTest.cpp b/Source/UnitTests/Core/MMIOTest.cpp index c7e183f458..65a072617d 100644 --- a/Source/UnitTests/Core/MMIOTest.cpp +++ b/Source/UnitTests/Core/MMIOTest.cpp @@ -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); +} |
