summaryrefslogtreecommitdiff
path: root/tests/utils.cc
diff options
context:
space:
mode:
authorSiddarth Suresh <155843085+SiddarthSuresh98@users.noreply.github.com>2025-03-11 20:34:40 -0400
committerGitHub <noreply@github.com>2025-03-11 20:34:40 -0400
commit89b9d1e4592d11cd6146b1bc3b3c12e241e574d3 (patch)
tree30947c7018653ca18d4a69de20936b3615768f9e /tests/utils.cc
parentf208e63ce553c6144a672cd35da23425fa7f86d1 (diff)
parent7c828204a091330eca7dd6495f02f54c2c0a3091 (diff)
Merge pull request #26 from bdunahu/bdunahu
clarify macro names, implement load in CLI, fix many display issues
Diffstat (limited to 'tests/utils.cc')
-rw-r--r--tests/utils.cc24
1 files changed, 12 insertions, 12 deletions
diff --git a/tests/utils.cc b/tests/utils.cc
index f0e4c24..ea1a1ed 100644
--- a/tests/utils.cc
+++ b/tests/utils.cc
@@ -5,9 +5,9 @@
TEST_CASE("Parse arbitrary fields # one", "[cache]")
{
int tag, index, offset;
- int address = 0b111110001010101;
+ int address = 0b0001010101;
get_bit_fields(address, &tag, &index, &offset);
- CHECK(tag == 0b11111000);
+ CHECK(tag == 0b000);
CHECK(index == 0b10101);
CHECK(offset == 0b01);
}
@@ -15,30 +15,30 @@ TEST_CASE("Parse arbitrary fields # one", "[cache]")
TEST_CASE("Parse arbitrary fields # two", "[cache]")
{
int tag, index, offset;
- int address = 0b000110100111011;
+ int address = 0b0100111011;
get_bit_fields(address, &tag, &index, &offset);
- CHECK(tag == 0b00011010);
+ CHECK(tag == 0b010);
CHECK(index == 0b01110);
CHECK(offset == 0b11);
}
TEST_CASE("wrap address outside upper bound", "[utils]")
{
- int address = MEM_SIZE + 25;
+ int address = MEM_WORDS + 25;
int wrapped = wrap_address(address);
REQUIRE(wrapped == 25);
}
TEST_CASE("wrap address inside upper bound", "[utils]")
{
- int address = MEM_SIZE - 25;
+ int address = MEM_WORDS - 25;
int wrapped = wrap_address(address);
- REQUIRE(wrapped == MEM_SIZE - 25);
+ REQUIRE(wrapped == MEM_WORDS - 25);
}
TEST_CASE("wrap address at upper bound", "[utils]")
{
- int address = MEM_SIZE;
+ int address = MEM_WORDS;
int wrapped = wrap_address(address);
REQUIRE(wrapped == 0);
}
@@ -47,14 +47,14 @@ TEST_CASE("wrap address lower than 0 with magnitude lesser than mem size", "[uti
{
int address = -10;
int wrapped = wrap_address(address);
- REQUIRE(wrapped == MEM_SIZE - 10);
+ REQUIRE(wrapped == MEM_WORDS - 10);
}
TEST_CASE("wrap address lower than 0 but with magnitude greater than mem size", "[utils]")
{
- int address = -(MEM_SIZE + 10);
+ int address = -(MEM_WORDS + 10);
int wrapped = wrap_address(address);
- REQUIRE(wrapped == MEM_SIZE - 10);
+ REQUIRE(wrapped == MEM_WORDS - 10);
}
TEST_CASE("wrap address at 0", "[utils]")
@@ -62,4 +62,4 @@ TEST_CASE("wrap address at 0", "[utils]")
int address = 0;
int wrapped = wrap_address(address);
REQUIRE(wrapped == 0);
-} \ No newline at end of file
+}