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 web site: http://sourceforge.net/projects/rkh-reactivesys/
28  * e-mail: francuccilea@gmail.com
29  * ---------------------------------------------------------------------------
30  */
31 
44 /* -------------------------- Development history -------------------------- */
45 /*
46  * 2017.26.04 LeFr v2.4.05 ---
47  */
48 
49 /* -------------------------------- Authors -------------------------------- */
50 /*
51  * LeFr Leandro Francucci francuccilea@gmail.com
52  */
53 
54 /* --------------------------------- Notes --------------------------------- */
55 /* ----------------------------- Include files ----------------------------- */
56 #include "unity_fixture.h"
57 #include "rkhfwk_bittbl.h"
58 
59 /* ----------------------------- Local macros ------------------------------ */
60 /* ------------------------------- Constants ------------------------------- */
61 /* ---------------------------- Local data types --------------------------- */
62 /* ---------------------------- Global variables --------------------------- */
63 TEST_GROUP(bittbl);
64 
65 /* ---------------------------- Local variables ---------------------------- */
66 /* ----------------------- Local function prototypes ----------------------- */
67 /* ---------------------------- Local functions ---------------------------- */
68 /* ---------------------------- Global functions --------------------------- */
69 /* =========================== Bittbl test group =========================== */
70 TEST_SETUP(bittbl)
71 {
72 }
73 
74 TEST_TEAR_DOWN(bittbl)
75 {
76 }
77 
84 TEST(bittbl, GetBitMask)
85 {
86  rui8_t bitPos = 5, result;
87  rui8_t expectedBitMask = (rui8_t)(1 << bitPos);
88 
89  result = rkh_bittbl_getBitMask(5);
90  TEST_ASSERT_EQUAL_HEX8(expectedBitMask, result);
91 }
92 
93 TEST(bittbl, GetLeastSignificantBitPost)
94 {
95  rui8_t result, value;
96 
97  value = 0x38;
98  result = rkh_bittbl_getLeastBitSetPos(value);
99  TEST_ASSERT_EQUAL(3, result);
100 }
101 
102 TEST(bittbl, InvalidBitPosition)
103 {
104  rui8_t result;
105 
106  result = rkh_bittbl_getBitMask(8);
107  TEST_ASSERT_EQUAL_HEX8(RKH_INVALID_BITPOS, result);
108 }
109 
115 /* ------------------------------ End of file ------------------------------ */
Specifies the interface of the mapping table manager to deal with native priority algorithm...
rui8_t rkh_bittbl_getBitMask(rui8_t bitPos)
Get the bit mask from a bit position (from an 8-bit value).
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 ...