1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.chabala.brick.controllab.sensor;
20
21 import org.junit.Test;
22
23 import static org.hamcrest.Matchers.is;
24 import static org.junit.Assert.*;
25
26
27
28
29 public class SensorValueTest {
30
31 @Test
32 public void testMinimumPossibleValues() throws Exception {
33 SensorValue value = SensorValue.newSensorValue((byte) 0b0, (byte) 0b0);
34 assertThat(value.getAnalogValue(), is(0));
35 assertThat(value.getStatusCode(), is(0));
36 }
37
38 @Test
39 public void testMaximumPossibleValues() throws Exception {
40 SensorValue value = SensorValue.newSensorValue((byte) 0b11111111, (byte) 0b11111111);
41 assertThat(value.getAnalogValue(), is(1023));
42 assertThat(value.getStatusCode(), is(63));
43 }
44
45 @Test
46 public void testValueSeparation() throws Exception {
47 SensorValue value = SensorValue.newSensorValue((byte) 0b11111111, (byte) 0b11000000);
48 assertThat(value.getAnalogValue(), is(1023));
49 assertThat(value.getStatusCode(), is(0));
50 }
51 }