Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/quite/humla.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Peugnet <nicolas.peugnet@lip6.fr>2024-01-11 17:35:49 +0300
committerDaniel Lublin <daniel@lublin.se>2024-01-16 14:02:11 +0300
commita88dddf1c0b56c0edd0694d917027f43754f843e (patch)
treee90a2e0527210ccb357fb7b0ddc00d96ad097559
parent2770931c2b959a399152bd516774413f23284631 (diff)
Full (i think) coverage of WhisperTargetList
I forgot to test the 'return null' branch of 'get()', by the way I added messages to assertions that didn't hav one
-rw-r--r--src/test/java/se/lublin/humla/test/WhisperTargetListTest.java15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/test/java/se/lublin/humla/test/WhisperTargetListTest.java b/src/test/java/se/lublin/humla/test/WhisperTargetListTest.java
index adda841..62ea50f 100644
--- a/src/test/java/se/lublin/humla/test/WhisperTargetListTest.java
+++ b/src/test/java/se/lublin/humla/test/WhisperTargetListTest.java
@@ -33,16 +33,21 @@ public class WhisperTargetListTest extends TestCase {
public void testWhisperTargetAddRemove() {
// Initialisation.
Channel root = new Channel(0, false);
+ WhisperTarget expected, actual;
WhisperTarget[] targets = new WhisperTarget[30];
for (int i = 0; i < 30; i++) {
targets[i] = new WhisperTargetChannel(root, false, false, null);
}
WhisperTargetList list = new WhisperTargetList();
+ // Empty list
+ actual = list.get((byte) 1);
+ assertEquals("get on empty list", null, actual);
+
// There should be space for 30 whisper targets.
for (int i = 0; i < 30; i++) {
int space = list.spaceRemaining();
- assertEquals(30-i, space);
+ assertEquals("spaceRemaining should be 30-i", 30-i, space);
byte id = list.append(targets[i]);
assertEquals("id should be equal to i + 1", i+1, id);
WhisperTarget target = list.get(id);
@@ -51,18 +56,20 @@ public class WhisperTargetListTest extends TestCase {
// But not 31.
int space = list.spaceRemaining();
- assertEquals(0, space);
+ assertEquals("spaceRemaining of full list", 0, space);
byte id = list.append(targets[0]);
assertEquals("id should be -1 when no space left", -1, id);
// Freeing one target
list.free((byte) 5);
+ actual = list.get((byte) 5);
+ assertEquals("get after free in same slot", null, actual);
space = list.spaceRemaining();
assertEquals("space should be 1 after freeing one slot", 1, space);
- WhisperTarget expected = new WhisperTargetChannel(root, false, false, null);
+ expected = new WhisperTargetChannel(root, false, false, null);
id = list.append(expected);
assertEquals("append should have filled slot 5", 5, id);
- WhisperTarget actual = list.get((byte) 5);
+ actual = list.get((byte) 5);
assertEquals("slot 5 should contain our target", expected, actual);
list.clear();