
import tester.*;

/**
 * Testing class RectangleTest.
 * 
 * @author pepper
 * @version 2/4/2015
 */
public class RectangleTest  
{
    // Instance variables go here, typically examples to test.
    // For example, if you're testing the Date class, you might say
    // private Date myBirthday = new Date(1964, 1, 27);
    // private Date millennium = new Date(2001, 1, 1);

    /**
     * Run all test methods in the class.
     */
    public static void testEverything ()
    {
        Tester.run (new RectangleTest());
    }

    /**
     *Test the isInside method. Check all four corners and one inside as true. 
     * Check outside x, outside y and outside both as false
     * 
     * @param  t   the Tester to use
     */
    public void testIsInside (Tester t)
    {
        Rectangle t1 = new Rectangle(2,3,5,10); // note that I should not have used 1,1 for the test before
        // as it needs to be sure that it is correctly reading x vs y. 
        // put your code here, e.g.
        t.checkExpect (t1.isInside(2,3),true);
        t.checkExpect (t1.isInside(7,13),true);
        t.checkExpect (t1.isInside(7,3),true);
        t.checkExpect (t1.isInside(2,13),true);
        t.checkExpect (t1.isInside(4,4),true);
        t.checkExpect (t1.isInside(1,3),false);
        t.checkExpect (t1.isInside(2,2),false);
        t.checkExpect (t1.isInside(7,14),false);
        t.checkExpect (t1.isInside(14,14),false);

    }

    /**
     *Test the containingRect method. 
     *It needs to add a rectangle that is inside the object completely
     *add one that slightly overlaps
     *add one that does not overlap at all
     * 
     * @param  t   the Tester to use
     */
    public void testContainingRect (Tester t)
    {
        Rectangle t1 = new Rectangle(2,3,5,10);
        Rectangle add1 = new Rectangle (1,5,2,11); // overlaps
        Rectangle addOutside = new Rectangle (8,14,6,7); // totally outside the object
        Rectangle addInside = new Rectangle (3,4,2,2); // totally inside the object

        t.checkExpect (t1.containingRect(add1),new Rectangle(1,3,6,13));                
        t.checkExpect (t1.containingRect(addOutside),new Rectangle(2,3,12,18)); 
        t.checkExpect (t1.containingRect(addInside),new Rectangle(2,3,5,10)); 
    }
}
