<commit_before>package is.ru.coolpeople.tictactoe;

import org.junit.Test;
import org.springframework.boot.test.context.SpringBootTest;
import static org.junit.Assert.*;

/**
 * Created by olafur on 22/10/2017.
 */

@SpringBootTest
public class BoardTest {
	@Test
	public void placeSymbol() throws Exception {
		//initialize new board
		Board board = new Board();

		//place an arbitrary symbol correctly
		board.placeSymbol("X", 0);

		//check that correctly placed symbol got where it was headed
		assertTrue("X".equals(board.grid[0]));

		//place symbol incorrectly
		boolean caughtException = false;

		try {
			board.placeSymbol("X", 123);
		} catch (IllegalArgumentException e) {
			caughtException = true;
		}

		//IllegalArgumentException should be thrown since this is out of bounds
		assert(caughtException);
	}

	@Test
	public void getSymbolAtIndex() throws Exception {
		//initialize new board
		Board board = new Board();
		board.placeSymbol("X", 4);

		String symbol = board.getSymbolAtIndex(4);

		//check that we get the expected symbol
		assertEquals("X", symbol);

		boolean caughtException = false;
		try {
			board.getSymbolAtIndex(10);
		} catch (IllegalArgumentException e) {
			caughtException = true;
		}

		assertTrue(caughtException);
	}

	@Test
	public void getGrid() throws Exception {
		Board board = new Board();
		String[] grid = board.getGrid();

		assertFalse(grid == null);
	}

	@Test
	public void testBoard() {
		//Set up new board
		Board board = new Board();

		//Grid should be initialized
		assertFalse(board.grid == null);
	}

    @Test
	public void testCustomBoard() {
		//Set up new board
		Board board = new Board(5,5);

		//Grid should be initialized and have 25 tiles
		assertFalse(board.grid == null);
		assertEquals(25, board.grid.length);
	}

    @Test
	public void testInvalidBoardSize() {
		//Set up new board with invalid size
		boolean caughtExceptionOne = false;
		boolean caughtExceptionTwo = false;
		try {
			Board board = new Board(1,2);
		} catch (IllegalArgumentException e) {
			caughtExceptionOne = true;
		}

		try {
			Board board = new Board(3,2);
		} catch (IllegalArgumentException e) {
			caughtExceptionTwo = true;
		}

		//should catch exception
		assertTrue(caughtExceptionOne && caughtExceptionTwo);
	}

}<commit_msg>added testDefaultBoardSize, refacoted testCustomBoard to check for board width/height<commit_after>package is.ru.coolpeople.tictactoe;

import org.junit.Test;
import org.springframework.boot.test.context.SpringBootTest;
import static org.junit.Assert.*;

/**
 * Created by olafur on 22/10/2017.
 */

@SpringBootTest
public class BoardTest {
	@Test
	public void placeSymbol() throws Exception {
		//initialize new board
		Board board = new Board();

		//place an arbitrary symbol correctly
		board.placeSymbol("X", 0);

		//check that correctly placed symbol got where it was headed
		assertTrue("X".equals(board.grid[0]));

		//place symbol incorrectly
		boolean caughtException = false;

		try {
			board.placeSymbol("X", 123);
		} catch (IllegalArgumentException e) {
			caughtException = true;
		}

		//IllegalArgumentException should be thrown since this is out of bounds
		assert(caughtException);
	}

	@Test
	public void getSymbolAtIndex() throws Exception {
		//initialize new board
		Board board = new Board();
		board.placeSymbol("X", 4);

		String symbol = board.getSymbolAtIndex(4);

		//check that we get the expected symbol
		assertEquals("X", symbol);

		boolean caughtException = false;
		try {
			board.getSymbolAtIndex(10);
		} catch (IllegalArgumentException e) {
			caughtException = true;
		}

		assertTrue(caughtException);
	}

	@Test
	public void getGrid() throws Exception {
		Board board = new Board();
		String[] grid = board.getGrid();

		assertFalse(grid == null);
	}

	@Test
	public void testBoard() {
		//Set up new board
		Board board = new Board();

		//Grid should be initialized
		assertFalse(board.grid == null);
	}

    @Test
	public void testDefaultBoardSize() {
		//Set up new board
		Board board = new Board();

		//Grid should be initialized and have 25 tiles
		assertFalse(board.grid == null);
		assertEquals(3, board.getWidth());
		assertEquals(3, board.getHeight());
		assertEquals(9, board.grid.length);
	}

    @Test
	public void testCustomBoard() {
		//Set up new board
		int width = 5;
		int height = 5;
		Board board = new Board(width, height);

		//Grid should be initialized and have 25 tiles
		assertFalse(board.grid == null);
		assertEquals(width, board.getWidth());
		assertEquals(height, board.getHeight());
		assertEquals(25, board.grid.length);
	}

    @Test
	public void testInvalidBoardSize() {
		//Set up new board with invalid size
		boolean caughtExceptionOne = false;
		boolean caughtExceptionTwo = false;
		try {
			Board board = new Board(1,2);
		} catch (IllegalArgumentException e) {
			caughtExceptionOne = true;
		}

		try {
			Board board = new Board(3,2);
		} catch (IllegalArgumentException e) {
			caughtExceptionTwo = true;
		}

		//should catch exception
		assertTrue(caughtExceptionOne && caughtExceptionTwo);
	}

}
{'fraction_non_alphanumeric': 0.10931652550718929, 'fraction_numerical': 0.01162103604490841, 'mean_word_length': 3.7457943925233645, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4551685', 'n_tokens_mistral': 1714, 'n_tokens_neox': 1487, 'n_words': 469}