作者 crossoverJie

:white_check_mark: Adding tests.

@@ -198,7 +198,6 @@ public class TrieTree { @@ -198,7 +198,6 @@ public class TrieTree {
198 return list; 198 return list;
199 } 199 }
200 200
201 -  
202 private class Node { 201 private class Node {
203 /** 202 /**
204 * 是否为最后一个字符 203 * 是否为最后一个字符
@@ -20,10 +20,29 @@ public class TrieTreeTest { @@ -20,10 +20,29 @@ public class TrieTreeTest {
20 trieTree.insert("ABC"); 20 trieTree.insert("ABC");
21 trieTree.insert("abC"); 21 trieTree.insert("abC");
22 List<String> all = trieTree.all(); 22 List<String> all = trieTree.all();
  23 + String result = "";
  24 + for (String s : all) {
  25 + result += s + ",";
  26 + System.out.println(s);
  27 + }
  28 +
  29 + Assert.assertTrue("ABC,abC,".equals(result));
  30 +
  31 + }
  32 + @Test
  33 + public void all2() throws Exception {
  34 + TrieTree trieTree = new TrieTree();
  35 + trieTree.insert("abc");
  36 + trieTree.insert("abC");
  37 + List<String> all = trieTree.all();
  38 + String result = "";
23 for (String s : all) { 39 for (String s : all) {
  40 + result += s + ",";
24 System.out.println(s); 41 System.out.println(s);
25 } 42 }
26 43
  44 + //Assert.assertTrue("ABC,abC,".equals(result));
  45 +
27 } 46 }
28 47
29 @Test 48 @Test
@@ -88,7 +107,7 @@ public class TrieTreeTest { @@ -88,7 +107,7 @@ public class TrieTreeTest {
88 List<String> ab = trieTree.prefixSearch("Cd"); 107 List<String> ab = trieTree.prefixSearch("Cd");
89 String result = ""; 108 String result = "";
90 for (String s : ab) { 109 for (String s : ab) {
91 - result += s + "," ; 110 + result += s + ",";
92 System.out.println(s); 111 System.out.println(s);
93 } 112 }
94 Assert.assertTrue(result.equals("Cde,")); 113 Assert.assertTrue(result.equals("Cde,"));
@@ -106,7 +125,7 @@ public class TrieTreeTest { @@ -106,7 +125,7 @@ public class TrieTreeTest {
106 List<String> ab = trieTree.prefixSearch("Cd"); 125 List<String> ab = trieTree.prefixSearch("Cd");
107 String result = ""; 126 String result = "";
108 for (String s : ab) { 127 for (String s : ab) {
109 - result += s + "," ; 128 + result += s + ",";
110 System.out.println(s); 129 System.out.println(s);
111 } 130 }
112 Assert.assertTrue(result.equals("Cde,Cdfff,")); 131 Assert.assertTrue(result.equals("Cde,Cdfff,"));
@@ -124,7 +143,7 @@ public class TrieTreeTest { @@ -124,7 +143,7 @@ public class TrieTreeTest {
124 List<String> ab = trieTree.prefixSearch("CD"); 143 List<String> ab = trieTree.prefixSearch("CD");
125 String result = ""; 144 String result = "";
126 for (String s : ab) { 145 for (String s : ab) {
127 - result += s + "," ; 146 + result += s + ",";
128 System.out.println(s); 147 System.out.println(s);
129 } 148 }
130 Assert.assertTrue(result.equals("CDa,CDfff,")); 149 Assert.assertTrue(result.equals("CDa,CDfff,"));
@@ -142,7 +161,7 @@ public class TrieTreeTest { @@ -142,7 +161,7 @@ public class TrieTreeTest {
142 List<String> ab = trieTree.prefixSearch(""); 161 List<String> ab = trieTree.prefixSearch("");
143 String result = ""; 162 String result = "";
144 for (String s : ab) { 163 for (String s : ab) {
145 - result += s + "," ; 164 + result += s + ",";
146 System.out.println(s); 165 System.out.println(s);
147 } 166 }
148 Assert.assertTrue(result.equals("")); 167 Assert.assertTrue(result.equals(""));
@@ -155,7 +174,7 @@ public class TrieTreeTest { @@ -155,7 +174,7 @@ public class TrieTreeTest {
155 List<String> ab = trieTree.prefixSearch(""); 174 List<String> ab = trieTree.prefixSearch("");
156 String result = ""; 175 String result = "";
157 for (String s : ab) { 176 for (String s : ab) {
158 - result += s + "," ; 177 + result += s + ",";
159 System.out.println(s); 178 System.out.println(s);
160 } 179 }
161 Assert.assertTrue(result.equals("")); 180 Assert.assertTrue(result.equals(""));
@@ -174,7 +193,7 @@ public class TrieTreeTest { @@ -174,7 +193,7 @@ public class TrieTreeTest {
174 List<String> ab = trieTree.prefixSearch("CDFD"); 193 List<String> ab = trieTree.prefixSearch("CDFD");
175 String result = ""; 194 String result = "";
176 for (String s : ab) { 195 for (String s : ab) {
177 - result += s + "," ; 196 + result += s + ",";
178 System.out.println(s); 197 System.out.println(s);
179 } 198 }
180 Assert.assertTrue(result.equals("")); 199 Assert.assertTrue(result.equals(""));
@@ -190,7 +209,7 @@ public class TrieTreeTest { @@ -190,7 +209,7 @@ public class TrieTreeTest {
190 List<String> ab = trieTree.prefixSearch("c"); 209 List<String> ab = trieTree.prefixSearch("c");
191 String result = ""; 210 String result = "";
192 for (String s : ab) { 211 for (String s : ab) {
193 - result += s + "," ; 212 + result += s + ",";
194 System.out.println(s); 213 System.out.println(s);
195 } 214 }
196 Assert.assertTrue(result.equals("crossoverJie,")); 215 Assert.assertTrue(result.equals("crossoverJie,"));