diff options
author | Siddarth-Suresh <65844402+Siddarth-Suresh@users.noreply.github.com> | 2025-03-11 15:24:57 -0400 |
---|---|---|
committer | Siddarth-Suresh <65844402+Siddarth-Suresh@users.noreply.github.com> | 2025-03-11 15:24:57 -0400 |
commit | 21187ae663a8450553881851e8450315c8d9ca1c (patch) | |
tree | 2a1a7b5b7847d979052ea4aae2f04d7915332c79 /tests/utils.cc | |
parent | b87fa0973b7a3ec08b08e86a2505e68879455b0e (diff) |
Tests for write line in Dram, memory address wrapping implementation and tests
Diffstat (limited to 'tests/utils.cc')
-rw-r--r-- | tests/utils.cc | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/utils.cc b/tests/utils.cc index 5368204..f0e4c24 100644 --- a/tests/utils.cc +++ b/tests/utils.cc @@ -21,3 +21,45 @@ TEST_CASE("Parse arbitrary fields # two", "[cache]") CHECK(index == 0b01110); CHECK(offset == 0b11); } + +TEST_CASE("wrap address outside upper bound", "[utils]") +{ + int address = MEM_SIZE + 25; + int wrapped = wrap_address(address); + REQUIRE(wrapped == 25); +} + +TEST_CASE("wrap address inside upper bound", "[utils]") +{ + int address = MEM_SIZE - 25; + int wrapped = wrap_address(address); + REQUIRE(wrapped == MEM_SIZE - 25); +} + +TEST_CASE("wrap address at upper bound", "[utils]") +{ + int address = MEM_SIZE; + int wrapped = wrap_address(address); + REQUIRE(wrapped == 0); +} + +TEST_CASE("wrap address lower than 0 with magnitude lesser than mem size", "[utils]") +{ + int address = -10; + int wrapped = wrap_address(address); + REQUIRE(wrapped == MEM_SIZE - 10); +} + +TEST_CASE("wrap address lower than 0 but with magnitude greater than mem size", "[utils]") +{ + int address = -(MEM_SIZE + 10); + int wrapped = wrap_address(address); + REQUIRE(wrapped == MEM_SIZE - 10); +} + +TEST_CASE("wrap address at 0", "[utils]") +{ + int address = 0; + int wrapped = wrap_address(address); + REQUIRE(wrapped == 0); +}
\ No newline at end of file |