diff options
Diffstat (limited to 'core/test/ch/asynk/rustanddust')
-rw-r--r-- | core/test/ch/asynk/rustanddust/Util.java | 74 |
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); + } +} |