From 3941a75c910440186dbb93f1b54ffb2ec5cc9176 Mon Sep 17 00:00:00 2001 From: CyB3RC0nN0R Date: Tue, 10 Sep 2019 21:15:31 +0200 Subject: [PATCH] Changed unit test package structure - Changed unit test package structure to match src - Refactored PositionTest + TestToString method in PositionTest --- .../kske/chess/{test => board}/BoardTest.java | 2 +- test/dev/kske/chess/board/PositionTest.java | 47 +++++++++++++++++ test/dev/kske/chess/test/PositionTest.java | 52 ------------------- 3 files changed, 48 insertions(+), 53 deletions(-) rename test/dev/kske/chess/{test => board}/BoardTest.java (93%) create mode 100644 test/dev/kske/chess/board/PositionTest.java delete mode 100644 test/dev/kske/chess/test/PositionTest.java diff --git a/test/dev/kske/chess/test/BoardTest.java b/test/dev/kske/chess/board/BoardTest.java similarity index 93% rename from test/dev/kske/chess/test/BoardTest.java rename to test/dev/kske/chess/board/BoardTest.java index a4cff22..35bdc96 100644 --- a/test/dev/kske/chess/test/BoardTest.java +++ b/test/dev/kske/chess/board/BoardTest.java @@ -1,4 +1,4 @@ -package dev.kske.chess.test; +package dev.kske.chess.board; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotSame; diff --git a/test/dev/kske/chess/board/PositionTest.java b/test/dev/kske/chess/board/PositionTest.java new file mode 100644 index 0000000..8ae1d0e --- /dev/null +++ b/test/dev/kske/chess/board/PositionTest.java @@ -0,0 +1,47 @@ +package dev.kske.chess.board; + +import static org.junit.Assert.assertEquals; + +import org.junit.jupiter.api.Test; + +/** + * Project: Chess
+ * File: PositionTest.java
+ * Created: 24.07.2019
+ * Author: Kai S. K. Engelbart + */ +class PositionTest { + + final int n = 4; + Position[] positions = new Position[] { new Position(0, 0), new Position(7, 7), new Position(0, 7), new Position(7, 0) }; + String[] sans = new String[] { "a8", "h1", "a1", "h8" }; + String[] strings = new String[] { "[0, 0]", "[7, 7]", "[0, 7]", "[7, 0]" }; + + /** + * Test method for + * {@link dev.kske.chess.board.Position#fromSAN(java.lang.String)}. + */ + @Test + void testFromSAN() { + for (int i = 0; i < n; i++) + assertEquals(positions[i], Position.fromSAN(sans[i])); + } + + /** + * Test method for {@link dev.kske.chess.board.Position#toSAN()}. + */ + @Test + void testToSAN() { + for (int i = 0; i < n; i++) + assertEquals(sans[i], positions[i].toSAN()); + } + + /** + * Test method for {@link dev.kske.chess.board.Position#toString()}. + */ + @Test + void testToString() { + for (int i = 0; i < n; i++) + assertEquals(strings[i], positions[i].toString()); + } +} diff --git a/test/dev/kske/chess/test/PositionTest.java b/test/dev/kske/chess/test/PositionTest.java deleted file mode 100644 index c98c2ba..0000000 --- a/test/dev/kske/chess/test/PositionTest.java +++ /dev/null @@ -1,52 +0,0 @@ -package dev.kske.chess.test; - -import static org.junit.Assert.assertEquals; - -import java.util.Arrays; -import java.util.List; -import java.util.stream.IntStream; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import dev.kske.chess.board.Position; - -/** - * Project: Chess
- * File: PositionTest.java
- * Created: 24.07.2019
- * Author: Kai S. K. Engelbart - */ -class PositionTest { - - List positions; - List sans; - - /** - * @throws java.lang.Exception - */ - @BeforeEach - void setUp() throws Exception { - positions = Arrays.asList(new Position(0, 0), new Position(7, 7), new Position(0, 7), new Position(7, 0)); - sans = Arrays.asList("a8", "h1", "a1", "h8"); - } - - /** - * Test method for - * {@link dev.kske.chess.board.Position#fromSAN(java.lang.String)}. - */ - @Test - void testFromSAN() { - IntStream.range(0, positions.size()) - .forEach(i -> assertEquals(positions.get(i), Position.fromSAN(sans.get(i)))); - } - - /** - * Test method for {@link dev.kske.chess.board.Position#toSAN()}. - */ - @Test - void testToSAN() { - IntStream.range(0, positions.size()).forEach(i -> assertEquals(sans.get(i), positions.get(i).toSAN())); - } - -}