import junit.framework.TestCase;

/*
 * Created on Jun 7, 2004
 *
 */

/**
 * @author liam
 */
public class TestFibonacci extends TestCase {

    private Fibonacci f;

    /**
     * Constructor for TestFibonacci.
     * @param arg0
     */
    public TestFibonacci(String arg0) {
        super(arg0);
    }

    public static void main(String[] args) {
        junit.textui.TestRunner.run(TestFibonacci.class);
    }

     public void testGetNext() {
         int terms[] = {1,1,2,3,5};
        int r;
        for (int i = 0; i < terms.length; i++) {
            r = f.getNext();
            assertEquals(terms[i], r);
        }
    }

    public void testSetTerm() {
        int r;
        f.setTerm(7);
        r = f.getNext();
        assertEquals(13,r);
    }

    public void testAssertSame() {
        Fibonacci g = new Fibonacci();
        assertNotSame(f,g);
        Fibonacci h = f;
        assertSame(f,h);
    }
    
    public void testAssertEquals() {
        Fibonacci g = new Fibonacci();
        assertEquals(f,f);
        assertFalse(f == g);
    }

    public void testAssertions() {
        String str = null;
        String str2;
        assertNull(str);

        str = "Hi there";
        str2 = "Hi there";
        assertNotNull(str);

        assertEquals(str, str2);

        assertTrue( 1 == 1 );
        assertTrue( 1 < 2 );
        assertFalse( 100 < 99 );

        try {
            int zero = 0;
            int indefinite = 5 / zero;

            // If execution continues here, code failed
            fail();
        } catch (Exception e) {
            // Division by zero caught, do nothing
        }
    }
    
    /*
     * @see TestCase#setUp()
     */
    protected void setUp() throws Exception {
        super.setUp();
        f = new Fibonacci();
    }

}

