1 /*
2  * Copyright 2023 Meta
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include <limits.h>
8 
9 #include <zephyr/sys/util.h>
10 #include <zephyr/ztest.h>
11 
ZTEST(pot,test_IS_POWER_OF_TWO)12 ZTEST(pot, test_IS_POWER_OF_TWO)
13 {
14 	zassert_false(IS_POWER_OF_TWO(-1));
15 	zassert_false(IS_POWER_OF_TWO(0));
16 	zassert_true(IS_POWER_OF_TWO(1));
17 	zassert_true(IS_POWER_OF_TWO(2));
18 	zassert_false(IS_POWER_OF_TWO(3));
19 	zassert_true(IS_POWER_OF_TWO(4));
20 	zassert_true(IS_POWER_OF_TWO(BIT(30)));
21 	zassert_false(IS_POWER_OF_TWO(BIT(30) + 1));
22 	zassert_true(IS_POWER_OF_TWO(BIT64(32)));
23 	zassert_false(IS_POWER_OF_TWO(BIT64(32) + 1));
24 	zassert_true(IS_POWER_OF_TWO(BIT64(63)));
25 	zassert_false(IS_POWER_OF_TWO(BIT64(63) + 1));
26 	zassert_false(IS_POWER_OF_TWO(UINT64_MAX));
27 }
28