aboutsummaryrefslogtreecommitdiff
path: root/qtmips_machine/tests/testmemory.cpp
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2017-11-21 19:48:51 +0100
committerKarel Kočí <cynerd@email.cz>2017-11-21 19:48:51 +0100
commit499a88621d12ff0cdcba1f8c796b7031d6adc649 (patch)
treec050b5224c896b3e14d74866473aef9c2a5e9b69 /qtmips_machine/tests/testmemory.cpp
parent68f2af6801756980ec53347c0acb7fcc292f7939 (diff)
downloadqtmips-499a88621d12ff0cdcba1f8c796b7031d6adc649.tar.gz
qtmips-499a88621d12ff0cdcba1f8c796b7031d6adc649.tar.bz2
qtmips-499a88621d12ff0cdcba1f8c796b7031d6adc649.zip
Add possibility to compare memory and registers state
For core testing we want to compare whole memory and registers. Registers are pretty simple but in case of memory it is some what more complicated and required its own tests to be sure that it works.
Diffstat (limited to 'qtmips_machine/tests/testmemory.cpp')
-rw-r--r--qtmips_machine/tests/testmemory.cpp28
1 files changed, 25 insertions, 3 deletions
diff --git a/qtmips_machine/tests/testmemory.cpp b/qtmips_machine/tests/testmemory.cpp
index e450231..091c26d 100644
--- a/qtmips_machine/tests/testmemory.cpp
+++ b/qtmips_machine/tests/testmemory.cpp
@@ -44,8 +44,7 @@ void MachineTests::memory_section() {
QFETCH(std::uint32_t, address);
- // First section shouldn't exists
- QCOMPARE(m.get_section(address, false), (MemorySection*)nullptr);
+ // First section shouldn't exists QCOMPARE(m.get_section(address, false), (MemorySection*)nullptr);
// Create section
MemorySection *s = m.get_section(address, true);
QVERIFY(s != nullptr);
@@ -63,7 +62,7 @@ void MachineTests::memory_section() {
void MachineTests::memory_endian() {
Memory m;
- // Memory should be bit endian so write bytes from most significant byte
+ // Memory should be little endian so write bytes from most significant byte
m.write_byte(0x00, 0x12);
m.write_byte(0x01, 0x34);
m.write_byte(0x02, 0x56);
@@ -81,3 +80,26 @@ void MachineTests::memory_endian() {
QCOMPARE(m.read_byte(0xF2), (std::uint8_t)0x56);
QCOMPARE(m.read_byte(0xF3), (std::uint8_t)0x78);
}
+
+void MachineTests::memory_compare() {
+ Memory m1, m2;
+ QCOMPARE(m1, m2);
+ m1.write_byte(0x20,0x0);
+ QVERIFY(m1 != m2); // This should not be equal as this identifies also memory write (difference between no write and zero write)
+ m1.write_byte(0x20,0x24);
+ QVERIFY(m1 != m2);
+ m2.write_byte(0x20,0x23);
+ QVERIFY(m1 != m2);
+ m2.write_byte(0x20,0x24);
+ QCOMPARE(m1, m2);
+ // Do the same with some other section
+ m1.write_byte(0xFFFF20, 0x24);
+ QVERIFY(m1 != m2);
+ m2.write_byte(0xFFFF20, 0x24);
+ QCOMPARE(m1, m2);
+ // And also check memory copy
+ Memory m3(m1);
+ QCOMPARE(m1, m3);
+ m3.write_byte(0x18, 0x22);
+ QVERIFY(m1 != m3);
+}