1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.chabala.brick.controllab;
20
21 import org.junit.Test;
22
23 import java.util.HashSet;
24 import java.util.Set;
25
26 import static org.hamcrest.Matchers.arrayWithSize;
27 import static org.hamcrest.Matchers.hasSize;
28 import static org.hamcrest.Matchers.is;
29 import static org.junit.Assert.*;
30
31
32
33
34 public class PowerLevelTest {
35
36 @Test
37 public void testPowerLevelZeroHasCorrectCode() throws Exception {
38 assertThat(PowerLevel.P0.getCode(), is((byte) 0b10010010));
39 }
40
41 @Test
42 public void testPowerLevelOneHasCorrectCode() throws Exception {
43 assertThat(PowerLevel.P1.getCode(), is((byte) 0b10110000));
44 }
45
46 @Test
47 public void testPowerLevelEightHasCorrectCode() throws Exception {
48 assertThat(PowerLevel.P8.getCode(), is((byte) 0b10110111));
49 }
50
51 @Test
52 public void testThereAreNinePowerLevels() throws Exception {
53 assertThat(PowerLevel.values(), arrayWithSize(9));
54 }
55
56 @Test
57 public void testEveryPowerLevelHasAUniqueCode() throws Exception {
58 Set<Byte> codes = new HashSet<>();
59 for (PowerLevel p : PowerLevel.values()) {
60 codes.add(p.getCode());
61 }
62 assertThat(codes, hasSize(PowerLevel.values().length));
63 }
64 }