import org.junit.Assert;
import org.junit.Test;

/**
 * Created by IntelliJ IDEA.
 * User: gloyaute
 * Date: 10 06 2011
 * Time: 21:50:01
 * To change this template use File | Settings | File Templates.
 */

public class TestFreePolyLine {

    @Test
    public void testAdd() {
        try {
            FreePolyLine freePolyLine = new FreePolyLine();

            Assert.assertEquals(0, freePolyLine.pointCount());
            for (int i = 0; i < 10; ++i) {
                freePolyLine.add(new Point(1, 2));
            }
            Assert.assertEquals(10, freePolyLine.pointCount());
        } catch(NegativeArraySizeException e) {
            Assert.fail();
        }
    }

    @Test
    public void testPointCount() {
        try {
            FreePolyLine freePolyLine = new FreePolyLine();
            Assert.assertEquals(0, freePolyLine.pointCount());
            freePolyLine.add(new Point(1, 2));
            Assert.assertEquals(1, freePolyLine.pointCount());
        } catch(NegativeArraySizeException e) {
            Assert.fail();
        }
    }

    @Test
    public void testContains() {
        try {
            FreePolyLine freePolyLine = new FreePolyLine();

            Assert.assertEquals(0, freePolyLine.pointCount());
            for (int i = 0; i < 10; ++i) {
                freePolyLine.add(new Point(i, 2 * i));
            }
            Assert.assertEquals(10, freePolyLine.pointCount());

            Assert.assertTrue(freePolyLine.contains(new Point(8, 16)));
            Assert.assertFalse(freePolyLine.contains(new Point(9, 9)));
        } catch(NegativeArraySizeException e) {
            Assert.fail();
        }
    }
}
