commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From EP...@upstate.com
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:
org.apache.commons.collections.comparators.TestBeanCompar
ator
    [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
the
 List correctly
    [junit]     at
org.apache.commons.collections.comparators.TestBeanComparator
.testReverseListSort(TestBeanComparator.java:77)

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

Anyone have ideas?

Eric

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message