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.assertEquals;
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 testCalculateWinningRowIndicesSizes()
    {
        int rowSize=3;
        List<List<Integer>> indices = BoardMathHelpers.calculateWinningRowIndices(rowSize*rowSize,rowSize);

        //Each list of winning indices should be the length of rowSize
        for(List<Integer> index : indices) {
            assertEquals(index.size(), rowSize);
        }


    }

}

@@ -137,58 +137,9 @@
 ies.
-Theories;%0Aimport org.junit.contrib.theories.Theory
+*
 ;%0Aim
@@ -169,17 +169,16 @@
 unWith;%0A
-%0A
 import j
@@ -190,14 +190,10 @@
 til.
-List;%0A
+*;
 %0Aimp
@@ -225,19 +225,17 @@
 atchers.
-any
+*
 ;%0Aimport
@@ -263,107 +263,9 @@
 ert.
-assertEquals;%0Aimport static org.junit.Assert.assertFalse;%0Aimport static org.junit.Assert.assertTrue
+*
 ;%0Aim
@@ -293,26 +293,17 @@
 .Assume.
-assumeThat
+*
 ;%0A/**%0A *
@@ -532,16 +532,24 @@
 OfDigits
+Property
 (@ForAll
@@ -760,23 +760,19 @@
 @ForAll 
-I
+i
 nt
-eger
  num)%0A  
@@ -873,24 +873,74 @@
 quare(num);%0A
+        Integer sqrt = (int)(Math.sqrt(num)+0.5);%0A
         if(a
@@ -941,24 +941,25 @@
   if(ans) %7B%0A
+%0A
             
@@ -968,26 +968,31 @@
 sert
-F
+Equ
 als
-e
 (num
- %25 1 == 0
+, sqrt * sqrt
 );%0A 
@@ -1037,25 +1037,34 @@
 sert
-True(num %25 1 == 0
+NotEquals(num, sqrt * sqrt
 );%0A 
@@ -1125,16 +1125,28 @@
 ultBoard
+SizeProperty
 ()%0A    %7B

Update property tests