Run clang-format and enable CI check for it (#755)
* pre-commit: Update and enable clang-format check There is newer version from clang-format so use that. We do not yet want 18 as that is little bit too new. * Format some thing by hand which clang-format "breaks" Clang-format will format some things little bit off in some cases. Format some things by hand so we get cleaner end result. * Run clang-format with ``` pre-commit run --all-files clang-format ``` We have already in previously checked places where clang-format does not make good format and ignored those (hopefully most of the things). --------- Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
|
||||
#include <zephyr/ztest.h>
|
||||
|
||||
#undef BIT
|
||||
@@ -20,7 +19,6 @@
|
||||
|
||||
#include "bacnet/basic/sys/bits.h"
|
||||
|
||||
|
||||
/* NOTE: These tests must be compatible with C90, so they do not
|
||||
* verify support for ULL.
|
||||
*/
|
||||
@@ -34,7 +32,7 @@ static void test_BIT(void)
|
||||
unsigned int bitpos = sizeof(unsigned int) * 8;
|
||||
|
||||
do {
|
||||
bitpos -= 1;
|
||||
bitpos -= 1;
|
||||
zassert_true(BIT(bitpos) == (1U << bitpos), NULL);
|
||||
} while (bitpos > 0);
|
||||
}
|
||||
@@ -48,7 +46,7 @@ static void test__BV(void)
|
||||
unsigned int bitpos = sizeof(unsigned int) * 8;
|
||||
|
||||
do {
|
||||
bitpos -= 1;
|
||||
bitpos -= 1;
|
||||
zassert_true(BIT(bitpos) == (1U << bitpos), NULL);
|
||||
} while (bitpos > 0);
|
||||
}
|
||||
@@ -63,8 +61,8 @@ static void test_BIT_SET(void)
|
||||
|
||||
do {
|
||||
unsigned int a = 0U;
|
||||
bitpos -= 1;
|
||||
BIT_SET(a, bitpos);
|
||||
bitpos -= 1;
|
||||
BIT_SET(a, bitpos);
|
||||
zassert_true(a == (1U << bitpos), NULL);
|
||||
} while (bitpos > 0);
|
||||
}
|
||||
@@ -79,8 +77,8 @@ static void test_BIT_CLEAR(void)
|
||||
|
||||
do {
|
||||
unsigned int a = ~0U;
|
||||
bitpos -= 1;
|
||||
BIT_CLEAR(a, bitpos);
|
||||
bitpos -= 1;
|
||||
BIT_CLEAR(a, bitpos);
|
||||
zassert_true(~(a) == (1U << bitpos), NULL);
|
||||
} while (bitpos > 0);
|
||||
}
|
||||
@@ -95,16 +93,16 @@ static void test_BIT_FLIP(void)
|
||||
|
||||
do {
|
||||
unsigned int a = ~0U;
|
||||
bitpos -= 1;
|
||||
BIT_FLIP(a, bitpos);
|
||||
bitpos -= 1;
|
||||
BIT_FLIP(a, bitpos);
|
||||
zassert_true(a == ~(1U << bitpos), NULL);
|
||||
BIT_FLIP(a, bitpos);
|
||||
BIT_FLIP(a, bitpos);
|
||||
zassert_true(a == ~0U, NULL);
|
||||
|
||||
a = 0U;
|
||||
BIT_FLIP(a, bitpos);
|
||||
a = 0U;
|
||||
BIT_FLIP(a, bitpos);
|
||||
zassert_true(a == (1U << bitpos), NULL);
|
||||
BIT_FLIP(a, bitpos);
|
||||
BIT_FLIP(a, bitpos);
|
||||
zassert_true(a == 0U, NULL);
|
||||
|
||||
} while (bitpos > 0);
|
||||
@@ -120,11 +118,11 @@ static void test_BIT_CHECK(void)
|
||||
|
||||
do {
|
||||
unsigned int a = ~0U;
|
||||
bitpos -= 1;
|
||||
zassert_true(BIT_CHECK(a, bitpos), NULL);
|
||||
bitpos -= 1;
|
||||
zassert_true(BIT_CHECK(a, bitpos), NULL);
|
||||
|
||||
a = 0U;
|
||||
zassert_false(BIT_CHECK(a, bitpos), NULL);
|
||||
a = 0U;
|
||||
zassert_false(BIT_CHECK(a, bitpos), NULL);
|
||||
|
||||
} while (bitpos > 0);
|
||||
}
|
||||
@@ -139,8 +137,8 @@ static void test_BITMASK_SET(void)
|
||||
|
||||
do {
|
||||
unsigned int a = 0U;
|
||||
bitpos -= 1;
|
||||
BITMASK_SET(a, (1U << bitpos));
|
||||
bitpos -= 1;
|
||||
BITMASK_SET(a, (1U << bitpos));
|
||||
zassert_true(a == (1U << bitpos), NULL);
|
||||
} while (bitpos > 0);
|
||||
}
|
||||
@@ -155,8 +153,8 @@ static void test_BITMASK_CLEAR(void)
|
||||
|
||||
do {
|
||||
unsigned int a = ~0U;
|
||||
bitpos -= 1;
|
||||
BITMASK_CLEAR(a, (1U << bitpos));
|
||||
bitpos -= 1;
|
||||
BITMASK_CLEAR(a, (1U << bitpos));
|
||||
zassert_true(~(a) == (1U << bitpos), NULL);
|
||||
} while (bitpos > 0);
|
||||
}
|
||||
@@ -171,16 +169,16 @@ static void test_BITMASK_FLIP(void)
|
||||
|
||||
do {
|
||||
unsigned int a = ~0U;
|
||||
bitpos -= 1;
|
||||
BITMASK_FLIP(a, (1U << bitpos));
|
||||
bitpos -= 1;
|
||||
BITMASK_FLIP(a, (1U << bitpos));
|
||||
zassert_true(a == ~(1U << bitpos), NULL);
|
||||
BITMASK_FLIP(a, (1U << bitpos));
|
||||
BITMASK_FLIP(a, (1U << bitpos));
|
||||
zassert_true(a == ~0U, NULL);
|
||||
|
||||
a = 0U;
|
||||
BITMASK_FLIP(a, (1U << bitpos));
|
||||
a = 0U;
|
||||
BITMASK_FLIP(a, (1U << bitpos));
|
||||
zassert_true(a == (1U << bitpos), NULL);
|
||||
BITMASK_FLIP(a, (1U << bitpos));
|
||||
BITMASK_FLIP(a, (1U << bitpos));
|
||||
zassert_true(a == 0U, NULL);
|
||||
|
||||
} while (bitpos > 0);
|
||||
@@ -196,11 +194,11 @@ static void test_BITMASK_CHECK(void)
|
||||
|
||||
do {
|
||||
unsigned int a = ~0U;
|
||||
bitpos -= 1;
|
||||
zassert_true(BITMASK_CHECK(a, (1U << bitpos)), NULL);
|
||||
bitpos -= 1;
|
||||
zassert_true(BITMASK_CHECK(a, (1U << bitpos)), NULL);
|
||||
|
||||
a = 0U;
|
||||
zassert_false(BITMASK_CHECK(a, (1U << bitpos)), NULL);
|
||||
a = 0U;
|
||||
zassert_false(BITMASK_CHECK(a, (1U << bitpos)), NULL);
|
||||
|
||||
} while (bitpos > 0);
|
||||
}
|
||||
@@ -210,18 +208,13 @@ ZTEST_SUITE(bacnet_bits, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(bacnet_bits,
|
||||
ztest_unit_test(test_BIT),
|
||||
ztest_unit_test(test__BV),
|
||||
ztest_unit_test(test_BIT_SET),
|
||||
ztest_unit_test(test_BIT_CLEAR),
|
||||
ztest_unit_test(test_BIT_FLIP),
|
||||
ztest_unit_test(test_BIT_CHECK),
|
||||
ztest_unit_test(test_BITMASK_SET),
|
||||
ztest_unit_test(test_BITMASK_CLEAR),
|
||||
ztest_unit_test(test_BITMASK_FLIP),
|
||||
ztest_unit_test(test_BITMASK_CHECK)
|
||||
);
|
||||
ztest_test_suite(
|
||||
bacnet_bits, ztest_unit_test(test_BIT), ztest_unit_test(test__BV),
|
||||
ztest_unit_test(test_BIT_SET), ztest_unit_test(test_BIT_CLEAR),
|
||||
ztest_unit_test(test_BIT_FLIP), ztest_unit_test(test_BIT_CHECK),
|
||||
ztest_unit_test(test_BITMASK_SET), ztest_unit_test(test_BITMASK_CLEAR),
|
||||
ztest_unit_test(test_BITMASK_FLIP),
|
||||
ztest_unit_test(test_BITMASK_CHECK));
|
||||
ztest_run_test_suite(bacnet_bits);
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user