package com.ybrikman.funky.tictactoe;

import com.pholser.junit.quickcheck.ForAll;
import org.junit.Test;
import org.junit.contrib.theories.Theories;
import org.junit.contrib.theories.Theory;
import org.junit.runner.RunWith;

import java.util.List;

import static org.hamcrest.Matchers.any;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeThat;
/**
 * Created by cody on 11/28/14.
 */
@RunWith(Theories.class)
public class BoardMathHelperPropertyTests
{
    //Tests that every return value of this function has greater than 0 digits
    @Test @Theory public void testNumberOfDigits(@ForAll int num)
    {
        assumeThat(num ,any(Integer.TYPE));
        int digits=BoardMathHelpers.numberOfDigits(num);
        assertTrue(digits>0);

    }
    @Test @Theory public void testIsPerfectSquare(@ForAll Integer num)
    {
        assumeThat(num,any(Integer.TYPE));
        boolean ans=BoardMathHelpers.isPerfectSquare(num);
        if(ans) {
            assertFalse(num % 1 == 0);
        }
        else {
            assertTrue(num % 1 == 0);
        }

    }
    @Test @Theory public void testDefaultBoard()
    {
       List<java.util.Optional<Player>> board=BoardMathHelpers.defaultBoard();
       assertTrue(board.size()==BoardMathHelpers.getDefaultBoardSize());

    }
    @Test @Theory public void testCalculateWinningRowIndices()
    {
        List<List<Integer>> indices = BoardMathHelpers.calculateWinningRowIndices(BoardMathHelpers.getDefaultBoardSize(),(int)Math.sqrt(BoardMathHelpers.getDefaultBoardSize()));

    }

}

@@ -284,16 +284,61 @@
 rs.any;%0A
+import static org.junit.Assert.assertEquals;%0A
 import s
@@ -1447,16 +1447,21 @@
 wIndices
+Sizes
 ()%0A    %7B
@@ -1453,32 +1453,55 @@
 esSizes()%0A    %7B%0A
+        int rowSize=3;%0A
         List%3CLis
@@ -1570,103 +1570,210 @@
 ces(
-BoardMathHelpers.getDefaultBoardSize(),(int)Math.sqrt(BoardMathHelpers.getDefaultBoardSize()));
+rowSize*rowSize,rowSize);%0A%0A        //Each list of winning indices should be the length of rowSize%0A        for(List%3CInteger%3E index : indices) %7B%0A            assertEquals(index.size(), rowSize);%0A        %7D%0A
 %0A%0A  

Improve calculateWinningRowIndices() testing