package Test;
import static org.junit.Assert.*;
import horse.Area;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class AreaTest
{
Area area;
@Before
public void setUp() throws Exception
{
area = new Area();
}
@After
public void tearDown() throws Exception
{
area = null;
}
@Test
public void testAreaNull()
{
area = new Area();
assertEquals( area.size(), 0 );
}
@Test
public void testArea()
{
area = new Area( 5, 5 );
assertEquals( area.size(), 81 );
}
@Test (expected = ArrayIndexOutOfBoundsException.class)
public void testAreaOutSizeN()
{
area = new Area(0,5);
}
@Test (expected = ArrayIndexOutOfBoundsException.class)
public void testAreaOutSizeM()
{
area = new Area( 5, 0 );
}
@Test (expected = ArrayIndexOutOfBoundsException.class)
public void testSetSizeNull()
{
area.setSize( 0, 0 );
}
@Test
public void testSetSize()
{
area.setSize( 3, 3 );
assertEquals( area.size(), 49 );
}
@Test (expected = ArrayIndexOutOfBoundsException.class)
public void testSetSizeOutSizeN()
{
area.setSize(0,5);
}
@Test (expected = ArrayIndexOutOfBoundsException.class)
public void testSetSizeOutSizeM()
{
area.setSize( 5, 0 );
}
@Test (expected = ArrayIndexOutOfBoundsException.class)
public void testCloneNull()
{
area.clone();
}
@Test
public void testClone()
{
Area clone;
area.setSize(3, 3);
clone = area.clone();
assertEquals( area.size(), clone.size() );
assertArrayEquals(area.getArray(), clone.getArray());
}
@Test (expected = ArrayIndexOutOfBoundsException.class)
public void testSetStartPointNullArea()
{
area.setStartPoint( 0, 0 );
}
@Test (expected = ArrayIndexOutOfBoundsException.class)
public void testSetStartPointOutSizeN()
{
area = new Area( 5, 5 );
area.setStartPoint( 5, 4 );
}
@Test (expected = ArrayIndexOutOfBoundsException.class)
public void testSetStartPointOutSizeM()
{
area = new Area( 5, 5 );
area.setStartPoint( 4, 5 );
}
@Test (expected = ArrayIndexOutOfBoundsException.class)
public void testSetStartPointOutSize_m()
{
area = new Area( 5, 5 );
area.setStartPoint( 4, -1 );
}
@Test (expected = ArrayIndexOutOfBoundsException.class)
public void testSetStartPointOutSize_n()
{
area = new Area( 5, 5 );
area.setStartPoint( -1, 4 );
}
@Test
public void testSetStartPoint()
{
area = new Area( 5, 5 );
area.setStartPoint( 0, 0 );
}
@Test (expected = ArrayIndexOutOfBoundsException.class)
public void testSetEndPointNullArea()
{
area.setEndPoint( 0, 0 );
}
@Test (expected = ArrayIndexOutOfBoundsException.class)
public void testSetEndPointOutSizeN()
{
area = new Area( 5, 5 );
area.setEndPoint( 5, 4 );
}
@Test (expected = ArrayIndexOutOfBoundsException.class)
public void testSetEndPointOutSizeM()
{
area = new Area( 5, 5 );
area.setEndPoint( 4, 5 );
}
@Test (expected = ArrayIndexOutOfBoundsException.class)
public void testSetEndPointOutSize_m()
{
area = new Area( 5, 5 );
area.setEndPoint( 4, -1 );
}
@Test (expected = ArrayIndexOutOfBoundsException.class)
public void testSetEndPointOutSize_n()
{
area = new Area( 5, 5 );
area.setEndPoint( -1, 4 );
}
@Test
public void testSetEndPoint()
{
area = new Area( 5, 5 );
area.setEndPoint( 0, 0 );
}
@Test (expected = ArrayIndexOutOfBoundsException.class)
public void testCheckEndNullArea()
{
area.checkEnd(0, 0);
}
@Test (expected = ArrayIndexOutOfBoundsException.class)
public void testCheckEndOutSizeN()
{
area = new Area( 5, 5 );
area.checkEnd(9, 0);
}
@Test (expected = ArrayIndexOutOfBoundsException.class)
public void testCheckEndOutSizeM()
{
area = new Area( 5, 5 );
area.checkEnd(0, 9);
}
@Test
public void testCheckEnd()
{
area = new Area( 5, 5 );
area.setEndPoint(3, 0);
assertTrue(area.checkEnd(5, 2));
}
@Test (expected = ArrayIndexOutOfBoundsException.class)
public void testSetValueNullArea()
{
area.setValue(0, 0, 1);
}
@Test (expected = ArrayIndexOutOfBoundsException.class)
public void testSetValueOutSizeN()
{
area = new Area( 5, 5 );
area.setValue(9, 5, 1);
}
@Test (expected = ArrayIndexOutOfBoundsException.class)
public void testSetValueOutSizeM()
{
area = new Area( 5, 5 );
area.setValue(5, 9, 1);
}
@Test (expected = ArrayIndexOutOfBoundsException.class)
public void testCheckStepNullArea()
{
area.checkStep(0, 0);
}
@Test (expected = ArrayIndexOutOfBoundsException.class)
public void testCheckStepOutSizeN()
{
area = new Area( 5, 5 );
area.checkStep(9, 0);
}
@Test (expected = ArrayIndexOutOfBoundsException.class)
public void testCheckStepOutSizeM()
{
area = new Area( 5, 5 );
area.checkStep(0, 9);
}
@Test
public void testCheckStep()
{
area = new Area( 5, 5 );
assertTrue(area.checkStep(5, 2));
}
}