Package purrpackagedemo.polygon

Source Code of purrpackagedemo.polygon.PolygonTest

package purrpackagedemo.polygon;

import junit.framework.Assert;

import org.junit.BeforeClass;
import org.junit.Test;


import purrpackagedemo.Point;

public class PolygonTest {

  static Polygon tri, square;
 
  @BeforeClass
  public static void setup() {
    tri = new Polygon( new Point( -1, -1 ), new Point( 0, 1 ), new Point( 1, -1 ) );
    square = new Polygon( new Point( -1, -1 ), new Point( -1, 1 ), new Point( 1, 1 ), new Point( 1, -1 ) );
  }
 
  @Test
  public void testTriangle() {
    Assert.assertTrue( tri.contains( Point.ORIGIN ));
    Assert.assertTrue( tri.contains( new Point( 0, 0.5 ) ));
    Assert.assertFalse( tri.contains( new Point( 3,3 )));
    Assert.assertFalse( tri.contains( new Point( .05, 1 )));
    Assert.assertFalse( tri.contains( new Point( 0, 1.05 )));
    Assert.assertFalse( tri.contains( new Point( -1, -2 )));
    Assert.assertFalse( tri.contains( new Point( -1, 2 )));
    Assert.assertTrue( tri.contains( new Point( -.999, -1 )));
  }
 
  @Test
  public void testSquare() {
    Assert.assertTrue( square.contains( Point.ORIGIN ));
    Assert.assertTrue( square.contains( new Point( 0.5, 0.5 )));
    Assert.assertFalse( square.contains( new Point( 0, 2 )));
    Assert.assertFalse( square.contains( new Point( 1, 3 )) );
  }
 
}
TOP

Related Classes of purrpackagedemo.polygon.PolygonTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.