-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWs3PublicTestsEx4.java
More file actions
89 lines (62 loc) · 2.07 KB
/
Ws3PublicTestsEx4.java
File metadata and controls
89 lines (62 loc) · 2.07 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
import static org.junit.Assert.*;
import org.junit.Test;
/**
* @author Alexandros Evangelidis
* 6 tests to test the Parity.addParity method.
*/
public class Ws3PublicTestsEx4 {
@Test
public void test1() {
int[][] test1 = {{0,1,1,1,0},
{1,0,0,0,1},
{1,0,1,0,1}};
//expected array after adding parity bits
int [][] expected = {{0, 1, 1, 1, 0, 1},
{1, 0, 0, 0, 1, 0},
{1, 0, 1, 0, 1, 1},
{0, 1, 0, 1, 0, 0}};
int [][] actual = Parity.addParity(test1);
assertArrayEquals(expected, actual);
}
@Test
public void test2() {
int[][] test1 = {{0,1,1,1,0},
{1,0,0,0,1},
{1,0,1,0,1}};
assertFalse(Parity.checkParity(test1));
}
@Test
public void test3() {
int[][] test1 = {{0,1,1,1,0},
{1,0,0,0,1},
{1,0,1,0,1}};
assertTrue(Parity.checkParity(Parity.addParity(test1)));
}
@Test
public void test4() {
int[][] test4 = {{1,1,1,1,1},
{1,1,1,1,1},
{1,1,1,1,0}};
//expected array after adding parity bits
int [][] expected = {{1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 0, 0},
{1, 1, 1, 1, 0, 0}};
int [][] actual = Parity.addParity(test4);
assertArrayEquals(expected, actual);
}
@Test
public void test5() {
int[][] test4 = {{1,1,1,1,1},
{1,1,1,1,1},
{1,1,1,1,0}};
assertFalse(Parity.checkParity(test4));
}
@Test
public void test6() {
int[][] test4 = {{1,1,1,1,1},
{1,1,1,1,1},
{1,1,1,1,0}};
assertTrue( Parity.checkParity(Parity.addParity(test4)));
}
}