Traversals

Tests that compare all elements of two traversal objects.

Overview

If the user implements the Traversal interface for his own class, the checkExpect still examines the data within the class by comparing the values of the corresponding fields. To invoke the comparison of the data generated by the Traversal iterator, the user needs to use thecheckTraversal (or the inexact variant, the checkInexactTraversal) method.

The class ExamplesTraversals contains all test cases.

Code sources

Here is the complete source code for this test suite.

You can also download the entire souce code as a zip file.

Complete test results are shown here.

Brief Examples

Here is an example comparing traversal objects.

t.checkTraversal(
    songlistTr2,  // object 1
    songlistTr1,  // object 2
    "Success: same Traversal-s of songs - shown as Traversal-s"); // test case name

t.checkTraversal(
    songlistTr1a, // object 1
    songlistTr1,  // object 2
    "Success: same Traversal-s of songs (different instance of the same data) - shown as Traversal-s"); // test case name

t.checkTraversal(
    songlistTr3,  // object 1 (2 elements in the list)
    songlistTr1,  // object 2 (3 elements in the list)
    "Should fail: different Traversal-s of songs - first list is shorter"); // test case name

t.checkInexactTraversal(
    doubleListTr1,  // object 1
    doubleListTr2,  // object 2
    0.001,          // tolerance level (too tight)
    "Should fail: not exactly equivalent Traversal-s of Double - the tolerance is too tight"); // test case name

t.checkInexactTraversal(
    doubleListTr1,  // object 1
    doubleListTr2,  // object 2
    0.01,           // tolerance level (loose enough)
    "Success: not exactly equivalent Traversal-s of Double - the tolerance is loose enough"); // test case name

back

Last updated: April 1, 2011 11:56 am