From 375607d9969896c894fa2642ce4a0b8b519a2adb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Sat, 2 Sep 2017 15:34:07 +0200 Subject: Use QString and QVector instead of std ones and more --- qtmips_machine/tests/testprogrammemory.cpp | 41 ++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 qtmips_machine/tests/testprogrammemory.cpp (limited to 'qtmips_machine/tests/testprogrammemory.cpp') 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 +#include + +QVector str_inst_r(const char *inst, const char *rs, const char *rd, const char *rt, const char *sa) { + QVector 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("bin"); + QTest::addColumn>("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, str); + + m.write_word(0x00, bin); + QCOMPARE(pm.at(0x00)->to_strs(), str); +} -- cgit v1.2.3