diff options
author | Karel Kočí <cynerd@email.cz> | 2017-11-19 21:23:04 +0100 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2017-11-19 21:23:04 +0100 |
commit | f0ad502e4651243d6a96194b3393bd460c0f7fc9 (patch) | |
tree | 4f912c24b5943bd93b5a3378df75f9611de6779b /qtmips_machine/tests/testmemory.cpp | |
parent | 2c6562fa78e884d66b8c2a306f020101e8803f2e (diff) | |
download | qtmips-f0ad502e4651243d6a96194b3393bd460c0f7fc9.tar.gz qtmips-f0ad502e4651243d6a96194b3393bd460c0f7fc9.tar.bz2 qtmips-f0ad502e4651243d6a96194b3393bd460c0f7fc9.zip |
Another huge pile of work for about two months
Well I should commit every change instead of this madness. I am not
documenting changes as all this is just improvements and implementation
progression.
Diffstat (limited to 'qtmips_machine/tests/testmemory.cpp')
-rw-r--r-- | qtmips_machine/tests/testmemory.cpp | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/qtmips_machine/tests/testmemory.cpp b/qtmips_machine/tests/testmemory.cpp index eac7dd6..e450231 100644 --- a/qtmips_machine/tests/testmemory.cpp +++ b/qtmips_machine/tests/testmemory.cpp @@ -13,21 +13,21 @@ void MachineTests::memory_data() { void MachineTests::memory() { Memory m; - QFETCH(std::uint32_t, address); + QFETCH(std::uint32_t, address); - // Uninitialize memory should read as zero - QCOMPARE(m.read_byte(address), (std::uint8_t)0); - QCOMPARE(m.read_hword(address), (std::uint16_t)0); - QCOMPARE(m.read_word(address), (std::uint32_t)0); - // Just a byte - m.write_byte(address, 0x42); - QCOMPARE(m.read_byte(address), (std::uint8_t)0x42); - // Half word - m.write_hword(address, 0x4243); - QCOMPARE(m.read_hword(address), (std::uint16_t)0x4243); - // Word - m.write_word(address, 0x42434445); - QCOMPARE(m.read_word(address), (std::uint32_t)0x42434445); + // Uninitialize memory should read as zero + QCOMPARE(m.read_byte(address), (std::uint8_t)0); + QCOMPARE(m.read_hword(address), (std::uint16_t)0); + QCOMPARE(m.read_word(address), (std::uint32_t)0); + // Just a byte + m.write_byte(address, 0x42); + QCOMPARE(m.read_byte(address), (std::uint8_t)0x42); + // Half word + m.write_hword(address, 0x4243); + QCOMPARE(m.read_hword(address), (std::uint16_t)0x4243); + // Word + m.write_word(address, 0x42434445); + QCOMPARE(m.read_word(address), (std::uint32_t)0x42434445); } void MachineTests::memory_section_data() { @@ -40,24 +40,24 @@ void MachineTests::memory_section_data() { } void MachineTests::memory_section() { - Memory m; + Memory m; - QFETCH(std::uint32_t, address); + QFETCH(std::uint32_t, address); - // 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); + // 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); - // Write some data to memory - m.write_byte(address, 0x42); - // Read it trough section (mask bits outside of the memory section) - QCOMPARE(s->read_byte(address & ((1 << MEMORY_SECTION_BITS) - 1)), (std::uint8_t)0x42); - // Write some other data trough section - s->write_byte(address & ((1 << MEMORY_SECTION_BITS) - 1), 0x66); - // Read trough memory - QCOMPARE(m.read_byte(address), (std::uint8_t)0x66); + // Write some data to memory + m.write_byte(address, 0x42); + // Read it trough section (mask bits outside of the memory section) + QCOMPARE(s->read_byte(address & ((1 << MEMORY_SECTION_BITS) - 1)), (std::uint8_t)0x42); + // Write some other data trough section + s->write_byte(address & ((1 << MEMORY_SECTION_BITS) - 1), 0x66); + // Read trough memory + QCOMPARE(m.read_byte(address), (std::uint8_t)0x66); } void MachineTests::memory_endian() { |