DroidFish: Avoid crash if asked to speak a null move.

This commit is contained in:
Peter Osterlund 2017-09-24 01:11:44 +02:00
parent 45a8bee002
commit f1e62c5263
2 changed files with 3 additions and 1 deletions

View File

@ -145,7 +145,7 @@ public class Speech {
/** Convert move "move" in position "pos" to a sentence that can be spoken. */
public static String moveToText(Position pos, Move move, Language lang) {
if (move == null)
if (move == null || move.from == move.to)
return "";
String moveStr = TextIO.moveToString(pos, move, false, false);

View File

@ -206,6 +206,8 @@ public class SpeechTest extends TestCase {
Pair<Boolean,Move> res = game.processString("Nexc3");
assertEquals(new String[]{"Knight e takes, c3", "Springer e schlägt c3", "Caballo e captura c3"},
moveToText(game.prevPos(), res.second, lang));
assertEquals(new String[]{"", "", ""},
moveToText(game.prevPos(), new Move(0, 0, 0), lang));
}
}