1 package junit.tests.runner; 2 3 import java.util.Vector ; 4 5 import junit.framework.*; 6 import junit.runner.Sorter; 7 8 public class SorterTest extends TestCase { 9 10 static class Swapper implements Sorter.Swapper { 11 public void swap(Vector values, int left, int right) { 12 Object tmp= values.elementAt(left); 13 values.setElementAt(values.elementAt(right), left); 14 values.setElementAt(tmp, right); 15 } 16 } 17 18 public void testSort() throws Exception { 19 Vector v= new Vector (); 20 v.addElement("c"); 21 v.addElement("b"); 22 v.addElement("a"); 23 Sorter.sortStrings(v, 0, v.size()-1, new Swapper()); 24 assertEquals(v.elementAt(0), "a"); 25 assertEquals(v.elementAt(1), "b"); 26 assertEquals(v.elementAt(2), "c"); 27 } 28 } | Popular Tags |