Skip to content

Commit 6b3c887

Browse files
committed
Add a function under test (FUT) specification class.
Can be used to test Python functions with varying parameters in a loop.
1 parent e53c52c commit 6b3c887

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
package edu.cuny.hunter.hybridize.tests;
2+
3+
import java.util.List;
4+
import java.util.ArrayList;
5+
import java.util.Arrays;
6+
import java.util.Collections;
7+
import java.util.Objects;
8+
9+
/**
10+
* A specification of a Python function being tested.
11+
*
12+
* @author <a href="mailto:rk1424@hunter.cuny.edu">Raffi Khatchadourian</a>
13+
*/
14+
public class FunctionUnderTest {
15+
16+
/**
17+
* The simple name of this function under test.
18+
*/
19+
private String name;
20+
21+
/**
22+
* The names of the parameteres of this function under test.
23+
*/
24+
private List<String> parameters = new ArrayList<>();
25+
26+
/**
27+
* Whether this function under test should be a hybrid function.
28+
*/
29+
private boolean hybrid;
30+
31+
public FunctionUnderTest(String name) {
32+
this.name = name;
33+
}
34+
35+
public FunctionUnderTest(String name, boolean hybrid) {
36+
this(name);
37+
this.hybrid = hybrid;
38+
}
39+
40+
public boolean addParameters(String... parameter) {
41+
return this.parameters.addAll(Arrays.asList(parameter));
42+
}
43+
44+
public String getName() {
45+
return name;
46+
}
47+
48+
public List<String> getParameters() {
49+
return Collections.unmodifiableList(parameters);
50+
}
51+
52+
public boolean isHybrid() {
53+
return hybrid;
54+
}
55+
56+
@Override
57+
public int hashCode() {
58+
return Objects.hash(name, parameters, hybrid);
59+
}
60+
61+
@Override
62+
public boolean equals(Object obj) {
63+
if (this == obj)
64+
return true;
65+
if (obj == null)
66+
return false;
67+
if (getClass() != obj.getClass())
68+
return false;
69+
FunctionUnderTest other = (FunctionUnderTest) obj;
70+
return Objects.equals(name, other.name) && Objects.equals(parameters, other.parameters) && Objects.equals(hybrid, other.hybrid);
71+
}
72+
}

0 commit comments

Comments
 (0)