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:
Steve Karg
2022-08-01 22:17:27 -05:00
committed by GitHub
parent af16d44d2b
commit 319a1dfd23
3 changed files with 31 additions and 3 deletions
@@ -196,7 +196,6 @@
<ClCompile Include="..\..\..\..\src\bacnet\iam.c" />
<ClCompile Include="..\..\..\..\src\bacnet\ihave.c" />
<ClCompile Include="..\..\..\..\src\bacnet\indtext.c" />
<ClCompile Include="..\..\..\..\src\bacnet\basic\sys\key.c" />
<ClCompile Include="..\..\..\..\src\bacnet\basic\sys\keylist.c" />
<ClCompile Include="..\..\..\..\src\bacnet\hostnport.c" />
<ClCompile Include="..\..\..\..\src\bacnet\lighting.c" />
@@ -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
+31 -1
View File
@@ -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);