-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMemoryTest.java
More file actions
47 lines (42 loc) · 1.23 KB
/
MemoryTest.java
File metadata and controls
47 lines (42 loc) · 1.23 KB
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
44
45
46
47
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class MemoryTest {
@Test
void addressAsInt() {
var m = new Memory();
for (int i = 0; i < 1000; i++) {
TestConverter.fromInt(i, m.address);
assertEquals(i, m.addressAsInt());
}
}
@Test
void readwrite() {
var m = new Memory();
for (int i = 0; i < 1000; i++) {
TestConverter.fromInt(i, m.address);
TestConverter.fromInt(i+4000, m.value);
m.write();
}
for (int i = 0; i < 1000; i++) {
TestConverter.fromInt(i, m.address);
m.read();
assertEquals(i+4000, TestConverter.toInt(m.value));
}
}
@Test
void load() {
var data = new String[1000];
var result = new Word32();
for (int i = 0; i < 1000; i++) {
TestConverter.fromInt(8000+i,result);
data[i]=result.toString().replace(",","");
}
var m = new Memory();
m.load(data);
for (int i = 0; i < 1000; i++) {
TestConverter.fromInt(i, m.address);
m.read();
assertEquals(i+8000, TestConverter.toInt(m.value));
}
}
}