Permalink
Browse files

Passed testTablebaseToStringOutput

  • Loading branch information...
1 parent af3c240 commit 30bc584f44c27c8ff8aca70c16b199e32c366ea7 Kestutis-Z committed Nov 5, 2012
@@ -123,4 +123,26 @@ protected static int getConsequtiveDuplicateCharsInArrayUpToIndex(
blackPieces = convertCharsToPieces(blackPiecesAsChars, PieceColour.BLACK);
return blackPieces;
}
+
+ @Override
+ public String toString() {
+ List<Piece> whitePieces = getWhitePieces();
+ List<Piece> blackPieces = getBlackPieces();
+
+ String output = "";
+ output += whitePieces.get(0).getPieceType().name();
+ for (int i = 1; i < whitePieces.size(); i++) {
+ output += " + ";
+ output += whitePieces.get(i).getPieceType().name();
+ }
+ output += " vs. ";
+ output += blackPieces.get(0).getPieceType().name();
+ for (int i = 1; i < blackPieces.size(); i++) {
+ output += " + ";
+ output += blackPieces.get(i).getPieceType().name();
+ }
+
+ return output;
+ }
+
}
@@ -99,4 +99,13 @@ public void testGetConsequtiveDuplicateCharsInArrayUpToIndex() {
assertArrayEquals(expectedDuplicates, actualDuplicates);
}
+ @Test
+ public void testTablebaseToStringOutput() {
+ Tablebase tablebase = Tablebase.KPK;
+ String actualString = tablebase.toString();
+ String expectedString = "KING + PAWN vs. KING";
+
+ assertEquals(expectedString, actualString);
+ }
+
}
Binary file not shown.

0 comments on commit 30bc584

Please sign in to comment.