A Test Suite II

 [Previous Chapter]  [Previous Page]  [Contents]  [Next Page]  [Next Chapter]

ArrayedStackTester.java
private TestProtocol protocol;

/**
 * Prepare a test suite.
 */
public ArrayedStackTester() {
   protocol = new TestProtocol();
}

/**
 * Test an empty stack.
 *
 * @param size size of the stack.
 */
public void testEmptyStack(int size) {
   ArrayedStack stack = new ArrayedStack(size);
   String stackdesc = "for an empty stack of size " + size;

   protocol.compare("empty() " + stackdesc,
      stack.empty(), true);
   protocol.compare("full() " + stackdesc,
      stack.full(), false);
}

*testEmptyStack tests the empty() and full() method for empty stacks of a given size.
 
*Note that this method does not constitute an individual test case but a convenient way to run many test cases. Testing an empty stack of size 2 is a different test case as a test of an empty stack of size 3.
 

 [Previous Chapter]  [Previous Page]  [Contents]  [Next Page]  [Next Chapter]
Copyright © 2001, 2002 Andreas Borchert, converted to HTML on February 11, 2002