firmware  v0.1.2
Chromation Spectrometer Dev-Kit
test_ReadWriteBits.c
1 #include "unity.h"
2 #include "test_ReadWriteBits.h"
3 #include "ReadWriteBits.h"
4 void SetBit_sets_bit_in_register(void)
5 {
6  /* =====[ Setup ]===== */
7  uint8_t port = 0x00;
8  uint8_t bit = 0;
9  TEST_ASSERT_BIT_LOW_MESSAGE(
10  bit,
11  port,
12  "Cannot run test: must start with low bit in port!"
13  );
14  /* =====[ Operate ]===== */
15  SetBit(&port, bit);
16  TEST_ASSERT_BIT_HIGH(bit, port);
17 }
18 void ClearBit_clears_bit_in_register(void)
19 {
20  /* =====[ Setup ]===== */
21  uint8_t port = 0xFF;
22  uint8_t bit = 0;
23  TEST_ASSERT_BIT_HIGH_MESSAGE(
24  bit,
25  port,
26  "Cannot run test: must start with high bit in port!"
27  );
28  /* =====[ Operate ]===== */
29  ClearBit(&port, bit);
30  /* =====[ Test ]===== */
31  TEST_ASSERT_BIT_LOW(bit, port);
32 }
33 void BitIsSet_returns_true_if_bit_is_set(void)
34 {
35  /* =====[ Setup ]===== */
36  uint8_t port = 0x01;
37  uint8_t bit = 0;
38  /* =====[ Operate and Test ]===== */
39  TEST_ASSERT_TRUE(BitIsSet(&port, bit));
40 }
41 void BitIsSet_returns_false_if_bit_is_clear(void)
42 {
43  /* =====[ Setup ]===== */
44  uint8_t port = 0x00;
45  uint8_t bit = 0;
46  /* =====[ Operate and Test ]===== */
47  TEST_ASSERT_FALSE(BitIsSet(&port, bit));
48 }
49 void BitIsClear_returns_true_if_bit_is_clear(void)
50 {
51  /* =====[ Setup ]===== */
52  uint8_t port = 0xFE;
53  uint8_t bit = 0;
54  /* =====[ Operate and Test ]===== */
55  TEST_ASSERT_TRUE(BitIsClear(&port, bit));
56 }
57 void BitIsClear_returns_false_if_bit_is_set(void)
58 {
59  /* =====[ Setup ]===== */
60  uint8_t port = 0xFF;
61  uint8_t bit = 0;
62  /* =====[ Operate and Test ]===== */
63  TEST_ASSERT_FALSE(BitIsClear(&port, bit));
64 }
65