diff options
author | Karel Kočí <cynerd@email.cz> | 2017-09-02 15:34:07 +0200 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2017-09-02 15:34:07 +0200 |
commit | 375607d9969896c894fa2642ce4a0b8b519a2adb (patch) | |
tree | cb947a843d85f1cd278da15cff432c849986166c /qtmips_machine/tests | |
parent | 82884b3ef726889f837542d2b5e98e2cd8246c00 (diff) | |
download | qtmips-375607d9969896c894fa2642ce4a0b8b519a2adb.tar.gz qtmips-375607d9969896c894fa2642ce4a0b8b519a2adb.tar.bz2 qtmips-375607d9969896c894fa2642ce4a0b8b519a2adb.zip |
Use QString and QVector instead of std ones and more
Diffstat (limited to 'qtmips_machine/tests')
-rw-r--r-- | qtmips_machine/tests/testprogrammemory.cpp | 41 | ||||
-rw-r--r-- | qtmips_machine/tests/tests.pro | 3 | ||||
-rw-r--r-- | qtmips_machine/tests/tst_machine.h | 3 |
3 files changed, 46 insertions, 1 deletions
diff --git a/qtmips_machine/tests/testprogrammemory.cpp b/qtmips_machine/tests/testprogrammemory.cpp new file mode 100644 index 0000000..a08bbab --- /dev/null +++ b/qtmips_machine/tests/testprogrammemory.cpp @@ -0,0 +1,41 @@ +#include "tst_machine.h" +#include "programmemory.h" +#include <qstring.h> +#include <qvector.h> + +QVector<QString> str_inst_r(const char *inst, const char *rs, const char *rd, const char *rt, const char *sa) { + QVector<QString> ret; + ret << inst; + if (rs) + ret << rs; + if (rd) + ret << rd; + if (rt) + ret << rt; + if (sa) + ret << sa; + return ret; +} + +#define I(II) ((std::uint32_t) II) + +void MachineTests::program_memory_data() { + QTest::addColumn<std::uint32_t>("bin"); + QTest::addColumn<QVector<QString>>("str"); + + // TODO correct instruction + QTest::newRow("NOP") << I(0x000000) << str_inst_r("nop", nullptr, nullptr, nullptr, nullptr); + //QTest::newRow("SLL") << I(0x000000) << str_inst_r("sll", "", "", nullptr, nullptr); + // TODO other instructions +} + +void MachineTests::program_memory() { + Memory m; + ProgramMemory pm(&m); + + QFETCH(std::uint32_t, bin); + QFETCH(QVector<QString>, str); + + m.write_word(0x00, bin); + QCOMPARE(pm.at(0x00)->to_strs(), str); +} diff --git a/qtmips_machine/tests/tests.pro b/qtmips_machine/tests/tests.pro index 9477e08..b9f1497 100644 --- a/qtmips_machine/tests/tests.pro +++ b/qtmips_machine/tests/tests.pro @@ -17,7 +17,8 @@ DEFINES += QT_DEPRECATED_WARNINGS SOURCES += tst_machine.cpp \ testmemory.cpp \ - testregisters.cpp + testregisters.cpp \ + testprogrammemory.cpp HEADERS += tst_machine.h diff --git a/qtmips_machine/tests/tst_machine.h b/qtmips_machine/tests/tst_machine.h index e5137c4..50915f5 100644 --- a/qtmips_machine/tests/tst_machine.h +++ b/qtmips_machine/tests/tst_machine.h @@ -17,6 +17,9 @@ private Q_SLOTS: void memory_section(); void memory_section_data(); void memory_endian(); + // ProgramMemory + void program_memory(); + void program_memory_data(); }; #endif // TST_MACHINE_H |