57 lines
1.2 KiB
Java
57 lines
1.2 KiB
Java
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 {
|
|
|
|
private final int n = 4;
|
|
private Position[] positions = new Position[] {
|
|
new Position(0, 0),
|
|
new Position(7, 7),
|
|
new Position(0, 7),
|
|
new Position(7, 0)
|
|
};
|
|
private String[] sans = new String[] {
|
|
"a8", "h1", "a1", "h8"
|
|
};
|
|
private String[] strings = new String[] {
|
|
"[0, 0]", "[7, 7]", "[0, 7]", "[7, 0]"
|
|
};
|
|
|
|
/**
|
|
* Test method for
|
|
* {@link Position#fromLAN(java.lang.String)}.
|
|
*/
|
|
@Test
|
|
void testFromSAN() {
|
|
for (int i = 0; i < n; i++)
|
|
assertEquals(positions[i], Position.fromLAN(sans[i]));
|
|
}
|
|
|
|
/**
|
|
* Test method for {@link Position#toLAN()}.
|
|
*/
|
|
@Test
|
|
void testToSAN() {
|
|
for (int i = 0; i < n; i++)
|
|
assertEquals(sans[i], positions[i].toLAN());
|
|
}
|
|
|
|
/**
|
|
* Test method for {@link Position#toString()}.
|
|
*/
|
|
@Test
|
|
void testToString() {
|
|
for (int i = 0; i < n; i++)
|
|
assertEquals(strings[i], positions[i].toString());
|
|
}
|
|
}
|