ps0.test
Class FibonacciTest
java.lang.Object
junit.framework.Assert
junit.framework.TestCase
ps0.test.FibonacciTest
- All Implemented Interfaces:
- Test
public class FibonacciTest
- extends TestCase
FibonacciTest is a glassbox test of the Fibonacci class.
Recall that the Fibonacci sequence is a recursive
sequence where the first two terms of the sequence are 1 and all subsequent
terms are the sum of the previous two terms.
Thus, the Fibonacci sequence starts out as 1, 1, 2, 3, 5, 8, 13...
The first 1 in the sequence is considered the "0th" term,
so the indices that ps0.Fibonacci
uses are 0-based.
- See Also:
Fibonacci
Method Summary |
protected void |
setUp()
|
void |
testBaseCase()
Tests to see that Fibonacci returns the correct value for the base cases, n=0 and n=1 |
void |
testInductiveCase()
Tests inductive cases of the Fibonacci sequence |
void |
testThrowsIllegalArgumentException()
Tests to see that Fibonacci throws an IllegalArgumentException
for a negative number but not for zero or for a positive number. |
Methods inherited from class junit.framework.Assert |
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail |
FibonacciTest
public FibonacciTest()
setUp
protected void setUp()
throws Exception
- Overrides:
setUp
in class TestCase
- Throws:
Exception
testThrowsIllegalArgumentException
public void testThrowsIllegalArgumentException()
- Tests to see that Fibonacci throws an IllegalArgumentException
for a negative number but not for zero or for a positive number.
testBaseCase
public void testBaseCase()
- Tests to see that Fibonacci returns the correct value for the base cases, n=0 and n=1
testInductiveCase
public void testInductiveCase()
- Tests inductive cases of the Fibonacci sequence