mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2025-02-18 18:17:49 +01:00
DroidFish: Avoid crash if asked to speak a null move.
This commit is contained in:
parent
45a8bee002
commit
f1e62c5263
|
@ -145,7 +145,7 @@ public class Speech {
|
||||||
|
|
||||||
/** Convert move "move" in position "pos" to a sentence that can be spoken. */
|
/** Convert move "move" in position "pos" to a sentence that can be spoken. */
|
||||||
public static String moveToText(Position pos, Move move, Language lang) {
|
public static String moveToText(Position pos, Move move, Language lang) {
|
||||||
if (move == null)
|
if (move == null || move.from == move.to)
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
String moveStr = TextIO.moveToString(pos, move, false, false);
|
String moveStr = TextIO.moveToString(pos, move, false, false);
|
||||||
|
|
|
@ -206,6 +206,8 @@ public class SpeechTest extends TestCase {
|
||||||
Pair<Boolean,Move> res = game.processString("Nexc3");
|
Pair<Boolean,Move> res = game.processString("Nexc3");
|
||||||
assertEquals(new String[]{"Knight e takes, c3", "Springer e schlägt c3", "Caballo e captura c3"},
|
assertEquals(new String[]{"Knight e takes, c3", "Springer e schlägt c3", "Caballo e captura c3"},
|
||||||
moveToText(game.prevPos(), res.second, lang));
|
moveToText(game.prevPos(), res.second, lang));
|
||||||
|
assertEquals(new String[]{"", "", ""},
|
||||||
|
moveToText(game.prevPos(), new Move(0, 0, 0), lang));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user