commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject [Collections] Question about testReverseListSort testcase of Test Comparators
Date Wed, 03 Jul 2002 13:14:40 GMT
Hi all,

I am trying to get my BeanComparator to pass all the test cases, and I am
currently failing on the testReverseListSort testcase.  I pulled the entire
testcase into my own test class, and am logging the output.
Here is my testcase:
	/**  A unit test for JUnit */
	public void testReverseListSort() {
		Comparator comparator = makeComparator();

		List randomList = getComparableObjectsOrdered();
		System.out.println( "random list:" + randomList );
		Collections.reverse( randomList );
		System.out.println( "random list:" + randomList );
		Collections.sort( randomList, comparator );
		System.out.println( "random list:" + randomList );

		List orderedList = getComparableObjectsOrdered();

		assertTrue( "Comparator did not reorder the List correctly",
				orderedList.equals( randomList ) );


Now, I am failing the assertTrue, but when I look at the values, they seem
to be in the correct order:
    [junit] Testsuite:
    [junit] Tests run: 1, Failures: 1, Errors: 0, Time elapsed: 0.301 sec
    [junit] ------------- Standard Output ---------------
    [junit] random list:[value1, value2]
    [junit] random list:[value2, value1]
    [junit] random list:[value1, value2]
    [junit] ------------- ---------------- ---------------

    [junit] Testcase: testReverseListSort took 0.271 sec
    [junit]     FAILED
    [junit] Comparator did not reorder the List correctly
    [junit] junit.framework.AssertionFailedError: Comparator did not reorder
 List correctly
    [junit]     at

It appears that the testcase should pass becaouse the order of the first
randomlist is the same as the last randomlist...

Anyone have ideas?


To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message