summaryrefslogtreecommitdiffstats
path: root/core/test/ch
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2016-01-11 16:00:42 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2016-01-11 16:00:42 +0100
commitd474aea7e0b67ca3e04a07bad68102020e56abf8 (patch)
treeac19e58eef0bf2dd42d9863908465d212d51793d /core/test/ch
parent8db6263d9c91d98c8a0bc32ff542bcfbddfb5835 (diff)
downloadRustAndDust-d474aea7e0b67ca3e04a07bad68102020e56abf8.zip
RustAndDust-d474aea7e0b67ca3e04a07bad68102020e56abf8.tar.gz
tests: add stuff for IterableArray
Diffstat (limited to 'core/test/ch')
-rw-r--r--core/test/ch/asynk/rustanddust/Util.java74
1 files changed, 74 insertions, 0 deletions
diff --git a/core/test/ch/asynk/rustanddust/Util.java b/core/test/ch/asynk/rustanddust/Util.java
new file mode 100644
index 0000000..5ed7b13
--- /dev/null
+++ b/core/test/ch/asynk/rustanddust/Util.java
@@ -0,0 +1,74 @@
+package ch.asynk.rustanddust;
+
+import org.junit.Test;
+
+import ch.asynk.rustanddust.engine.util.IterableArray;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+
+public class Util
+{
+ @Test
+ public void testArray()
+ {
+ IterableArray<Object> a = new IterableArray<Object>(3);
+ assertTrue(a.isEmpty());
+ assertTrue(a.size() == 0);
+ a.add(new Object());
+ assertFalse(a.isEmpty());
+ assertTrue(a.size() == 1);
+ a.add(new Object());
+ assertFalse(a.isEmpty());
+ assertTrue(a.size() == 2);
+ Object o = new Object();
+ assertFalse(a.contains(o));
+ a.add(o);
+ assertTrue(a.contains(o));
+ assertFalse(a.isEmpty());
+ assertTrue(a.size() == 3);
+ a.add(new Object());
+ assertFalse(a.isEmpty());
+ assertTrue(a.size() == 4);
+
+ assertTrue(a.get(2) == o);
+
+ a.clear();
+ assertTrue(a.isEmpty());
+ assertTrue(a.size() == 0);
+
+ a.add(new Object());
+ assertFalse(a.isEmpty());
+ assertTrue(a.size() == 1);
+ a.add(new Object());
+ assertFalse(a.isEmpty());
+ assertTrue(a.size() == 2);
+ assertFalse(a.contains(o));
+ a.add(o);
+ assertTrue(a.contains(o));
+ assertFalse(a.isEmpty());
+ assertTrue(a.size() == 3);
+ a.add(new Object());
+ assertFalse(a.isEmpty());
+ assertTrue(a.size() == 4);
+
+ assertTrue(a.get(2) == o);
+ a.add(o);
+ assertTrue(a.contains(o));
+
+ assertFalse(a.isEmpty());
+ assertTrue(a.size() == 5);
+ assertTrue(a.remove(o));
+ assertFalse(a.isEmpty());
+ assertTrue(a.size() == 4);
+ assertTrue(a.remove(o));
+ assertFalse(a.isEmpty());
+ assertTrue(a.size() == 3);
+ assertFalse(a.remove(o));
+
+ assertNotNull(a.remove(1));
+ assertFalse(a.isEmpty());
+ assertTrue(a.size() == 2);
+ }
+}