Skip to content
Snippets Groups Projects
Select Git revision
  • 0fa0c6d4a6b3c178146a04cad2ce2bc4e7f43e55
  • main default protected
  • correction_video
  • going_further
  • ImprovedMouseInteraction
  • final2023
  • template
  • ModifGUI
8 results

CellState.java

Blame
  • Forked from YAGOUBI Rim / Game of life Template
    Source project has a limited visibility.
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    GridTest.java 1.10 KiB
    package model;
    
    import org.junit.jupiter.api.BeforeEach;
    import org.junit.jupiter.api.Test;
    import static org.hamcrest.MatcherAssert.assertThat;
    import static org.hamcrest.Matchers.*;
    
    public class GridTest {
      private Grid grid;
    
      @BeforeEach
      public void initializeGrid(){
        grid = new Grid(3,3);
      }
    
      @Test
      public void testGetNeighbours(){
        assertThat(grid.getNeighbours(1,1), is(notNullValue()));
        assertThat(grid.getNeighbours(1,1), hasSize(equalTo(8)));
        assertThat(grid.getNeighbours(1,1),
                containsInAnyOrder(grid.getCell(0,0),
                        grid.getCell(0,1),
                        grid.getCell(0,2),
                        grid.getCell(1,0),
                        grid.getCell(1,2),
                        grid.getCell(2,0),
                        grid.getCell(2,1),
                        grid.getCell(2,2)));
      }
    
      @Test
      public void testCountAliveNeighbours(){
        assertThat(grid.countAliveNeighbours(1,1), is(equalTo(0)));
        grid.getCell(2,2).setState(CellState.ALIVE);
        grid.getCell(0,0).setState(CellState.ALIVE);
        assertThat(grid.countAliveNeighbours(1,1), is(equalTo(2)));
      }
    
    
    }