-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBitTest.java
More file actions
79 lines (71 loc) · 2.55 KB
/
BitTest.java
File metadata and controls
79 lines (71 loc) · 2.55 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
import org.junit.jupiter.api.Assertions;
class BitTest {
Bit t1, t2, f1, f2;
BitTest() {
t1 = new Bit(true);
t2 = new Bit(true);
f1 = new Bit(false);
f2 = new Bit(false);
}
private void stillOK() {
Assertions.assertEquals(Bit.boolValues.TRUE,t1.getValue());
Assertions.assertEquals(Bit.boolValues.TRUE,t2.getValue());
Assertions.assertEquals(Bit.boolValues.FALSE,f1.getValue());
Assertions.assertEquals(Bit.boolValues.FALSE,f2.getValue());
}
@org.junit.jupiter.api.Test
void testAnd() {
Bit result = new Bit(true);
t1.and(t2,result);
Assertions.assertEquals(Bit.boolValues.TRUE,result.getValue());
f1.and(t2,result);
Assertions.assertEquals(Bit.boolValues.FALSE,result.getValue());
t1.and(f2,result);
Assertions.assertEquals(Bit.boolValues.FALSE,result.getValue());
f1.and(f2,result);
Assertions.assertEquals(Bit.boolValues.FALSE,result.getValue());
stillOK();
}
@org.junit.jupiter.api.Test
void testOr() {
Bit result = new Bit(true);
t1.or(t2,result);
Assertions.assertEquals(Bit.boolValues.TRUE,result.getValue());
f1.or(t2,result);
Assertions.assertEquals(Bit.boolValues.TRUE,result.getValue());
t1.or(f2,result);
Assertions.assertEquals(Bit.boolValues.TRUE,result.getValue());
f1.or(f2,result);
Assertions.assertEquals(Bit.boolValues.FALSE,result.getValue());
stillOK();
}
@org.junit.jupiter.api.Test
void testXor() {
Bit result = new Bit(true);
t1.xor(t2,result);
Assertions.assertEquals(Bit.boolValues.FALSE,result.getValue());
f1.xor(t2,result);
Assertions.assertEquals(Bit.boolValues.TRUE,result.getValue());
t1.xor(f2,result);
Assertions.assertEquals(Bit.boolValues.TRUE,result.getValue());
f1.xor(f2,result);
Assertions.assertEquals(Bit.boolValues.FALSE,result.getValue());
stillOK();
}
@org.junit.jupiter.api.Test
void testNot() {
Bit result = new Bit(true);
t1.not(result);
Assertions.assertEquals(Bit.boolValues.FALSE,result.getValue());
f1.not(result);
Assertions.assertEquals(Bit.boolValues.TRUE,result.getValue());
stillOK();
}
@org.junit.jupiter.api.Test
void testToString() {
Bit result = new Bit(true);
Assertions.assertEquals("t",result.toString());
Bit f = new Bit(false);
Assertions.assertEquals("f",f.toString());
}
}