A Class For Test Protocols IV

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

TestProtocol.java
/**
 * Compare two boolean values for equality and protocol
 * the result.
 *
 * @param testdesc short description of the test.
 * @param returned boolean value returned by test candidate.
 * @param expected expected boolean value.
 */
public void compare(String testdesc,
      boolean returned, boolean expected) {
   ++numberOfTests;
   if (returned == expected) {
      protocol += "Passed: ";
      ++numberOfPassedTests;
   } else {
      protocol += "Failed: "
         + "Got " + returned
         + " but expected " + expected + ": ";
   }
   protocol += testdesc + "\n";
}

*Similar compare methods can be provided for the fundamental types of Java.
 

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