summaryrefslogtreecommitdiff
path: root/test/compile_time_macros.c
diff options
context:
space:
mode:
authorCraig Hesling <hesling@chromium.org>2019-12-18 11:09:38 -0800
committerCommit Bot <commit-bot@chromium.org>2019-12-20 17:37:07 +0000
commitad349a691d18eb433686c748e67ad76374dd7a6e (patch)
treec834eebba360164d3c546110e37513cd5fcaf809 /test/compile_time_macros.c
parentf776a287369e4ac46b17eb9001f3b78621f87325 (diff)
downloadchrome-ec-ad349a691d18eb433686c748e67ad76374dd7a6e.tar.gz
test/compile_time_macros: Add BIT and BIT_ULL
This is really just for completeness. BRANCH=all BUG=none TEST=make buildall TEST=make run-compile_time_macros Change-Id: I8f0166ce502b310d9491fd83cde31072ee2530ef Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1974550 Tested-by: Craig Hesling <hesling@chromium.org> Auto-Submit: Craig Hesling <hesling@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'test/compile_time_macros.c')
-rw-r--r--test/compile_time_macros.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/compile_time_macros.c b/test/compile_time_macros.c
index 28e7af500b..9ef52bc7e3 100644
--- a/test/compile_time_macros.c
+++ b/test/compile_time_macros.c
@@ -9,6 +9,25 @@
#include "test_util.h"
+static int test_BIT(void)
+{
+ TEST_EQ(BIT(0), 0x00000001U, "%u");
+ TEST_EQ(BIT(25), 0x02000000U, "%u");
+ TEST_EQ(BIT(31), 0x80000000U, "%u");
+
+ return EC_SUCCESS;
+}
+
+static int test_BIT_ULL(void)
+{
+ TEST_EQ(BIT_ULL(0), 0x0000000000000001ULL, "%Lu");
+ TEST_EQ(BIT_ULL(25), 0x0000000002000000ULL, "%Lu");
+ TEST_EQ(BIT_ULL(50), 0x0004000000000000ULL, "%Lu");
+ TEST_EQ(BIT_ULL(63), 0x8000000000000000ULL, "%Lu");
+
+ return EC_SUCCESS;
+}
+
static int test_GENMASK(void)
{
TEST_EQ(GENMASK(0, 0), 0x00000001U, "%u");
@@ -40,6 +59,8 @@ void run_test(void)
{
test_reset();
+ RUN_TEST(test_BIT);
+ RUN_TEST(test_BIT_ULL);
RUN_TEST(test_GENMASK);
RUN_TEST(test_GENMASK_ULL);