|
|
| TestProtocol.java |
/**
* Compare two objects for identity and protocol the result.
*
* @param testdesc short description of the test.
* @param returned object returned by test candidate.
* @param expected expected object.
*/
public void compare(String testdesc,
Object returned, Object expected) {
++numberOfTests;
if (returned == expected) {
protocol += "Passed: ";
++numberOfPassedTests;
} else {
protocol += "Failed: "
+ "Got `" + returned
+ "' but expected `" + expected + "': ";
}
protocol += testdesc + "\n";
}
|
![]() | The compare methods compare two objects for referential
identity and protocol the result.
|
![]() | Tests of identity are helpful in those cases where the
identity of a returned object is known in advance. This is
true for container classes like stacks.
|
![]() | Note that we rely on the toString() method of objects
if we report differences.
|
|
| Copyright © 2001, 2002 Andreas Borchert, converted to HTML on February 11, 2002 |