test.ca.odell.glazedlists.ToStringTest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of glazedlists_java15 Show documentation
Show all versions of glazedlists_java15 Show documentation
Event-driven lists for dynamically filtered and sorted tables
/* Glazed Lists (c) 2003-2006 */
/* http://publicobject.com/glazedlists/ publicobject.com,*/
/* O'Dell Engineering Ltd.*/
package ca.odell.glazedlists;
// for being a JUnit test case
import ca.odell.glazedlists.matchers.Matchers;
import junit.framework.TestCase;
import java.util.ArrayList;
/**
* This test verifies that the toString() method on all lists is consistent
* with the toString() method of {@link ArrayList}.
*
* @author Jesse Wilson
*/
public class ToStringTest extends TestCase {
/**
* Validate that toString() is consistent with ArrayList on all lists.
*/
public void testToStringConsistency() {
ArrayList controlList = new ArrayList();
BasicEventList basicEventList = new BasicEventList();
FilterList filterList = new FilterList(basicEventList, Matchers.trueMatcher());
SortedList sortedList = SortedList.create(basicEventList);
// Test On Empty Lists
assertEquals(controlList.toString(), basicEventList.toString());
assertEquals(controlList.toString(), filterList.toString());
assertEquals(controlList.toString(), sortedList.toString());
// Test On Lists With One Element
controlList.add("Apple");
basicEventList.add("Apple");
assertEquals(controlList.toString(), basicEventList.toString());
assertEquals(controlList.toString(), filterList.toString());
assertEquals(controlList.toString(), sortedList.toString());
// Test On Lists With Multiple Elements
controlList.add("Banana");
controlList.add("Cherry");
controlList.add("Donut");
basicEventList.add("Banana");
basicEventList.add("Cherry");
basicEventList.add("Donut");
assertEquals(controlList.toString(), basicEventList.toString());
assertEquals(controlList.toString(), filterList.toString());
assertEquals(controlList.toString(), sortedList.toString());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy