Added AlignAfterOpenBracket: AlwaysBreak and BinPackArguments: true to clang-format. Updated test/bacnet c/h files with updated format.

This commit is contained in:
Steve Karg
2024-04-24 09:38:12 -05:00
parent 1aaebe9414
commit 70c54817fd
120 changed files with 2182 additions and 1894 deletions
+34 -21
View File
@@ -21,7 +21,7 @@
/**
* @brief compare two floating point values to 3 decimal places
*
*
* @param x1 - first comparison value
* @param x2 - second comparison value
* @return true if the value is the same to 3 decimal points
@@ -34,7 +34,8 @@ static bool is_float_equal(float x1, float x2)
/**
* Unit Test for sRGB to CIE xy
*/
static void test_color_rgb_xy_gamma_unit(uint8_t red,
static void test_color_rgb_xy_gamma_unit(
uint8_t red,
uint8_t green,
uint8_t blue,
float x_coordinate,
@@ -46,22 +47,28 @@ static void test_color_rgb_xy_gamma_unit(uint8_t red,
uint8_t test_red = 0, test_green = 0, test_blue = 0;
/* functions with gamma correction */
color_rgb_to_xy_gamma(red, green, blue, &test_x_coordinate,
&test_y_coordinate, &test_brightness);
color_rgb_from_xy_gamma(&test_red, &test_green, &test_blue, x_coordinate,
y_coordinate, brightness);
zassert_true(is_float_equal(x_coordinate, test_x_coordinate),
"(x=%.3f,test_x=%.3f)", x_coordinate, test_x_coordinate);
zassert_true(is_float_equal(y_coordinate, test_y_coordinate),
"(y=%.3f,test_y=%.3f)", y_coordinate, test_y_coordinate);
zassert_equal(brightness, test_brightness, "b=%u, test_b=%u", brightness,
color_rgb_to_xy_gamma(
red, green, blue, &test_x_coordinate, &test_y_coordinate,
&test_brightness);
color_rgb_from_xy_gamma(
&test_red, &test_green, &test_blue, x_coordinate, y_coordinate,
brightness);
zassert_true(
is_float_equal(x_coordinate, test_x_coordinate), "(x=%.3f,test_x=%.3f)",
x_coordinate, test_x_coordinate);
zassert_true(
is_float_equal(y_coordinate, test_y_coordinate), "(y=%.3f,test_y=%.3f)",
y_coordinate, test_y_coordinate);
zassert_equal(
brightness, test_brightness, "b=%u, test_b=%u", brightness,
test_brightness);
}
/**
* Unit Test for sRGB to CIE xy
*/
static void test_color_rgb_xy_unit(uint8_t red,
static void test_color_rgb_xy_unit(
uint8_t red,
uint8_t green,
uint8_t blue,
float x_coordinate,
@@ -72,15 +79,20 @@ static void test_color_rgb_xy_unit(uint8_t red,
uint8_t test_brightness = 0;
uint8_t test_red = 0, test_green = 0, test_blue = 0;
color_rgb_to_xy(red, green, blue, &test_x_coordinate, &test_y_coordinate,
color_rgb_to_xy(
red, green, blue, &test_x_coordinate, &test_y_coordinate,
&test_brightness);
color_rgb_from_xy(&test_red, &test_green, &test_blue, x_coordinate,
y_coordinate, brightness);
zassert_true(is_float_equal(x_coordinate, test_x_coordinate),
"(x=%.3f,test_x=%.3f)", x_coordinate, test_x_coordinate);
zassert_true(is_float_equal(y_coordinate, test_y_coordinate),
"(y=%.3f,test_y=%.3f)", y_coordinate, test_y_coordinate);
zassert_equal(brightness, test_brightness, "b=%u, test_b=%u", brightness,
color_rgb_from_xy(
&test_red, &test_green, &test_blue, x_coordinate, y_coordinate,
brightness);
zassert_true(
is_float_equal(x_coordinate, test_x_coordinate), "(x=%.3f,test_x=%.3f)",
x_coordinate, test_x_coordinate);
zassert_true(
is_float_equal(y_coordinate, test_y_coordinate), "(y=%.3f,test_y=%.3f)",
y_coordinate, test_y_coordinate);
zassert_equal(
brightness, test_brightness, "b=%u, test_b=%u", brightness,
test_brightness);
}
@@ -166,7 +178,8 @@ ZTEST_SUITE(color_rgb_tests, NULL, NULL, NULL, NULL, NULL);
#else
void test_main(void)
{
ztest_test_suite(color_rgb_tests, ztest_unit_test(test_color_rgb_ascii),
ztest_test_suite(
color_rgb_tests, ztest_unit_test(test_color_rgb_ascii),
ztest_unit_test(test_color_rgb_xy));
ztest_run_test_suite(color_rgb_tests);
+19 -29
View File
@@ -17,13 +17,10 @@
*/
/**
* Unit Test for the days, checking the epoch conversion
*/
* Unit Test for the days, checking the epoch conversion
*/
static void test_epoch_conversion_date(
uint16_t epoch_year,
uint16_t year,
uint8_t month,
uint8_t day)
uint16_t epoch_year, uint16_t year, uint8_t month, uint8_t day)
{
uint32_t days;
uint16_t test_year;
@@ -32,8 +29,8 @@ static void test_epoch_conversion_date(
/* conversions of day and date */
days = days_since_epoch(epoch_year, year, month, day);
days_since_epoch_to_date(epoch_year, days, &test_year, &test_month,
&test_day);
days_since_epoch_to_date(
epoch_year, days, &test_year, &test_month, &test_day);
zassert_equal(year, test_year, NULL);
zassert_equal(month, test_month, NULL);
zassert_equal(day, test_day, NULL);
@@ -61,15 +58,12 @@ static void test_days_epoch_conversion(void)
* Unit Test for the days and year to month date year
*/
static void test_days_of_year_to_month_day_date(
uint16_t year,
uint16_t days,
uint8_t month,
uint8_t day)
uint16_t year, uint16_t days, uint8_t month, uint8_t day)
{
uint8_t test_month = 0;
uint8_t test_day = 0;
/* conversions of days and year */
days_of_year_to_month_day(days , year, &test_month, &test_day);
days_of_year_to_month_day(days, year, &test_month, &test_day);
zassert_equal(month, test_month, NULL);
zassert_equal(day, test_day, NULL);
}
@@ -91,11 +85,9 @@ static void test_days_of_year_to_md(void)
}
/**
* Unit Test for the days, checking the date to see if it is a valid day
*/
static void test_date_is_valid_day(
uint16_t year,
uint8_t month)
* Unit Test for the days, checking the date to see if it is a valid day
*/
static void test_date_is_valid_day(uint16_t year, uint8_t month)
{
uint8_t last_day = days_per_month(year, month);
@@ -107,8 +99,8 @@ static void test_date_is_valid_day(
}
/**
* Unit Test for the days, checking the date to see if it is a valid date
*/
* Unit Test for the days, checking the date to see if it is a valid date
*/
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST(days_tests, test_days_date_is_valid)
#else
@@ -143,8 +135,8 @@ static void test_days_date_is_valid(void)
}
/**
* Unit Test for days apart, checking the dates to see how many days apart
*/
* Unit Test for days apart, checking the dates to see how many days apart
*/
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST(days_tests, test_days_apart)
#else
@@ -163,18 +155,16 @@ static void test_days_apart(void)
* @}
*/
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST_SUITE(days_tests, NULL, NULL, NULL, NULL, NULL);
#else
void test_main(void)
{
ztest_test_suite(days_tests,
ztest_unit_test(test_days_epoch_conversion),
ztest_unit_test(test_days_of_year_to_md),
ztest_unit_test(test_days_date_is_valid),
ztest_unit_test(test_days_apart)
);
ztest_test_suite(
days_tests, ztest_unit_test(test_days_epoch_conversion),
ztest_unit_test(test_days_of_year_to_md),
ztest_unit_test(test_days_date_is_valid),
ztest_unit_test(test_days_apart));
ztest_run_test_suite(days_tests);
}
+3 -6
View File
@@ -138,8 +138,8 @@ static void testFIFOBuffer(void)
status = FIFO_Add(&test_buffer, add_data, sizeof(add_data));
zassert_true(status, NULL);
count = FIFO_Count(&test_buffer);
test_count = FIFO_Peek_Ahead(&test_buffer, &test_add_data[0], count-1);
zassert_equal(count-1, test_count, NULL);
test_count = FIFO_Peek_Ahead(&test_buffer, &test_add_data[0], count - 1);
zassert_equal(count - 1, test_count, NULL);
for (index = 0; index < test_count; index++) {
zassert_equal(test_add_data[index], add_data[index], NULL);
}
@@ -150,15 +150,12 @@ static void testFIFOBuffer(void)
* @}
*/
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST_SUITE(fifo_tests, NULL, NULL, NULL, NULL, NULL);
#else
void test_main(void)
{
ztest_test_suite(fifo_tests,
ztest_unit_test(testFIFOBuffer)
);
ztest_test_suite(fifo_tests, ztest_unit_test(testFIFOBuffer));
ztest_run_test_suite(fifo_tests);
}
+1 -4
View File
@@ -49,15 +49,12 @@ static void testFilename(void)
* @}
*/
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST_SUITE(filename_tests, NULL, NULL, NULL, NULL, NULL);
#else
void test_main(void)
{
ztest_test_suite(filename_tests,
ztest_unit_test(testFilename)
);
ztest_test_suite(filename_tests, ztest_unit_test(testFilename));
ztest_run_test_suite(filename_tests);
}
+5 -9
View File
@@ -349,20 +349,16 @@ static void testKeySample(void)
* @}
*/
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST_SUITE(keylist_tests, NULL, NULL, NULL, NULL, NULL);
#else
void test_main(void)
{
ztest_test_suite(keylist_tests,
ztest_unit_test(testKeyListFIFO),
ztest_unit_test(testKeyListFILO),
ztest_unit_test(testKeyListDataKey),
ztest_unit_test(testKeyListDataIndex),
ztest_unit_test(testKeyListLarge),
ztest_unit_test(testKeySample)
);
ztest_test_suite(
keylist_tests, ztest_unit_test(testKeyListFIFO),
ztest_unit_test(testKeyListFILO), ztest_unit_test(testKeyListDataKey),
ztest_unit_test(testKeyListDataIndex),
ztest_unit_test(testKeyListLarge), ztest_unit_test(testKeySample));
ztest_run_test_suite(keylist_tests);
}
+8 -9
View File
@@ -17,8 +17,8 @@
*/
/**
* Unit Test for linear interpolation of floating point values, rounded
*/
* Unit Test for linear interpolation of floating point values, rounded
*/
void testLinearInterpolateRound(void)
{
uint16_t x2 = 0;
@@ -82,8 +82,8 @@ void testLinearInterpolateRound(void)
}
/**
* Unit Test for linear interpolation of integers
*/
* Unit Test for linear interpolation of integers
*/
void testLinearInterpolateInt(void)
{
uint16_t y2 = 0;
@@ -103,7 +103,7 @@ void testLinearInterpolateInt(void)
y2 = linear_interpolate_int(1, (65535 / 2), 65535, 1, 100);
zassert_equal(y2, 50, NULL);
y2 = linear_interpolate_int(1, ((65535 * 3) / 4), 65535, 1, 100);
zassert_equal(y2, 75, NULL);
@@ -126,10 +126,9 @@ ZTEST_SUITE(Linear_Interpolate, NULL, NULL, NULL, NULL, NULL);
#else
void test_main(void)
{
ztest_test_suite(Linear_Interpolate,
ztest_unit_test(testLinearInterpolateRound),
ztest_unit_test(testLinearInterpolateInt)
);
ztest_test_suite(
Linear_Interpolate, ztest_unit_test(testLinearInterpolateRound),
ztest_unit_test(testLinearInterpolateInt));
ztest_run_test_suite(Linear_Interpolate);
}
+18 -16
View File
@@ -175,7 +175,8 @@ static void testRingBufSizeSmall(void)
uint8_t data_element[5];
uint8_t data_store[sizeof(data_element) * NEXT_POWER_OF_2(16)];
testRingBuf(data_store, data_element, sizeof(data_element),
testRingBuf(
data_store, data_element, sizeof(data_element),
sizeof(data_store) / sizeof(data_element));
}
@@ -191,7 +192,8 @@ static void testRingBufSizeLarge(void)
uint8_t data_element[16];
uint8_t data_store[sizeof(data_element) * NEXT_POWER_OF_2(99)];
testRingBuf(data_store, data_element, sizeof(data_element),
testRingBuf(
data_store, data_element, sizeof(data_element),
sizeof(data_store) / sizeof(data_element));
}
@@ -208,10 +210,11 @@ static void testRingBufSizeInvalid(void)
uint8_t data_element[16];
uint8_t data_store[sizeof(data_element) * 99];
zassert_false(Ringbuf_Init(&test_buffer,
data_store, sizeof(data_element),
sizeof(data_store) / sizeof(data_element)),
NULL);
zassert_false(
Ringbuf_Init(
&test_buffer, data_store, sizeof(data_element),
sizeof(data_store) / sizeof(data_element)),
NULL);
}
#if defined(CONFIG_ZTEST_NEW_API)
@@ -344,27 +347,26 @@ static void testRingBufNextElementSizeSmall(void)
uint8_t data_element[5];
uint8_t data_store[sizeof(data_element) * NEXT_POWER_OF_2(16)];
status = testRingBufNextElement(data_store, data_element,
sizeof(data_element), sizeof(data_store) / sizeof(data_element));
status = testRingBufNextElement(
data_store, data_element, sizeof(data_element),
sizeof(data_store) / sizeof(data_element));
zassert_true(status, NULL);
}
/**
* @}
*/
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST_SUITE(ringbuf_tests, NULL, NULL, NULL, NULL, NULL);
#else
void test_main(void)
{
ztest_test_suite(ringbuf_tests,
ztest_unit_test(testRingBufPowerOfTwo),
ztest_unit_test(testRingBufSizeSmall),
ztest_unit_test(testRingBufSizeLarge),
ztest_unit_test(testRingBufSizeInvalid),
ztest_unit_test(testRingBufNextElementSizeSmall)
);
ztest_test_suite(
ringbuf_tests, ztest_unit_test(testRingBufPowerOfTwo),
ztest_unit_test(testRingBufSizeSmall),
ztest_unit_test(testRingBufSizeLarge),
ztest_unit_test(testRingBufSizeInvalid),
ztest_unit_test(testRingBufNextElementSizeSmall));
ztest_run_test_suite(ringbuf_tests);
}
+1 -4
View File
@@ -78,15 +78,12 @@ static void testStaticBuffer(void)
* @}
*/
#if defined(CONFIG_ZTEST_NEW_API)
ZTEST_SUITE(sbuf_tests, NULL, NULL, NULL, NULL, NULL);
#else
void test_main(void)
{
ztest_test_suite(sbuf_tests,
ztest_unit_test(testStaticBuffer)
);
ztest_test_suite(sbuf_tests, ztest_unit_test(testStaticBuffer));
ztest_run_test_suite(sbuf_tests);
}