RKH
test_rkhfwk_bittbl.c
Go to the documentation of this file.
1 /*
2  * --------------------------------------------------------------------------
3  *
4  * Framework RKH
5  * -------------
6  *
7  * State-machine framework for reactive embedded systems
8  *
9  * Copyright (C) 2010 Leandro Francucci.
10  * All rights reserved. Protected by international copyright laws.
11  *
12  *
13  * RKH is free software: you can redistribute it and/or modify it under the
14  * terms of the GNU General Public License as published by the Free Software
15  * Foundation, either version 3 of the License, or (at your option) any
16  * later version.
17  *
18  * RKH is distributed in the hope that it will be useful, but WITHOUT ANY
19  * WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
21  * more details.
22  *
23  * You should have received a copy of the GNU General Public License along
24  * with RKH, see copying.txt file.
25  *
26  * Contact information:
27  * RKH site: http://vortexmakes.com/que-es/
28  * RKH GitHub: https://github.com/vortexmakes/RKH
29  * RKH Sourceforge: https://sourceforge.net/projects/rkh-reactivesys/
30  * e-mail: lf@vortexmakes.com
31  * ---------------------------------------------------------------------------
32  */
33 
46 /* -------------------------- Development history -------------------------- */
47 /*
48  * 2017.26.04 LeFr v2.4.05 ---
49  */
50 
51 /* -------------------------------- Authors -------------------------------- */
52 /*
53  * LeFr Leandro Francucci lf@vortexmakes.com
54  */
55 
56 /* --------------------------------- Notes --------------------------------- */
57 /* ----------------------------- Include files ----------------------------- */
58 #include "unity.h"
59 #include "rkhfwk_bittbl.h"
60 
61 /* ----------------------------- Local macros ------------------------------ */
62 /* ------------------------------- Constants ------------------------------- */
63 /* ---------------------------- Local data types --------------------------- */
64 /* ---------------------------- Global variables --------------------------- */
65 /* ---------------------------- Local variables ---------------------------- */
66 /* ----------------------- Local function prototypes ----------------------- */
67 /* ---------------------------- Local functions ---------------------------- */
68 /* ---------------------------- Global functions --------------------------- */
69 /* =========================== Bittbl test group =========================== */
70 void
71 setUp(void)
72 {
73 }
74 
75 void
76 tearDown(void)
77 {
78 }
79 
86 void
87 test_GetBitMask(void)
88 {
89  rui8_t bitPos = 5, result;
90  rui8_t expectedBitMask = (rui8_t)(1 << bitPos);
91 
92  result = rkh_bittbl_getBitMask(5);
93  TEST_ASSERT_EQUAL_HEX8(expectedBitMask, result);
94 }
95 
96 void
97 test_GetLeastSignificantBitPost(void)
98 {
99  rui8_t result, value;
100 
101  value = 0x38;
102  result = rkh_bittbl_getLeastBitSetPos(value);
103  TEST_ASSERT_EQUAL(3, result);
104 }
105 
106 void
107 test_InvalidBitPosition(void)
108 {
109  rui8_t result;
110 
111  result = rkh_bittbl_getBitMask(8);
112  TEST_ASSERT_EQUAL_HEX8(RKH_INVALID_BITPOS, result);
113 }
114 
120 /* ------------------------------ End of file ------------------------------ */
Specifies the interface of the mapping table manager to deal with native priority algorithm.
rui8_t rkh_bittbl_getLeastBitSetPos(rui8_t value)
Used to return the bit position of the least significant bit set - a number between 0 and 7 (from an ...
rui8_t rkh_bittbl_getBitMask(rui8_t bitPos)
Get the bit mask from a bit position (from an 8-bit value).