-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFloatSubtractionTest.java
More file actions
54 lines (44 loc) · 1.47 KB
/
FloatSubtractionTest.java
File metadata and controls
54 lines (44 loc) · 1.47 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
import static org.junit.Assert.*;
import java.util.Arrays;
import java.util.Collection;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.Timeout;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
@RunWith(Parameterized.class)
public class FloatSubtractionTest {
@Rule
public TestLogger tl = new TestLogger();
@Rule
public Timeout globalTimeout = Timeout.seconds(10);
@Parameters
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][] {
{"001100000", "000000000", 4, 4, 4, "0001100000"},
{"100000000", "001100000", 4, 4, 4, "0101100000"},
{"001100000", "001100000", 4, 4, 4, "0000000000"},
{"00111111010100000", "00111111001000000", 8, 8, 8, "000111110010000000"},
});
}
private ALU alu = new ALU();
private String operand1;
private String operand2;
private int eLength;
private int sLength;
private int gLength;
private String expected;
public FloatSubtractionTest(String operand1, String operand2, int eLength, int sLength, int gLength, String expected) {
this.operand1 = operand1;
this.operand2 = operand2;
this.eLength = eLength;
this.sLength = sLength;
this.gLength = gLength;
this.expected = expected;
}
@Test
public void test() {
assertEquals(expected, alu.floatSubtraction(operand1, operand2, eLength, sLength, gLength));
}
}