summaryrefslogtreecommitdiff
path: root/tests/controller.cc
diff options
context:
space:
mode:
authorbd <bdunahu@operationnull.com>2025-03-22 14:19:10 -0400
committerbd <bdunahu@operationnull.com>2025-03-22 14:19:10 -0400
commit2416cce2eec7ecdf0587896620806c465747eada (patch)
treeabcff26473cc45b23a7b9bd501f2974050479efa /tests/controller.cc
parentb73f7fbe952494e245c44fdd4b6123bac1b4ec97 (diff)
Add controller.h, implementation and tests.
Diffstat (limited to 'tests/controller.cc')
-rw-r--r--tests/controller.cc39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/controller.cc b/tests/controller.cc
new file mode 100644
index 0000000..a1b8123
--- /dev/null
+++ b/tests/controller.cc
@@ -0,0 +1,39 @@
+#include "controller.h"
+#include "cache.h"
+#include "dram.h"
+#include <algorithm>
+#include <catch2/catch_test_macros.hpp>
+
+class ControllerPipeFixture
+{
+ public:
+ ControllerPipeFixture()
+ {
+ this->c = new Cache(new Dram(3), 1);
+ this->ct = new Controller(this->c, true);
+ }
+ ~ControllerPipeFixture()
+ {
+ delete this->ct;
+ delete this->c;
+ };
+
+ Cache *c;
+ Controller *ct;
+};
+
+TEST_CASE_METHOD(
+ ControllerPipeFixture,
+ "Contructor resets gettable fields",
+ "[controller_pipe]")
+{
+ std::array<int, GPR_NUM> gprs;
+
+ gprs = this->ct->get_gprs();
+
+ CHECK(this->ct->get_clock_cycle() == 0);
+ CHECK(std::all_of(
+ gprs.begin(), gprs.end(), [](int value) { return value == 0; }));
+ // change me later
+ CHECK(this->ct->get_pc() == 0);
+}