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
48
49
50
51
52
|
#include <iostream>
#include "checkpoint.hpp"
#include "ephermal_checkpoint.hpp"
#include "vector.hpp"
#include "scalar.hpp"
#include "mempool.hpp"
using namespace std;
int main() {
Checkpoint<int, 16> cont("cont", 0), add("moppelkotze", -10);
EphermalCheckpoint<int, 16> eph("ignored", -10);
// check that all initial values are set
for (int i=0; i<16; i++) {
if (add.getValue(0, i) != -10) {
cerr << "initial value of " << i << "wrong (" << add.getValue(0, i) << " != -10)" << endl;
return -1;
}
if (add.getValue(0, i) != -10) {
cerr << "(ephermal) initial value of " << i << "wrong (" << add.getValue(0, i) << " != -10)" << endl;
return -1;
}
}
// check takeover to the next generation
add.getValue(1, 0); // readout already triggers (yes, this also happens below)
for (int i=0; i<16; i++)
if (add.getValue(1, i) != -10) {
cerr << "checkout generation takover of " << i << "failed (" << add.getValue(0, i) << " != -10)" << endl;
return -1;
}
// set and get value
add.set(6, 5, 42);
// check value continuation over time
// WARN: tests also the behaviour that only the most recent value per timeslot is stored
for (int i=1; i<1000; i++)
if (add.getValue(i, 5) != 42) {
cerr << "new value takover failed (time: " << i << ", element 5); value 42 != " << add.getValue(0, i) << endl;
return -1;
}
add.sync();
// success
return 0;
}
|