From 25c39d107cad34ff395f98e2fcaf266268d48c80 Mon Sep 17 00:00:00 2001 From: Malte Schellhardt Date: Wed, 9 Feb 2022 16:38:28 +0100 Subject: [PATCH] tictactoe: added checkForWin method --- src/main/java/de/tims/tictactoe/GameLogic.java | 6 ++++-- .../java/de/tims/tictactoe/GameLogicTest.java | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/tims/tictactoe/GameLogic.java b/src/main/java/de/tims/tictactoe/GameLogic.java index 0790cb3..463bbc7 100644 --- a/src/main/java/de/tims/tictactoe/GameLogic.java +++ b/src/main/java/de/tims/tictactoe/GameLogic.java @@ -1,7 +1,5 @@ package de.tims.tictactoe; -import java.util.Arrays; - public class GameLogic { private char[][] board; @@ -42,5 +40,9 @@ public class GameLogic { } return true; } + + public boolean checkForWin() { + return true; + } } diff --git a/src/test/java/de/tims/tictactoe/GameLogicTest.java b/src/test/java/de/tims/tictactoe/GameLogicTest.java index 4c14782..43b702a 100644 --- a/src/test/java/de/tims/tictactoe/GameLogicTest.java +++ b/src/test/java/de/tims/tictactoe/GameLogicTest.java @@ -80,6 +80,14 @@ class GameLogicTest { assertEquals(expectedResult, realResult); } + @ParameterizedTest(name = "[{index}] {0}") + @MethodSource("testCasesForCheckForWin") + void checkForWinTest(String testName, boolean expectedResult, char[][] boardToCheck) { + boolean realResult = new GameLogic(boardToCheck).checkForWin(); + + assertEquals(expectedResult, realResult); + } + private static Stream testCasesForCountPlayfields() { return Stream.of( Arguments.of("1x1 board with too few fields", 1, 9), @@ -123,5 +131,14 @@ class GameLogicTest { {'-', '-', '-'}}) ); } + + private static Stream testCasesForCheckForWin() { + return Stream.of( + Arguments.of("check win for player 1", true, new char[][] + {{'x', '-', '-'}, + {'x', '-', '-'}, + {'x', '-', '-'}}) + ); + } }