Changed unit test package structure

- Changed unit test package structure to match src
- Refactored PositionTest
+ TestToString method in PositionTest
This commit is contained in:
Kai S. K. Engelbart 2019-09-10 21:15:31 +02:00
parent bd523018f7
commit 7258e96b1a
Signed by: kske
GPG Key ID: 8BEB13EC5DF7EF13
3 changed files with 48 additions and 53 deletions

View File

@ -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.assertNotEquals;
import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertNotSame;

View File

@ -0,0 +1,47 @@
package dev.kske.chess.board;
import static org.junit.Assert.assertEquals;
import org.junit.jupiter.api.Test;
/**
* Project: <strong>Chess</strong><br>
* File: <strong>PositionTest.java</strong><br>
* Created: <strong>24.07.2019</strong><br>
* Author: <strong>Kai S. K. Engelbart</strong>
*/
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());
}
}

View File

@ -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: <strong>Chess</strong><br>
* File: <strong>PositionTest.java</strong><br>
* Created: <strong>24.07.2019</strong><br>
* Author: <strong>Kai S. K. Engelbart</strong>
*/
class PositionTest {
List<Position> positions;
List<String> 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()));
}
}