Corrected unit tests for iam, event, ai, and bacdevobjpropref. Removed device from unit test since it needs reworked for unit testing due to object dependencies. Noted that lc object fails test and needs fixed.

This commit is contained in:
skarg
2011-08-17 03:47:43 +00:00
parent 3e1cb1847f
commit 8d9b987064
6 changed files with 45 additions and 22 deletions
+29 -2
View File
@@ -105,7 +105,10 @@ void Analog_Input_Property_Lists(
void Analog_Input_Init(
void)
{
unsigned i, j;
unsigned i;
#if defined(INTRINSIC_REPORTING)
unsigned j;
#endif
for (i = 0; i < MAX_ANALOG_INPUTS; i++) {
AI_Descr[i].Present_Value = 0.0f;
@@ -226,13 +229,15 @@ bool Analog_Input_Object_Name(
int Analog_Input_Read_Property(
BACNET_READ_PROPERTY_DATA * rpdata)
{
int len = 0;
int apdu_len = 0; /* return value */
BACNET_BIT_STRING bit_string;
BACNET_CHARACTER_STRING char_string;
ANALOG_INPUT_DESCR *CurrentAI;
unsigned object_index = 0;
#if defined(INTRINSIC_REPORTING)
unsigned i = 0;
int len = 0;
#endif
uint8_t *apdu = NULL;
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
@@ -1121,6 +1126,28 @@ int Analog_Input_Alarm_Ack(
#include <string.h>
#include "ctest.h"
bool WPValidateArgType(
BACNET_APPLICATION_DATA_VALUE * pValue,
uint8_t ucExpectedTag,
BACNET_ERROR_CLASS * pErrorClass,
BACNET_ERROR_CODE * pErrorCode)
{
bool bResult;
/*
* start out assuming success and only set up error
* response if validation fails.
*/
bResult = true;
if (pValue->tag != ucExpectedTag) {
bResult = false;
*pErrorClass = ERROR_CLASS_PROPERTY;
*pErrorCode = ERROR_CODE_INVALID_DATA_TYPE;
}
return (bResult);
}
void testAnalogInput(
Test * pTest)
{
+11 -6
View File
@@ -2,8 +2,9 @@
CC = gcc
SRC_DIR = ../../src
TEST_DIR = ../../test
INCLUDES = -I../../include -I$(TEST_DIR) -I.
DEFINES = -DBIG_ENDIAN=0 -DTEST -DTEST_ANALOG_INPUT
HANDLER_DIR = ../handler
INCLUDES = -I../../include -I$(TEST_DIR) -I. -I$(HANDLER_DIR)
DEFINES = -DBIG_ENDIAN=0 -DBACDL_ALL -DTEST -DTEST_ANALOG_INPUT
CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g
@@ -12,24 +13,28 @@ SRCS = ai.c \
$(SRC_DIR)/bacint.c \
$(SRC_DIR)/bacstr.c \
$(SRC_DIR)/bacreal.c \
$(SRC_DIR)/bacapp.c \
$(SRC_DIR)/bactext.c \
$(SRC_DIR)/indtext.c \
$(SRC_DIR)/datetime.c \
$(TEST_DIR)/ctest.c
TARGET = analog_input
all: ${TARGET}
OBJS = ${SRCS:.c=.o}
${TARGET}: ${OBJS}
${CC} -o $@ ${OBJS}
${CC} -o $@ ${OBJS}
.c.o:
${CC} -c ${CFLAGS} $*.c -o $@
depend:
rm -f .depend
${CC} -MM ${CFLAGS} *.c >> .depend
clean:
rm -rf core ${TARGET} $(OBJS)
+2 -11
View File
@@ -329,16 +329,12 @@ void testDevIdPropRef(
void testDevIdRef(
Test * pTest)
{
BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE inData;
BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE outData;
BACNET_DEVICE_OBJECT_REFERENCE inData;
BACNET_DEVICE_OBJECT_REFERENCE outData;
uint8_t buffer[MAX_APDU];
int inLen;
int outLen;
inData.objectIdentifier.instance = 0x1234;
inData.objectIdentifier.type = 15;
inData.deviceIndentifier.instance = 0x4343;
inData.deviceIndentifier.type = 28;
@@ -347,11 +343,6 @@ void testDevIdRef(
ct_test(pTest, outLen == inLen);
ct_test(pTest,
inData.objectIdentifier.instance == outData.objectIdentifier.instance);
ct_test(pTest,
inData.objectIdentifier.type == outData.objectIdentifier.type);
ct_test(pTest,
inData.deviceIndentifier.instance ==
outData.deviceIndentifier.instance);
+1 -1
View File
@@ -187,7 +187,7 @@ wp: logfile test/wp.mak
( ./test/wp >> ${LOGFILE} )
make -C test -f wp.mak clean
objects: ai ao av bi bo bv device lc lo lso lsp mso
objects: ai ao av bi bo bv lc lo lso lsp mso
ai: logfile demo/object/ai.mak
make -C demo/object -f ai.mak clean all
+1 -1
View File
@@ -1,7 +1,7 @@
#Makefile to build test case
CC = gcc
SRC_DIR = ../src
INCLUDES = -I../include -I.
INCLUDES = -I../include -I. -I../demo/object
DEFINES = -DBIG_ENDIAN=0 -DTEST -DBACAPP_ALL -DTEST_EVENT
CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g
+1 -1
View File
@@ -1,7 +1,7 @@
#Makefile to build test case
CC = gcc
SRC_DIR = ../src
INCLUDES = -I../include -I.
INCLUDES = -I../include -I. -I../demo/object
DEFINES = -DBIG_ENDIAN=0 -DTEST -DTEST_IAM
CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g