m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules
diff options
context:
space:
mode:
authorMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2020-01-12 23:15:27 +0100
committerMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2020-01-12 23:15:27 +0100
commitec0971201f2b2c90513321a33896390252a43f3d (patch)
tree2f7003cec915d94859081c7712362e7d1317554f /src/test/java/pl/edu/mimuw/cloudatlas/agent/modules
parent0f31d1f5c267f893d765ccd848b95fc111009de5 (diff)
Add GTP tests
Diffstat (limited to 'src/test/java/pl/edu/mimuw/cloudatlas/agent/modules')
-rw-r--r--src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlStateTest.java45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlStateTest.java b/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlStateTest.java
new file mode 100644
index 0000000..b9162b8
--- /dev/null
+++ b/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlStateTest.java
@@ -0,0 +1,45 @@
+package pl.edu.mimuw.cloudatlas.agent.modules;
+
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+import pl.edu.mimuw.cloudatlas.model.PathName;
+import pl.edu.mimuw.cloudatlas.model.ValueContact;
+import pl.edu.mimuw.cloudatlas.model.ValueDuration;
+import pl.edu.mimuw.cloudatlas.model.ValueInt;
+import pl.edu.mimuw.cloudatlas.model.ValueTime;
+
+public class GossipGirlStateTest {
+ @Test
+ public void gtpTest1() throws Exception {
+ GossipGirlState state = new GossipGirlState(0, new PathName("/"), new ValueContact(null, null), true);
+ state.hejkaSendTimestamp = new ValueTime(100l);
+ state.hejkaReceiveTimestamp = new ValueTime(110l);
+ state.noCoTamSendTimestamp = new ValueTime(120l);
+ state.noCoTamReceiveTimestamp = new ValueTime(130l);
+ state.computeOffset();
+ assertEquals(new ValueDuration(0l), state.offset);
+ }
+
+ @Test
+ public void gtpTest2() throws Exception {
+ GossipGirlState state = new GossipGirlState(0, new PathName("/"), new ValueContact(null, null), true);
+ state.hejkaSendTimestamp = new ValueTime(100l);
+ state.hejkaReceiveTimestamp = new ValueTime(60l);
+ state.noCoTamSendTimestamp = new ValueTime(70l);
+ state.noCoTamReceiveTimestamp = new ValueTime(130l);
+ state.computeOffset();
+ assertEquals(new ValueDuration(-50l), state.offset);
+ }
+
+ @Test
+ public void gtpTest3() throws Exception {
+ GossipGirlState state = new GossipGirlState(0, new PathName("/"), new ValueContact(null, null), true);
+ state.hejkaSendTimestamp = new ValueTime(100l);
+ state.hejkaReceiveTimestamp = new ValueTime(160l);
+ state.noCoTamSendTimestamp = new ValueTime(170l);
+ state.noCoTamReceiveTimestamp = new ValueTime(130l);
+ state.computeOffset();
+ assertEquals(new ValueDuration(50l), state.offset);
+ }
+}