Strip tabs and trailing white spaces, and fix end of files (#748)
* format: Strip trailing whitespaces
We want to get rid of trailing whitespaces completly as they make just git
noice. Much better to start using automated tools to get rid of them once and
not getting them back again. This way git history will be cleaner and review
easier.
Commit was generated with:
pre-commit run --all-files trailing-whitespace
* format: Files should have exactly one new line end of them
It is good practice that every file has one new line. It is not now days so
mandatory but it also is not nice if file has lot of newlines end of it. We will
use pre-commit which takes automatically care about this so let's fix all.
Commit was generated with:
pre-commit run --all-files end-of-file-fixer
* format: Convert tabs to spaces
Project mostly use spaces over tabs. When mixing tabs and spaces this usually
makes formatting issues and also when changing those in commits it will make lot
of git noise. We will force spaces most of the time and use pre-commit to fix.
Commit was generated with:
pre-commit run --all-files remove-tabs
---------
Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
This commit is contained in:
@@ -4,8 +4,8 @@ cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
|
||||
|
||||
get_filename_component(basename ${CMAKE_CURRENT_SOURCE_DIR} NAME)
|
||||
project(unittest_${basename}
|
||||
VERSION 1.0.0
|
||||
LANGUAGES C)
|
||||
VERSION 1.0.0
|
||||
LANGUAGES C)
|
||||
|
||||
|
||||
string(REGEX REPLACE
|
||||
@@ -21,23 +21,23 @@ string(REGEX REPLACE
|
||||
set(ZTST_DIR "${TST_DIR}/ztest/src")
|
||||
|
||||
add_compile_definitions(
|
||||
BIG_ENDIAN=0
|
||||
CONFIG_ZTEST=1
|
||||
)
|
||||
BIG_ENDIAN=0
|
||||
CONFIG_ZTEST=1
|
||||
)
|
||||
|
||||
include_directories(
|
||||
./src
|
||||
${SRC_DIR}
|
||||
${TST_DIR}/ztest/include
|
||||
)
|
||||
./src
|
||||
${SRC_DIR}
|
||||
${TST_DIR}/ztest/include
|
||||
)
|
||||
|
||||
add_executable(${PROJECT_NAME}
|
||||
# File(s) under test
|
||||
${SRC_DIR}/bacnet/bacerror.c
|
||||
${SRC_DIR}/bacnet/bacerror.c
|
||||
# Support files and stubs (pathname alphabetical)
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
./src/fakes/bacdcode.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
${ZTST_DIR}/ztest.c
|
||||
)
|
||||
./src/main.c
|
||||
./src/fakes/bacdcode.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
${ZTST_DIR}/ztest.c
|
||||
)
|
||||
|
||||
@@ -4,8 +4,8 @@ cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
|
||||
|
||||
get_filename_component(basename ${CMAKE_CURRENT_SOURCE_DIR} NAME)
|
||||
project(test_${basename}
|
||||
VERSION 1.0.0
|
||||
LANGUAGES C)
|
||||
VERSION 1.0.0
|
||||
LANGUAGES C)
|
||||
|
||||
|
||||
string(REGEX REPLACE
|
||||
@@ -21,21 +21,21 @@ string(REGEX REPLACE
|
||||
set(ZTST_DIR "${TST_DIR}/ztest/src")
|
||||
|
||||
add_compile_definitions(
|
||||
BIG_ENDIAN=0
|
||||
CONFIG_ZTEST=1
|
||||
)
|
||||
BIG_ENDIAN=0
|
||||
CONFIG_ZTEST=1
|
||||
)
|
||||
|
||||
include_directories(
|
||||
${SRC_DIR}
|
||||
${TST_DIR}/ztest/include
|
||||
)
|
||||
${SRC_DIR}
|
||||
${TST_DIR}/ztest/include
|
||||
)
|
||||
|
||||
add_executable(${PROJECT_NAME}
|
||||
# File(s) under test
|
||||
# NOTE: bits.h contains the complete implementation of the API.
|
||||
# Support files and stubs (pathname alphabetical)
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
${ZTST_DIR}/ztest.c
|
||||
)
|
||||
./src/main.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
${ZTST_DIR}/ztest.c
|
||||
)
|
||||
|
||||
@@ -4,8 +4,8 @@ cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
|
||||
|
||||
get_filename_component(basename ${CMAKE_CURRENT_SOURCE_DIR} NAME)
|
||||
project(test_${basename}
|
||||
VERSION 1.0.0
|
||||
LANGUAGES C)
|
||||
VERSION 1.0.0
|
||||
LANGUAGES C)
|
||||
|
||||
|
||||
string(REGEX REPLACE
|
||||
@@ -21,21 +21,21 @@ string(REGEX REPLACE
|
||||
set(ZTST_DIR "${TST_DIR}/ztest/src")
|
||||
|
||||
add_compile_definitions(
|
||||
BIG_ENDIAN=0
|
||||
CONFIG_ZTEST=1
|
||||
)
|
||||
BIG_ENDIAN=0
|
||||
CONFIG_ZTEST=1
|
||||
)
|
||||
|
||||
include_directories(
|
||||
${SRC_DIR}
|
||||
${TST_DIR}/ztest/include
|
||||
)
|
||||
${SRC_DIR}
|
||||
${TST_DIR}/ztest/include
|
||||
)
|
||||
|
||||
add_executable(${PROJECT_NAME}
|
||||
# File(s) under test
|
||||
# NOTE: bits.h contains the complete implementation of the API.
|
||||
# Support files and stubs (pathname alphabetical)
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
${ZTST_DIR}/ztest.c
|
||||
)
|
||||
./src/main.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
${ZTST_DIR}/ztest.c
|
||||
)
|
||||
|
||||
@@ -34,7 +34,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 +48,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 +63,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 +79,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,18 +95,18 @@ 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,12 +120,12 @@ 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 +139,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 +155,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,18 +171,18 @@ 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,12 +196,12 @@ 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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user