This repository was archived by the owner on Mar 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestGapSeqGenerator.java
More file actions
150 lines (144 loc) · 3.37 KB
/
Copy pathTestGapSeqGenerator.java
File metadata and controls
150 lines (144 loc) · 3.37 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
import java.util.ArrayList;
/*
* Unit Tests for GapSeqGenerator
*/
public class TestGapSeqGenerator
{
//testing shell gap sequence generator
private static String TestGenShellGapSeq()
{
String n = "";
//setup
int arraySize = 1000;
int[] arrOUT = {500, 250, 125, 62, 31, 15, 7, 3, 1};
//experiment step
ArrayList<Integer> arr = GapSeqGenerator.genShellGapSeq(arraySize);
//testing
for(int i=0; i<arr.size(); i++)
{
if(arr.get(i) != arrOUT[i])
{
n = "Shell Gap Sequence Generator";
}
}
return n;
}
//testing knuth gap sequence generator
private static String TestGenKnuthGapSeq()
{
String n = "";
//setup
int arraySize = 1200;
int[] arrOUT = {364, 121, 40, 13, 4, 1};
//experiment step
ArrayList<Integer> arr = GapSeqGenerator.genKnuthGapSeq(arraySize);
//testing
for(int i=0; i<arr.size(); i++)
{
if(arr.get(i) != arrOUT[i])
{
n = "Knuth Gap Sequence Generator";
}
}
return n;
}
//testing tokuda gap sequence generator
private static String TestGenTokudaGapSeq()
{
String n = "";
//setup
int arraySize = 1300;
int[] arrOUT = {1182, 525, 233, 103, 46, 20, 9, 4, 1};
//experiment step
ArrayList<Integer> arr = GapSeqGenerator.genTokudaGapSeq(arraySize);
//testing
for(int i=0; i<arr.size(); i++)
{
if(arr.get(i) != arrOUT[i])
{
n = "Tokuda Gap Sequence Generator";
}
}
return n;
}
//testing the generateGapSeq method
private static ArrayList<String> TestGenerateGapSeq()
{
String n = "";
ArrayList<String> arrOfProblems = new ArrayList<String>();
//setup
int arraySize = 1000;
int[] arrOUTsh = {500, 250, 125, 62, 31, 15, 7, 3, 1};
int[] arrOUTkn = {121, 40, 13, 4, 1};
int[] arrOUTto = {525, 233, 103, 46, 20, 9, 4, 1};
//experiment step 1
ArrayList<Integer> arrSH = GapSeqGenerator.genShellGapSeq(arraySize);
//testing case 1
for(int i=0; i<arrSH.size(); i++)
{
if(arrSH.get(i) != arrOUTsh[i])
{
n = "Generate Gap Sequence General Method (SHELL)";
arrOfProblems.add(n);
}
}
//experiment step 2
ArrayList<Integer> arrKN = GapSeqGenerator.genKnuthGapSeq(arraySize);
//testing case 2
for(int i=0; i<arrKN.size(); i++)
{
if(arrKN.get(i) != arrOUTkn[i])
{
n = "Generate Gap Sequence General Method (SHELL)";
arrOfProblems.add(n);
}
}
//experiment step 3
ArrayList<Integer> arrTO = GapSeqGenerator.genTokudaGapSeq(arraySize);
//testing case 3
for(int i=0; i<arrTO.size(); i++)
{
if(arrTO.get(i) != arrOUTto[i])
{
n = "Generate Gap Sequence General Method (SHELL)";
arrOfProblems.add(n);
}
}
return arrOfProblems;
}
/*
* Runs all of the unit tests in this class
*/
public static void TestGapSeqGen()
{
ArrayList<String> whatTests = new ArrayList<String>();
String Testname = "Gap Sequence Generator";
whatTests.add(TestGenShellGapSeq());
whatTests.add(TestGenKnuthGapSeq());
whatTests.add(TestGenTokudaGapSeq());
ArrayList<String> g = TestGenerateGapSeq();
if(!g.isEmpty())
{
for(int i=0; i<g.size(); i++)
{
if(!g.get(i).equals(""))
{
whatTests.add(g.get(i));
}
}
}
boolean isCorrect = testIfFalse(whatTests);
FileIOUnitTestMenu.displayUnitTestResults(isCorrect, Testname, whatTests);
}
private static boolean testIfFalse(ArrayList<String> whatTests)
{
for(int i=0; i<whatTests.size(); i++)
{
if(!whatTests.get(i).equals(""))
{
return false;
}
}
return true;
}
}