View Javadoc
1   /**
2    * 
3    */
4   package org.melati.poem.util.test;
5   
6   import org.melati.poem.util.DictionaryOrder;
7   import org.melati.poem.util.SortUtils;
8   
9   import junit.framework.TestCase;
10  
11  /**
12   * @author timp
13   * @since 13 Jun 2007
14   *
15   */
16  public class SortUtilsTest extends TestCase {
17  
18    /**
19     * @param name
20     */
21    public SortUtilsTest(String name) {
22      super(name);
23    }
24  
25    /** 
26     * {@inheritDoc}
27     * @see junit.framework.TestCase#setUp()
28     */
29    protected void setUp() throws Exception {
30      super.setUp();
31    }
32  
33    /** 
34     * {@inheritDoc}
35     * @see junit.framework.TestCase#tearDown()
36     */
37    protected void tearDown() throws Exception {
38      super.tearDown();
39    }
40  
41    /**
42     * Test method for {@link org.melati.poem.util.SortUtils#swap(java.lang.Object[], int, int)}.
43     */
44    public void testSwap() {
45  
46    }
47  
48    /**
49     * Test method for {@link org.melati.poem.util.SortUtils#insertionSort(org.melati.poem.util.Order, java.lang.Object[])}.
50     */
51    public void testInsertionSort() {
52  
53    }
54  
55    /**
56     * Test method for {@link org.melati.poem.util.SortUtils#qsort(org.melati.poem.util.Order, java.lang.Object[])}.
57     */
58    public void testQsort() {
59      String[] toSort = new String[] {"a","b","c","d","e","f","g"};
60      SortUtils.qsort(DictionaryOrder.vanilla, toSort);
61      assertEquals("abcdefg", join(toSort));
62      toSort = new String[] {"g","f","e","d","c","b","a"};
63      SortUtils.qsort(DictionaryOrder.vanilla, toSort);
64      assertEquals("abcdefg", join(toSort));
65      toSort = new String[] {"g","b","e","a","c","f","d","z"};
66      SortUtils.qsort(DictionaryOrder.vanilla, toSort);
67      assertEquals("abcdefgz", join(toSort));
68   }
69    private String join(String[] in) { 
70      String ret = "";
71      for (int i = 0; i < in.length; i++)
72        ret += in[i];
73      return ret;
74    }
75    
76    /**
77     * Test method for {@link org.melati.poem.util.SortUtils#sorted(org.melati.poem.util.Order, java.lang.Object[])}.
78     */
79    public void testSortedOrderObjectArray() {
80      String[] toSort = new String[] {"a","b","c","d","e","f","g"};
81      String[] sorted = (String[])SortUtils.sorted(DictionaryOrder.vanilla, toSort);
82      assertEquals("abcdefg", join(sorted));
83      toSort = new String[] {"g","f","e","d","c","b","a"};
84      sorted = (String[])SortUtils.sorted(DictionaryOrder.vanilla, toSort);
85      assertEquals("abcdefg", join(sorted));
86  
87    }
88  
89    /**
90     * Test method for {@link org.melati.poem.util.SortUtils#sorted(org.melati.poem.util.Order, java.util.Vector)}.
91     */
92    public void testSortedOrderVector() {
93  
94    }
95  
96    /**
97     * Test method for {@link org.melati.poem.util.SortUtils#sorted(org.melati.poem.util.Order, java.util.Enumeration)}.
98     */
99    public void testSortedOrderEnumeration() {
100 
101   }
102 
103 }