-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIntegerDivisionTest.java
More file actions
50 lines (40 loc) · 1.28 KB
/
IntegerDivisionTest.java
File metadata and controls
50 lines (40 loc) · 1.28 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
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 IntegerDivisionTest {
@Rule
public Timeout globalTimeout = Timeout.seconds(10);
@Parameters
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][] {
{"00000000", "0000", 8, "NaN"},
{"0100", "0011", 12, "0000000000001000000000001"},
{"0111", "0011", 4, "000100001"},
{"0111", "1101", 4, "011100001"},
{"0110", "1101", 4, "011100000"},
{"1010", "0011", 4, "011100000"},
});
}
private ALU alu = new ALU();
private String operand1;
private String operand2;
private int length;
private String expected;
public IntegerDivisionTest(String operand1, String operand2, int length, String expected) {
this.operand1 = operand1;
this.operand2 = operand2;
this.length = length;
this.expected = expected;
}
@Test
public void test() {
assertEquals(expected, alu.integerDivision(operand1, operand2, length));
}
}