hw2.test
Class BoxTest

java.lang.Object
  extended by hw2.test.BoxTest

public class BoxTest
extends Object

BoxTest is a glassbox test of the Box class. Recall that like a BallContainer, the Box is a container for Balls and you can only put a Ball into a Box once. After you put the Ball into the Box, further attempts to do so will fail, since the Ball is already in the Box! Similarly, you cannot expect to remove a Ball from a Box if it is not inside the Box. In addition, a Box differs from a ballcontainer because it only has a finite volume. As Balls get put into a Box, it gets filled up. Once a Box is full, further attempts to put Balls into the Box will also fail.

See Also:
Ball, BallContainer, Box

Constructor Summary
BoxTest()
           
 
Method Summary
static void setupBeforeTests()
           
 void testAdd()
          Test to check that Box.add(Ball) is implemented correctly
 void testClear()
          Test to check that Box.clear() is implemented correctly
 void testContains()
          Test to check that size() returns the correct number.
 void testGetBalls()
          Test to check that Box.getBallsFromSmallest() is implemented correctly
 void testIterator()
          Test to check that iterator() is implemented correctly.
 void testRemove()
          Test to check that Box.remove(Ball) is implemented correctly.
 void testSize()
          Test to check that size() returns the correct number.
 void testVolume()
          Test to check that check that we can put a Ball into a Box
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BoxTest

public BoxTest()
Method Detail

setupBeforeTests

public static void setupBeforeTests()
                             throws Exception
Throws:
Exception

testAdd

public void testAdd()
Test to check that Box.add(Ball) is implemented correctly


testGetBalls

public void testGetBalls()
Test to check that Box.getBallsFromSmallest() is implemented correctly


testRemove

public void testRemove()
Test to check that Box.remove(Ball) is implemented correctly. Depending on how getBallsFromSmallest() is implemented, remove() might have to be overridden and this test helps ensure that remove() is not broken in the process.


testClear

public void testClear()
Test to check that Box.clear() is implemented correctly


testVolume

public void testVolume()
Test to check that check that we can put a Ball into a Box


testSize

public void testSize()
Test to check that size() returns the correct number.


testContains

public void testContains()
Test to check that size() returns the correct number.


testIterator

public void testIterator()
Test to check that iterator() is implemented correctly.