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
13
14
15
16 public class SortUtilsTest extends TestCase {
17
18
19
20
21 public SortUtilsTest(String name) {
22 super(name);
23 }
24
25
26
27
28
29 protected void setUp() throws Exception {
30 super.setUp();
31 }
32
33
34
35
36
37 protected void tearDown() throws Exception {
38 super.tearDown();
39 }
40
41
42
43
44 public void testSwap() {
45
46 }
47
48
49
50
51 public void testInsertionSort() {
52
53 }
54
55
56
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
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
91
92 public void testSortedOrderVector() {
93
94 }
95
96
97
98
99 public void testSortedOrderEnumeration() {
100
101 }
102
103 }