Merged revision(s) 2898 from branches/releases/bacnet-stack-0-8-0:
Cleanup of unit test exports. ........
This commit is contained in:
@@ -78,6 +78,12 @@ extern "C" {
|
|||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
int32_t * value);
|
int32_t * value);
|
||||||
|
|
||||||
|
#ifdef TEST
|
||||||
|
#include "ctest.h"
|
||||||
|
void testBACnetIntegers(
|
||||||
|
Test * pTest);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|||||||
@@ -185,6 +185,12 @@ extern "C" {
|
|||||||
uint8_t tag_number,
|
uint8_t tag_number,
|
||||||
BACNET_DATE_TIME * value);
|
BACNET_DATE_TIME * value);
|
||||||
|
|
||||||
|
#ifdef TEST
|
||||||
|
#include "ctest.h"
|
||||||
|
void testDateTime(
|
||||||
|
Test * pTest);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|||||||
@@ -84,6 +84,11 @@ extern "C" {
|
|||||||
OS_Keylist list,
|
OS_Keylist list,
|
||||||
KEY key);
|
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 */
|
/* returns the data specified by key */
|
||||||
void *Keylist_Data_Index(
|
void *Keylist_Data_Index(
|
||||||
OS_Keylist list,
|
OS_Keylist list,
|
||||||
@@ -103,6 +108,12 @@ extern "C" {
|
|||||||
int Keylist_Count(
|
int Keylist_Count(
|
||||||
OS_Keylist list);
|
OS_Keylist list);
|
||||||
|
|
||||||
|
#ifdef TEST
|
||||||
|
#include "ctest.h"
|
||||||
|
void testKeyList(
|
||||||
|
Test * pTest);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|||||||
+20
-12
@@ -228,7 +228,7 @@ int decode_signed32(
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include "ctest.h"
|
#include "ctest.h"
|
||||||
|
|
||||||
void testBACnetUnsigned16(
|
static void testBACnetUnsigned16(
|
||||||
Test * pTest)
|
Test * pTest)
|
||||||
{
|
{
|
||||||
uint8_t apdu[32] = { 0 };
|
uint8_t apdu[32] = { 0 };
|
||||||
@@ -245,7 +245,7 @@ void testBACnetUnsigned16(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void testBACnetUnsigned24(
|
static void testBACnetUnsigned24(
|
||||||
Test * pTest)
|
Test * pTest)
|
||||||
{
|
{
|
||||||
uint8_t apdu[32] = { 0 };
|
uint8_t apdu[32] = { 0 };
|
||||||
@@ -262,7 +262,7 @@ void testBACnetUnsigned24(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void testBACnetUnsigned32(
|
static void testBACnetUnsigned32(
|
||||||
Test * pTest)
|
Test * pTest)
|
||||||
{
|
{
|
||||||
uint8_t apdu[32] = { 0 };
|
uint8_t apdu[32] = { 0 };
|
||||||
@@ -279,7 +279,7 @@ void testBACnetUnsigned32(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void testBACnetSigned8(
|
static void testBACnetSigned8(
|
||||||
Test * pTest)
|
Test * pTest)
|
||||||
{
|
{
|
||||||
uint8_t apdu[32] = { 0 };
|
uint8_t apdu[32] = { 0 };
|
||||||
@@ -296,7 +296,7 @@ void testBACnetSigned8(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void testBACnetSigned16(
|
static void testBACnetSigned16(
|
||||||
Test * pTest)
|
Test * pTest)
|
||||||
{
|
{
|
||||||
uint8_t apdu[32] = { 0 };
|
uint8_t apdu[32] = { 0 };
|
||||||
@@ -313,7 +313,7 @@ void testBACnetSigned16(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void testBACnetSigned24(
|
static void testBACnetSigned24(
|
||||||
Test * pTest)
|
Test * pTest)
|
||||||
{
|
{
|
||||||
uint8_t apdu[32] = { 0 };
|
uint8_t apdu[32] = { 0 };
|
||||||
@@ -328,7 +328,7 @@ void testBACnetSigned24(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void testBACnetSigned32(
|
static void testBACnetSigned32(
|
||||||
Test * pTest)
|
Test * pTest)
|
||||||
{
|
{
|
||||||
uint8_t apdu[32] = { 0 };
|
uint8_t apdu[32] = { 0 };
|
||||||
@@ -349,14 +349,12 @@ void testBACnetSigned32(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TEST_BACINT
|
void testBACnetIntegers(
|
||||||
int main(
|
Test * pTest)
|
||||||
void)
|
|
||||||
{
|
{
|
||||||
Test *pTest;
|
|
||||||
bool rc;
|
bool rc;
|
||||||
|
|
||||||
pTest = ct_create("BACint", NULL);
|
assert(pTest);
|
||||||
/* individual tests */
|
/* individual tests */
|
||||||
rc = ct_addTestFunction(pTest, testBACnetUnsigned16);
|
rc = ct_addTestFunction(pTest, testBACnetUnsigned16);
|
||||||
assert(rc);
|
assert(rc);
|
||||||
@@ -372,6 +370,16 @@ int main(
|
|||||||
assert(rc);
|
assert(rc);
|
||||||
rc = ct_addTestFunction(pTest, testBACnetSigned32);
|
rc = ct_addTestFunction(pTest, testBACnetSigned32);
|
||||||
assert(rc);
|
assert(rc);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef TEST_BACINT
|
||||||
|
int main(
|
||||||
|
void)
|
||||||
|
{
|
||||||
|
Test *pTest;
|
||||||
|
|
||||||
|
pTest = ct_create("BACint", NULL);
|
||||||
|
testBACnetIntegers(pTest);
|
||||||
/* configure output */
|
/* configure output */
|
||||||
ct_setStream(pTest, stdout);
|
ct_setStream(pTest, stdout);
|
||||||
ct_run(pTest);
|
ct_run(pTest);
|
||||||
|
|||||||
+21
-16
@@ -762,7 +762,7 @@ int bacapp_decode_context_datetime(
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "ctest.h"
|
#include "ctest.h"
|
||||||
|
|
||||||
void testBACnetDateTimeWildcard(
|
static void testBACnetDateTimeWildcard(
|
||||||
Test * pTest)
|
Test * pTest)
|
||||||
{
|
{
|
||||||
BACNET_DATE_TIME bdatetime;
|
BACNET_DATE_TIME bdatetime;
|
||||||
@@ -777,7 +777,7 @@ void testBACnetDateTimeWildcard(
|
|||||||
ct_test(pTest, status == true);
|
ct_test(pTest, status == true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void testBACnetDateTimeAdd(
|
static void testBACnetDateTimeAdd(
|
||||||
Test * pTest)
|
Test * pTest)
|
||||||
{
|
{
|
||||||
BACNET_DATE_TIME bdatetime, test_bdatetime;
|
BACNET_DATE_TIME bdatetime, test_bdatetime;
|
||||||
@@ -821,7 +821,7 @@ void testBACnetDateTimeAdd(
|
|||||||
ct_test(pTest, diff == 0);
|
ct_test(pTest, diff == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void testBACnetDateTimeSeconds(
|
static void testBACnetDateTimeSeconds(
|
||||||
Test * pTest)
|
Test * pTest)
|
||||||
{
|
{
|
||||||
uint8_t hour = 0, minute = 0, second = 0;
|
uint8_t hour = 0, minute = 0, second = 0;
|
||||||
@@ -843,7 +843,7 @@ void testBACnetDateTimeSeconds(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void testBACnetDate(
|
static void testBACnetDate(
|
||||||
Test * pTest)
|
Test * pTest)
|
||||||
{
|
{
|
||||||
BACNET_DATE bdate1, bdate2;
|
BACNET_DATE bdate1, bdate2;
|
||||||
@@ -905,7 +905,7 @@ void testBACnetDate(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void testBACnetTime(
|
static void testBACnetTime(
|
||||||
Test * pTest)
|
Test * pTest)
|
||||||
{
|
{
|
||||||
BACNET_TIME btime1, btime2;
|
BACNET_TIME btime1, btime2;
|
||||||
@@ -955,7 +955,7 @@ void testBACnetTime(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void testBACnetDateTime(
|
static void testBACnetDateTime(
|
||||||
Test * pTest)
|
Test * pTest)
|
||||||
{
|
{
|
||||||
BACNET_DATE_TIME bdatetime1, bdatetime2;
|
BACNET_DATE_TIME bdatetime1, bdatetime2;
|
||||||
@@ -1023,7 +1023,7 @@ void testBACnetDateTime(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void testDayOfYear(
|
static void testDayOfYear(
|
||||||
Test * pTest)
|
Test * pTest)
|
||||||
{
|
{
|
||||||
uint32_t days = 0;
|
uint32_t days = 0;
|
||||||
@@ -1061,7 +1061,7 @@ void testDayOfYear(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void testDateEpoch(
|
static void testDateEpoch(
|
||||||
Test * pTest)
|
Test * pTest)
|
||||||
{
|
{
|
||||||
uint32_t days = 0;
|
uint32_t days = 0;
|
||||||
@@ -1091,7 +1091,7 @@ void testDateEpoch(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void testBACnetDayOfWeek(
|
static void testBACnetDayOfWeek(
|
||||||
Test * pTest)
|
Test * pTest)
|
||||||
{
|
{
|
||||||
uint8_t dow = 0;
|
uint8_t dow = 0;
|
||||||
@@ -1120,7 +1120,7 @@ void testBACnetDayOfWeek(
|
|||||||
ct_test(pTest, dow == 3);
|
ct_test(pTest, dow == 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
void testDatetimeCodec(
|
static void testDatetimeCodec(
|
||||||
Test * pTest)
|
Test * pTest)
|
||||||
{
|
{
|
||||||
uint8_t apdu[MAX_APDU];
|
uint8_t apdu[MAX_APDU];
|
||||||
@@ -1156,15 +1156,11 @@ void testDatetimeCodec(
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void testDateTime(
|
||||||
#ifdef TEST_DATE_TIME
|
Test * pTest)
|
||||||
int main(
|
|
||||||
void)
|
|
||||||
{
|
{
|
||||||
Test *pTest;
|
|
||||||
bool rc;
|
bool rc;
|
||||||
|
|
||||||
pTest = ct_create("BACnet Date Time", NULL);
|
|
||||||
/* individual tests */
|
/* individual tests */
|
||||||
rc = ct_addTestFunction(pTest, testBACnetDate);
|
rc = ct_addTestFunction(pTest, testBACnetDate);
|
||||||
assert(rc);
|
assert(rc);
|
||||||
@@ -1186,7 +1182,16 @@ int main(
|
|||||||
assert(rc);
|
assert(rc);
|
||||||
rc = ct_addTestFunction(pTest, testDayOfYear);
|
rc = ct_addTestFunction(pTest, testDayOfYear);
|
||||||
assert(rc);
|
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_setStream(pTest, stdout);
|
||||||
ct_run(pTest);
|
ct_run(pTest);
|
||||||
(void) ct_report(pTest);
|
(void) ct_report(pTest);
|
||||||
|
|||||||
+35
-11
@@ -308,6 +308,23 @@ void *Keylist_Data(
|
|||||||
return node ? node->data : NULL;
|
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 */
|
/* returns the data specified by key */
|
||||||
void *Keylist_Data_Index(
|
void *Keylist_Data_Index(
|
||||||
OS_Keylist list,
|
OS_Keylist list,
|
||||||
@@ -406,7 +423,7 @@ void Keylist_Delete(
|
|||||||
#include "ctest.h"
|
#include "ctest.h"
|
||||||
|
|
||||||
/* test the FIFO */
|
/* test the FIFO */
|
||||||
void testKeyListFIFO(
|
static void testKeyListFIFO(
|
||||||
Test * pTest)
|
Test * pTest)
|
||||||
{
|
{
|
||||||
OS_Keylist list;
|
OS_Keylist list;
|
||||||
@@ -450,7 +467,7 @@ void testKeyListFIFO(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* test the FILO */
|
/* test the FILO */
|
||||||
void testKeyListFILO(
|
static void testKeyListFILO(
|
||||||
Test * pTest)
|
Test * pTest)
|
||||||
{
|
{
|
||||||
OS_Keylist list;
|
OS_Keylist list;
|
||||||
@@ -497,7 +514,7 @@ void testKeyListFILO(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void testKeyListDataKey(
|
static void testKeyListDataKey(
|
||||||
Test * pTest)
|
Test * pTest)
|
||||||
{
|
{
|
||||||
OS_Keylist list;
|
OS_Keylist list;
|
||||||
@@ -578,7 +595,7 @@ void testKeyListDataKey(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void testKeyListDataIndex(
|
static void testKeyListDataIndex(
|
||||||
Test * pTest)
|
Test * pTest)
|
||||||
{
|
{
|
||||||
OS_Keylist list;
|
OS_Keylist list;
|
||||||
@@ -650,7 +667,7 @@ void testKeyListDataIndex(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* test access of a lot of entries */
|
/* test access of a lot of entries */
|
||||||
void testKeyListLarge(
|
static void testKeyListLarge(
|
||||||
Test * pTest)
|
Test * pTest)
|
||||||
{
|
{
|
||||||
int data1 = 42;
|
int data1 = 42;
|
||||||
@@ -681,15 +698,12 @@ void testKeyListLarge(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TEST_KEYLIST
|
/* test access of a lot of entries */
|
||||||
int main(
|
void testKeyList(
|
||||||
void)
|
Test * pTest)
|
||||||
{
|
{
|
||||||
Test *pTest;
|
|
||||||
bool rc;
|
bool rc;
|
||||||
|
|
||||||
pTest = ct_create("keylist", NULL);
|
|
||||||
|
|
||||||
/* individual tests */
|
/* individual tests */
|
||||||
rc = ct_addTestFunction(pTest, testKeyListFIFO);
|
rc = ct_addTestFunction(pTest, testKeyListFIFO);
|
||||||
assert(rc);
|
assert(rc);
|
||||||
@@ -701,7 +715,17 @@ int main(
|
|||||||
assert(rc);
|
assert(rc);
|
||||||
rc = ct_addTestFunction(pTest, testKeyListLarge);
|
rc = ct_addTestFunction(pTest, testKeyListLarge);
|
||||||
assert(rc);
|
assert(rc);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef TEST_KEYLIST
|
||||||
|
int main(
|
||||||
|
void)
|
||||||
|
{
|
||||||
|
Test *pTest;
|
||||||
|
bool rc;
|
||||||
|
|
||||||
|
pTest = ct_create("keylist", NULL);
|
||||||
|
testKeyList(pTest);
|
||||||
ct_setStream(pTest, stdout);
|
ct_setStream(pTest, stdout);
|
||||||
ct_run(pTest);
|
ct_run(pTest);
|
||||||
(void) ct_report(pTest);
|
(void) ct_report(pTest);
|
||||||
|
|||||||
Reference in New Issue
Block a user