-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTestModifier.java
More file actions
58 lines (43 loc) · 1.23 KB
/
TestModifier.java
File metadata and controls
58 lines (43 loc) · 1.23 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
package gp_project;
import static org.junit.Assert.*;
import java.util.ArrayList;
import java.util.List;
import gp_project.*;
import org.junit.Before;
import org.junit.Test;
public class TestModifier {
private Tree t1;
private Tree t2;
private FunctionGenerator fGenerator;
private FunctionModifier fModifier;
private FunctionEvaluator fEval;
@Before
public void setUp() throws Exception {
fGenerator = new FunctionGenerator();
fModifier = new FunctionModifier();
fEval = new FunctionEvaluator();
t1 = fGenerator.GenerateFullTree(2);
t2 = fGenerator.GenerateFullTree(2);
}
//Tests that one node in the tree is mutated
@Test
public void testMutate() {
List<String> original= new ArrayList<String>();
List<String> mutated = new ArrayList<String>();
fEval.getPostOrderList(t1.getRootNode(), original);
fModifier.mutate(t1);
fEval.getPostOrderList(t1.getRootNode(), mutated);
assertEquals(original.size(), mutated.size());
int mutatedCount = 0;
for (int i = 0; i < original.size(); i++)
{
String originalValue = original.get(i);
String mutatedValue = mutated.get(i);
if (!originalValue.equals(mutatedValue))
{
mutatedCount ++;
}
}
assertEquals(mutatedCount, 1);
}
}