From 7574a77482936bf2c56ee904f7d91d64571b0b12 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Mon, 22 Feb 2016 16:39:45 +0100 Subject: Refactor neighbor computation using directional vectors --- test/ch/epfl/xblast/DirectionTest.java | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'test/ch/epfl') diff --git a/test/ch/epfl/xblast/DirectionTest.java b/test/ch/epfl/xblast/DirectionTest.java index a2ac9cd..0ebb3b7 100644 --- a/test/ch/epfl/xblast/DirectionTest.java +++ b/test/ch/epfl/xblast/DirectionTest.java @@ -1,21 +1,23 @@ package ch.epfl.xblast; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - import org.junit.Test; +import static org.junit.Assert.*; + +/** + * @author EPFL + * @author Pacien TRAN-GIRARD (261948) + */ public class DirectionTest { @Test public void oppositeOfOppositeIsIdentity() { - for (Direction d: Direction.values()) + for (Direction d : Direction.values()) assertEquals(d, d.opposite().opposite()); } @Test public void oppositeIsTwoStepsAway() { - for (Direction d: Direction.values()) + for (Direction d : Direction.values()) assertEquals(2, Math.abs(d.ordinal() - d.opposite().ordinal())); } @@ -29,8 +31,8 @@ public class DirectionTest { @Test public void isParallelIsTrueOnlyForOppositeAndSelf() { - for (Direction d1: Direction.values()) { - for (Direction d2: Direction.values()) { + for (Direction d1 : Direction.values()) { + for (Direction d2 : Direction.values()) { if (d1 == d2 || d1 == d2.opposite()) assertTrue(d1.isParallelTo(d2)); else @@ -38,4 +40,12 @@ public class DirectionTest { } } } + + @Test + public void oppositeVectorSumIsNil() { + for (Direction d : Direction.values()) { + assertEquals(0, d.xVector() + d.opposite().xVector()); + assertEquals(0, d.yVector() + d.opposite().yVector()); + } + } } -- cgit v1.2.3