remove key.c from any projects. Add unit test from key.c to keylist. (#317)
Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
This commit is contained in:
@@ -10,7 +10,6 @@ CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g
|
||||
SRCS = main.c \
|
||||
$(SRC_DIR)/bacnet/basic/object/objects.c \
|
||||
$(SRC_DIR)/bacnet/basic/sys/keylist.c \
|
||||
$(SRC_DIR)/bacnet/basic/sys/key.c \
|
||||
$(TEST_DIR)/ctest.c
|
||||
|
||||
TARGET_NAME = unittest
|
||||
|
||||
@@ -284,6 +284,35 @@ static void testKeyListLarge(void)
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* test the encode and decode macros */
|
||||
static void testKeySample(void)
|
||||
{
|
||||
int type, id;
|
||||
int type_list[] = { 0, 1, KEY_TYPE_MAX / 2, KEY_TYPE_MAX - 1, -1 };
|
||||
int id_list[] = { 0, 1, KEY_ID_MAX / 2, KEY_ID_MAX - 1, -1 };
|
||||
int type_index = 0;
|
||||
int id_index = 0;
|
||||
int decoded_type, decoded_id;
|
||||
KEY key;
|
||||
|
||||
while (type_list[type_index] != -1) {
|
||||
while (id_list[id_index] != -1) {
|
||||
type = type_list[type_index];
|
||||
id = id_list[id_index];
|
||||
key = KEY_ENCODE(type, id);
|
||||
decoded_type = KEY_DECODE_TYPE(key);
|
||||
decoded_id = KEY_DECODE_ID(key);
|
||||
zassert_equal(decoded_type, type, NULL);
|
||||
zassert_equal(decoded_id, id, NULL);
|
||||
id_index++;
|
||||
}
|
||||
id_index = 0;
|
||||
type_index++;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@@ -296,7 +325,8 @@ void test_main(void)
|
||||
ztest_unit_test(testKeyListFILO),
|
||||
ztest_unit_test(testKeyListDataKey),
|
||||
ztest_unit_test(testKeyListDataIndex),
|
||||
ztest_unit_test(testKeyListLarge)
|
||||
ztest_unit_test(testKeyListLarge),
|
||||
ztest_unit_test(testKeySample)
|
||||
);
|
||||
|
||||
ztest_run_test_suite(keylist_tests);
|
||||
|
||||
Reference in New Issue
Block a user