diff options
Diffstat (limited to 'core/test_checkpoint.cpp')
-rw-r--r-- | core/test_checkpoint.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/core/test_checkpoint.cpp b/core/test_checkpoint.cpp new file mode 100644 index 0000000..2417a32 --- /dev/null +++ b/core/test_checkpoint.cpp @@ -0,0 +1,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; +} |