summaryrefslogtreecommitdiff
path: root/tests/cache.cc
blob: 55592ae4088f7b34a82a84eaabc45890e5545299 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "cache.h"
#include "definitions.h"
#include "dram.h"
#include <catch2/catch_test_macros.hpp>

TEST_CASE("Constructor singleton cache", "[cache]")
{
	Cache *c = new Cache(nullptr, 0);
	std::array<signed int, LINE_SIZE> expected = {0, 0, 0, 0};
	std::array<signed int, LINE_SIZE> actual = c->view(0, 1)[0];
	REQUIRE(expected == actual);
	delete c;
}

// TEST_CASE("no delay stores instantly", "[cache]")
// {
// 	int delay = 0;
// 	Dram *d = new Dram(MEM_SIZE, delay);
// 	Cache *c = new Cache(d, delay);
// 	std::array<signed int, LINE_SIZE> expected = {0, 0, 0, 0};
// 	std::array<signed int, LINE_SIZE> actual = d->view(0, 1)[0];
// 	CHECK(expected == actual);

// 	signed int w = 0x11223344;

// 	Response r;
	
// 	r = c->write(MEM, w, 0x0000000000000);	
// 	CHECK(r == OK);
// 	d->resolve();
// 	c->resolve();

// 	expected.at(0) = w;
// 	actual = c->view(0, 1)[0];
// 	REQUIRE(expected == actual);

// 	actual = d->view(0, 1)[0];
// 	// we do NOT write back now!
// 	REQUIRE(expected != actual);

// 	delete d;
// 	delete c;
// }