-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGoPathTester.java
More file actions
61 lines (49 loc) · 1.25 KB
/
Copy pathGoPathTester.java
File metadata and controls
61 lines (49 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package GoingToPath;
import java.util.ArrayList;
import java.util.List;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class GoPathTester {
private List<List<String>> points;
@Before
public void setUp() throws Exception {
initPoints();
printPointsInfo();
}
@Test
public void test() {
GoPath goPath = new GoPath(points);
goPath.goThroughPath();
}
@Test
public void testRecursive() {
GoPathRecursive goPath = new GoPathRecursive(points);
goPath.goThroughPath();
}
private void initPoints() {
points = new ArrayList<List<String>>();
int pathLength = (int)(Math.random()*5+1);
for (int i = 0; i < pathLength; i++) {
List<String> strings = new ArrayList<String>();
int choiceOfPoint = (int)(Math.random()*5+1);
for (int j = 0; j < choiceOfPoint; j++) {
// we don't care what does strings have
strings.add(String.valueOf((Math.random()*10)));
}
points.add(strings);
}
}
private void printPointsInfo() {
System.out.println("size of points: " + points.size());
System.out.print("paths: ");
for (List<String> strings : points) {
System.out.print(strings.size() + ", ");
}
System.out.println();
}
@After
public void tearDown() throws Exception {
points = null;
}
}