Can someone help me with my Java program?

This is the method for my MineSweeper game.
And my one JUnit test doesn't pass.
org.opentest4j.AssertionFailedError: array contents differ at index [0][2], expected: <9> but was: <-2>

at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)

at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)

at org.junit.jupiter.api.AssertArrayEquals.failArraysNotEqual(AssertArrayEquals.java:440)

at org.junit.jupiter.api.AssertArrayEquals.assertArrayEquals(AssertArrayEquals.java:241)

at org.junit.jupiter.api.AssertArrayEquals.assertArrayElementsEqual(AssertArrayEquals.java:364)

at org.junit.jupiter.api.AssertArrayEquals.assertArrayEquals(AssertArrayEquals.java:346)

at org.junit.jupiter.api.AssertArrayEquals.assertArrayEquals(AssertArrayEquals.java:159)

at org.junit.jupiter.api.AssertArrayEquals.assertArrayEquals(AssertArrayEquals.java:155)

at org.junit.jupiter.api.Assertions.assertArrayEquals(Assertions.java:1456)

at MinesweeperTest.testGameTurn(MinesweeperTest.java:113)

at java.base/java.lang.reflect.Method.invoke(Method.java:580)

Does anyone have any idea what I'm doing wrong?
Greeting

(2 votes)
Loading...

Similar Posts

Subscribe
Notify of
4 Answers
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
iQa1x
4 months ago

If you want to have all neighboring fields in the longest line, you need to be on i!=row R & D j!=col test, you only catch the diagonally offset. Whether that’s the mistake, I don’t know.

iQa1x
4 months ago
Reply to  DerPC222

Why do you cover the mines at the bottom of the loop in the adjacent fields? If there is a mine, it should be hidden, right?