You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.3 KiB
51 lines
1.3 KiB
package de.fd.fh;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
import org.junit.jupiter.params.ParameterizedTest;
|
|
import org.junit.jupiter.params.provider.CsvSource;
|
|
|
|
import java.lang.reflect.Array;
|
|
import java.util.ArrayList;
|
|
|
|
import static org.junit.jupiter.api.Assertions.*;
|
|
|
|
class FigureKingTest
|
|
{
|
|
// K = Position (19), x = gültig (10, 11, 12, 18, 20, 26, 27, 28), rest nicht
|
|
// x x x
|
|
// x K x
|
|
// x x x
|
|
@ParameterizedTest
|
|
@CsvSource({
|
|
"19",
|
|
"45"
|
|
})
|
|
void checkKingMovesSimple(int pos)
|
|
{
|
|
Figure f = new FigureKing();
|
|
|
|
ArrayList<Integer> possibleMoves = new ArrayList<>();
|
|
|
|
possibleMoves.add(pos - Figure.fieldLength - 1);
|
|
possibleMoves.add(pos - Figure.fieldLength);
|
|
possibleMoves.add(pos - Figure.fieldLength + 1);
|
|
|
|
possibleMoves.add(pos -1);
|
|
possibleMoves.add(pos + 1);
|
|
|
|
possibleMoves.add(pos + Figure.fieldLength - 1);
|
|
possibleMoves.add(pos + Figure.fieldLength);
|
|
possibleMoves.add(pos + Figure.fieldLength + 1);
|
|
|
|
for (int i = 0; i < Figure.fieldLength * Figure.fieldLength; i++)
|
|
{
|
|
if (possibleMoves.contains(i))
|
|
{
|
|
assertTrue(f.moveAllowed(pos, i, new Figure[64]));
|
|
continue;
|
|
}
|
|
|
|
assertFalse(f.moveAllowed(pos, i, new Figure[64]));
|
|
}
|
|
}
|
|
}
|