From 5a0ed5a9e055e5e568e331ed0095c51de6d6af7c Mon Sep 17 00:00:00 2001 From: skarg Date: Sun, 18 Oct 2015 00:27:09 +0000 Subject: [PATCH] Merged revision(s) 2898 from branches/releases/bacnet-stack-0-8-0: Cleanup of unit test exports. ........ --- bacnet-stack/include/bacint.h | 6 +++++ bacnet-stack/include/datetime.h | 6 +++++ bacnet-stack/include/keylist.h | 11 ++++++++ bacnet-stack/src/bacint.c | 32 ++++++++++++++--------- bacnet-stack/src/datetime.c | 37 ++++++++++++++------------ bacnet-stack/src/keylist.c | 46 +++++++++++++++++++++++++-------- 6 files changed, 99 insertions(+), 39 deletions(-) diff --git a/bacnet-stack/include/bacint.h b/bacnet-stack/include/bacint.h index 2991829e..7fa0bc41 100644 --- a/bacnet-stack/include/bacint.h +++ b/bacnet-stack/include/bacint.h @@ -78,6 +78,12 @@ extern "C" { uint8_t * apdu, int32_t * value); +#ifdef TEST +#include "ctest.h" + void testBACnetIntegers( + Test * pTest); +#endif + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/bacnet-stack/include/datetime.h b/bacnet-stack/include/datetime.h index c1a5b5e5..86b41bca 100644 --- a/bacnet-stack/include/datetime.h +++ b/bacnet-stack/include/datetime.h @@ -185,6 +185,12 @@ extern "C" { uint8_t tag_number, BACNET_DATE_TIME * value); +#ifdef TEST +#include "ctest.h" + void testDateTime( + Test * pTest); +#endif + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/bacnet-stack/include/keylist.h b/bacnet-stack/include/keylist.h index 48bf4e55..d6aaf5d7 100644 --- a/bacnet-stack/include/keylist.h +++ b/bacnet-stack/include/keylist.h @@ -84,6 +84,11 @@ extern "C" { OS_Keylist list, KEY key); +/* returns the index from the node specified by key */ + int Keylist_Index( + OS_Keylist list, + KEY key); + /* returns the data specified by key */ void *Keylist_Data_Index( OS_Keylist list, @@ -103,6 +108,12 @@ extern "C" { int Keylist_Count( OS_Keylist list); +#ifdef TEST +#include "ctest.h" + void testKeyList( + Test * pTest); +#endif + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/bacnet-stack/src/bacint.c b/bacnet-stack/src/bacint.c index 32018b1d..346076d3 100644 --- a/bacnet-stack/src/bacint.c +++ b/bacnet-stack/src/bacint.c @@ -228,7 +228,7 @@ int decode_signed32( #include #include "ctest.h" -void testBACnetUnsigned16( +static void testBACnetUnsigned16( Test * pTest) { uint8_t apdu[32] = { 0 }; @@ -245,7 +245,7 @@ void testBACnetUnsigned16( } } -void testBACnetUnsigned24( +static void testBACnetUnsigned24( Test * pTest) { uint8_t apdu[32] = { 0 }; @@ -262,7 +262,7 @@ void testBACnetUnsigned24( } } -void testBACnetUnsigned32( +static void testBACnetUnsigned32( Test * pTest) { uint8_t apdu[32] = { 0 }; @@ -279,7 +279,7 @@ void testBACnetUnsigned32( } } -void testBACnetSigned8( +static void testBACnetSigned8( Test * pTest) { uint8_t apdu[32] = { 0 }; @@ -296,7 +296,7 @@ void testBACnetSigned8( } } -void testBACnetSigned16( +static void testBACnetSigned16( Test * pTest) { uint8_t apdu[32] = { 0 }; @@ -313,7 +313,7 @@ void testBACnetSigned16( } } -void testBACnetSigned24( +static void testBACnetSigned24( Test * pTest) { uint8_t apdu[32] = { 0 }; @@ -328,7 +328,7 @@ void testBACnetSigned24( } } -void testBACnetSigned32( +static void testBACnetSigned32( Test * pTest) { uint8_t apdu[32] = { 0 }; @@ -349,14 +349,12 @@ void testBACnetSigned32( } } -#ifdef TEST_BACINT -int main( - void) +void testBACnetIntegers( + Test * pTest) { - Test *pTest; bool rc; - pTest = ct_create("BACint", NULL); + assert(pTest); /* individual tests */ rc = ct_addTestFunction(pTest, testBACnetUnsigned16); assert(rc); @@ -372,6 +370,16 @@ int main( assert(rc); rc = ct_addTestFunction(pTest, testBACnetSigned32); assert(rc); +} + +#ifdef TEST_BACINT +int main( + void) +{ + Test *pTest; + + pTest = ct_create("BACint", NULL); + testBACnetIntegers(pTest); /* configure output */ ct_setStream(pTest, stdout); ct_run(pTest); diff --git a/bacnet-stack/src/datetime.c b/bacnet-stack/src/datetime.c index 099f3232..b440983b 100644 --- a/bacnet-stack/src/datetime.c +++ b/bacnet-stack/src/datetime.c @@ -762,7 +762,7 @@ int bacapp_decode_context_datetime( #include #include "ctest.h" -void testBACnetDateTimeWildcard( +static void testBACnetDateTimeWildcard( Test * pTest) { BACNET_DATE_TIME bdatetime; @@ -777,7 +777,7 @@ void testBACnetDateTimeWildcard( ct_test(pTest, status == true); } -void testBACnetDateTimeAdd( +static void testBACnetDateTimeAdd( Test * pTest) { BACNET_DATE_TIME bdatetime, test_bdatetime; @@ -821,7 +821,7 @@ void testBACnetDateTimeAdd( ct_test(pTest, diff == 0); } -void testBACnetDateTimeSeconds( +static void testBACnetDateTimeSeconds( Test * pTest) { uint8_t hour = 0, minute = 0, second = 0; @@ -843,7 +843,7 @@ void testBACnetDateTimeSeconds( } } -void testBACnetDate( +static void testBACnetDate( Test * pTest) { BACNET_DATE bdate1, bdate2; @@ -905,7 +905,7 @@ void testBACnetDate( return; } -void testBACnetTime( +static void testBACnetTime( Test * pTest) { BACNET_TIME btime1, btime2; @@ -955,7 +955,7 @@ void testBACnetTime( return; } -void testBACnetDateTime( +static void testBACnetDateTime( Test * pTest) { BACNET_DATE_TIME bdatetime1, bdatetime2; @@ -1023,7 +1023,7 @@ void testBACnetDateTime( return; } -void testDayOfYear( +static void testDayOfYear( Test * pTest) { uint32_t days = 0; @@ -1061,7 +1061,7 @@ void testDayOfYear( } } -void testDateEpoch( +static void testDateEpoch( Test * pTest) { uint32_t days = 0; @@ -1091,7 +1091,7 @@ void testDateEpoch( } } -void testBACnetDayOfWeek( +static void testBACnetDayOfWeek( Test * pTest) { uint8_t dow = 0; @@ -1120,7 +1120,7 @@ void testBACnetDayOfWeek( ct_test(pTest, dow == 3); } -void testDatetimeCodec( +static void testDatetimeCodec( Test * pTest) { uint8_t apdu[MAX_APDU]; @@ -1156,15 +1156,11 @@ void testDatetimeCodec( } - -#ifdef TEST_DATE_TIME -int main( - void) +void testDateTime( + Test * pTest) { - Test *pTest; bool rc; - pTest = ct_create("BACnet Date Time", NULL); /* individual tests */ rc = ct_addTestFunction(pTest, testBACnetDate); assert(rc); @@ -1186,7 +1182,16 @@ int main( assert(rc); rc = ct_addTestFunction(pTest, testDayOfYear); assert(rc); +} +#ifdef TEST_DATE_TIME +int main( + void) +{ + Test *pTest; + + pTest = ct_create("BACnet Date Time", NULL); + testDateTime(pTest); ct_setStream(pTest, stdout); ct_run(pTest); (void) ct_report(pTest); diff --git a/bacnet-stack/src/keylist.c b/bacnet-stack/src/keylist.c index 0cff93c3..8f576381 100644 --- a/bacnet-stack/src/keylist.c +++ b/bacnet-stack/src/keylist.c @@ -308,6 +308,23 @@ void *Keylist_Data( return node ? node->data : NULL; } +/* returns the index from the node specified by key */ +int Keylist_Index( + OS_Keylist list, + KEY key) +{ + int index = -1; /* used to look up the index of node */ + + if (list && list->array && list->count) { + if (!FindIndex(list, key, &index)) { + index = -1; + } + } + + return index; +} + + /* returns the data specified by key */ void *Keylist_Data_Index( OS_Keylist list, @@ -406,7 +423,7 @@ void Keylist_Delete( #include "ctest.h" /* test the FIFO */ -void testKeyListFIFO( +static void testKeyListFIFO( Test * pTest) { OS_Keylist list; @@ -450,7 +467,7 @@ void testKeyListFIFO( } /* test the FILO */ -void testKeyListFILO( +static void testKeyListFILO( Test * pTest) { OS_Keylist list; @@ -497,7 +514,7 @@ void testKeyListFILO( return; } -void testKeyListDataKey( +static void testKeyListDataKey( Test * pTest) { OS_Keylist list; @@ -578,7 +595,7 @@ void testKeyListDataKey( return; } -void testKeyListDataIndex( +static void testKeyListDataIndex( Test * pTest) { OS_Keylist list; @@ -650,7 +667,7 @@ void testKeyListDataIndex( } /* test access of a lot of entries */ -void testKeyListLarge( +static void testKeyListLarge( Test * pTest) { int data1 = 42; @@ -681,15 +698,12 @@ void testKeyListLarge( return; } -#ifdef TEST_KEYLIST -int main( - void) +/* test access of a lot of entries */ +void testKeyList( + Test * pTest) { - Test *pTest; bool rc; - pTest = ct_create("keylist", NULL); - /* individual tests */ rc = ct_addTestFunction(pTest, testKeyListFIFO); assert(rc); @@ -701,7 +715,17 @@ int main( assert(rc); rc = ct_addTestFunction(pTest, testKeyListLarge); assert(rc); +} +#ifdef TEST_KEYLIST +int main( + void) +{ + Test *pTest; + bool rc; + + pTest = ct_create("keylist", NULL); + testKeyList(pTest); ct_setStream(pTest, stdout); ct_run(pTest); (void) ct_report(pTest);