Skip to content

Content of file VGFieldImplTest.java

package de.fhdw.gaming.ipspiel22.vierGewinnt.domain.impl;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import de.fhdw.gaming.core.domain.GameException;
import de.fhdw.gaming.ipspiel22.vierGewinnt.domain.VGBoard;
import de.fhdw.gaming.ipspiel22.vierGewinnt.domain.VGPosition;

/**
 *  Tests {@link VGFieldImpl}.
 */
class VGFieldImplTest {
    /**
     * Board.
     */
    private VGBoard board;

    /**
     * Set up method.
     */
    @BeforeEach
    void setUp() throws GameException {
        this.board = new VGBoardImpl();
    }
    
     /**
     * Tests {@link VGFieldImpl#equals()}.
     */
    @Test
    void testEquals() {
        assertThat(false, is((this.board.getFields().get(0).get(1))
Useless parentheses.
Parenthesized expressions are used to override the default operator precedence rules. Parentheses whose removal would not change the relative nesting of operators are unnecessary, because they don't change the semantics of the enclosing expression. Some parentheses that strictly speaking are unnecessary, may still be considered useful for readability. This rule allows to ignore violations on two kinds of unnecessary parentheses: - "Clarifying" parentheses, which separate operators of difference precedence. While unnecessary, they make precedence rules explicit, which may be useful for rarely used operators. For example: ```java (a + b) & c // is equivalent to `a + b & c`, but probably clearer ``` Unset the property `ignoreClarifying` to report them. - "Balancing" parentheses, which are unnecessary but visually balance out another pair of parentheses around an equality operator. For example, those two expressions are equivalent: ```java (a == null) != (b == null) a == null != (b == null) ``` The parentheses on the right are required, and the parentheses on the left are just more visually pleasing. Unset the property `ignoreBalancing` to report them.
    
        

public class Foo {
    {
        int n = 0;
        n = (n);         // here
        n = (n * 2) * 3; // and here
        n = n * (2 * 3); // and here
    }
}

        
    
See PMD documentation.
.equals(this.board.getFieldAt(VGPosition.of(0, 0))))); } /** * Tests {@link VGFieldImpl#getBoard()}. */ @Test void testGetBoard() { assertThat(true, is(((VGFieldImpl) this.board.getFieldAt(VGPosition.of(0, 0))) .getBoard().equals(this.board))); } // /** // * Tests {@link VGFieldImpl#hashCode()}. // */ // @Test // void testHashCode() { // assertEquals(1881902803, ((VGFieldImpl) this.board.getFieldAt(VGPosition.of(0, 0))) // .hashCode()); // } }