123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948 |
- /*
- ============================================================================
- Name : check_stack.c
- Author :
- Version :
- Copyright : Your copyright notice
- Description :
- ============================================================================
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include "../src/opcua_transportLayer.h"
- #include "../src/opcua_binaryEncDec.h"
- #include "../src/opcua_encodingLayer.h"
- #include "../src/opcua_advancedDatatypes.h"
- //#include "check_stdint.h"
- #include "check.h"
- START_TEST(test_getPacketType_validParameter)
- {
- char buf[] = {'C','L','O'};
- Int32 pos = 0;
- AD_RawMessage rawMessage;
- rawMessage.message = buf;
- rawMessage.length = 3;
- ck_assert_int_eq(TL_getPacketType(&pos,&rawMessage),packetType_CLO);
- }
- END_TEST
- START_TEST(encodeByte_test)
- {
- AD_RawMessage rawMessage;
- Int32 position = 0;
- //EncodeByte
- char *mem = malloc(sizeof(Byte));
- rawMessage.message = mem;
- Byte testByte = 0x08;
- rawMessage.length = 1;
- position = 0;
- encodeByte(testByte, &position, rawMessage.message);
- ck_assert_int_eq(rawMessage.message[0], 0x08);
- ck_assert_int_eq(rawMessage.length, 1);
- ck_assert_int_eq(position, 1);
- free(mem);
- }
- END_TEST
- /*
- START_TEST(decodeRequestHeader_test_validParameter)
- {
- char testMessage = {0x00,0x00,0x72,0xf1,0xdc,0xc9,0x87,0x0b,
- 0xcf,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00};
- AD_RawMessage rawMessage;
- rawMessage.message = &testMessage;
- rawMessage.length = 29;
- Int32 position = 0;
- T_RequestHeader requestHeader;
- decodeRequestHeader(rawMessage,&position,&requestHeader);
- ck_assert_int_eq(requestHeader.authenticationToken.EncodingByte,0);
- ck_assert_int_eq(requestHeader.returnDiagnostics,0);
- ck_assert_int_eq(requestHeader.authenticationToken.EncodingByte,0);
- }
- END_TEST
- */
- START_TEST(decodeInt16_test)
- {
- AD_RawMessage rawMessage;
- Int32 position = 0;
- //EncodeUInt16
- char mem[2] = {0x01,0x00};
- rawMessage.message = mem;
- rawMessage.length = 2;
- //encodeUInt16(testUInt16, &position, &rawMessage);
- Int32 p = 0;
- Int16 val;
- decoder_decodeBuiltInDatatype(rawMessage.message,INT16,&p,&val);
- ck_assert_int_eq(val,1);
- //ck_assert_int_eq(p, 2);
- //ck_assert_int_eq(rawMessage.message[0], 0xAB);
- }
- END_TEST
- START_TEST(encodeInt16_test)
- {
- AD_RawMessage rawMessage;
- Int32 position = 0;
- //EncodeUInt16
- char *mem = malloc(sizeof(UInt16));
- rawMessage.message = mem;
- UInt16 testUInt16 = 1;
- rawMessage.length = 2;
- position = 0;
- encodeUInt16(testUInt16, &position, rawMessage.message);
- //encodeUInt16(testUInt16, &position, &rawMessage);
- ck_assert_int_eq(position, 2);
- Int32 p = 0;
- Int16 val;
- decoder_decodeBuiltInDatatype(rawMessage.message, INT16, &p, &val);
- ck_assert_int_eq(val,testUInt16);
- //ck_assert_int_eq(rawMessage.message[0], 0xAB);
- }
- END_TEST
- START_TEST(decodeUInt16_test)
- {
- AD_RawMessage rawMessage;
- Int32 position = 0;
- //EncodeUInt16
- char mem[2] = {0x01,0x00};
- rawMessage.message = mem;
- rawMessage.length = 2;
- //encodeUInt16(testUInt16, &position, &rawMessage);
- Int32 p = 0;
- UInt16 val;
- decoder_decodeBuiltInDatatype(rawMessage.message,UINT16,&p,&val);
- ck_assert_int_eq(val,1);
- //ck_assert_int_eq(p, 2);
- //ck_assert_int_eq(rawMessage.message[0], 0xAB);
- }
- END_TEST
- START_TEST(encodeUInt16_test)
- {
- AD_RawMessage rawMessage;
- Int32 position = 0;
- //EncodeUInt16
- char *mem = malloc(sizeof(UInt16));
- rawMessage.message = mem;
- UInt16 testUInt16 = 1;
- rawMessage.length = 2;
- position = 0;
- encodeUInt16(testUInt16, &position, rawMessage.message);
- //encodeUInt16(testUInt16, &position, &rawMessage);
- ck_assert_int_eq(position, 2);
- Int32 p = 0;
- UInt16 val;
- decoder_decodeBuiltInDatatype(rawMessage.message, UINT16, &p, &val);
- ck_assert_int_eq(val,testUInt16);
- //ck_assert_int_eq(rawMessage.message[0], 0xAB);
- }
- END_TEST
- START_TEST(decodeUInt32_test)
- {
- AD_RawMessage rawMessage;
- Int32 position = 0;
- //EncodeUInt16
- char mem[4] = {0xFF,0x00,0x00,0x00};
- rawMessage.message = mem;
- rawMessage.length = 4;
- Int32 p = 0;
- UInt32 val;
- decoder_decodeBuiltInDatatype(rawMessage.message, UINT32, &p, &val);
- ck_assert_uint_eq(val,255);
- }
- END_TEST
- START_TEST(encodeUInt32_test)
- {
- AD_RawMessage rawMessage;
- Int32 position = 0;
- UInt32 value = 0x0101FF00;
- //EncodeUInt16
- rawMessage.message = (char*)opcua_malloc(2 * sizeof(UInt32));
- rawMessage.length = 8;
- Int32 p = 4;
- //encodeUInt32(value, &p,rawMessage.message);
- encoder_encodeBuiltInDatatype(&value,UINT32,&p,rawMessage.message);
- ck_assert_uint_eq((Byte)rawMessage.message[4],0x00);
- ck_assert_uint_eq((Byte)rawMessage.message[5],0xFF);
- ck_assert_uint_eq((Byte)rawMessage.message[6],0x01);
- ck_assert_uint_eq((Byte)rawMessage.message[7],0x01);
- ck_assert_int_eq(p,8);
- }
- END_TEST
- START_TEST(decodeInt32_test)
- {
- AD_RawMessage rawMessage;
- Int32 position = 0;
- //EncodeUInt16
- char mem[4] = {0x00,0xCA,0x9A,0x3B};
- rawMessage.message = mem;
- rawMessage.length = 4;
- Int32 p = 0;
- Int32 val;
- decoder_decodeBuiltInDatatype(rawMessage.message, INT32, &p, &val);
- ck_assert_int_eq(val,1000000000);
- }
- END_TEST
- START_TEST(encodeInt32_test)
- {
- }
- END_TEST
- START_TEST(decodeUInt64_test)
- {
- AD_RawMessage rawMessage;
- Int32 position = 0;
- UInt64 expectedVal = 0xFF;
- expectedVal = expectedVal << 56;
- char mem[8] = {00,00,00,00,0x00,0x00,0x00,0xFF};
- rawMessage.message = mem;
- rawMessage.length = 8;
- Int32 p = 0;
- UInt64 val;
- decoder_decodeBuiltInDatatype(rawMessage.message, UINT64, &p, &val);
- ck_assert_uint_eq(val, expectedVal);
- }
- END_TEST
- START_TEST(encodeUInt64_test)
- {
- AD_RawMessage rawMessage;
- Int32 position = 0;
- UInt64 value = 0x0101FF00FF00FF00;
- //EncodeUInt16
- rawMessage.message = (char*)opcua_malloc(sizeof(UInt32));
- rawMessage.length = 8;
- Int32 p = 0;
- encodeUInt64(value, &p,rawMessage.message);
- ck_assert_uint_eq((Byte)rawMessage.message[0],0x00);
- ck_assert_uint_eq((Byte)rawMessage.message[1],0xFF);
- ck_assert_uint_eq((Byte)rawMessage.message[2],0x00);
- ck_assert_uint_eq((Byte)rawMessage.message[3],0xFF);
- ck_assert_uint_eq((Byte)rawMessage.message[4],0x00);
- ck_assert_uint_eq((Byte)rawMessage.message[5],0xFF);
- ck_assert_uint_eq((Byte)rawMessage.message[6],0x01);
- ck_assert_uint_eq((Byte)rawMessage.message[7],0x01);
- }
- END_TEST
- START_TEST(decodeInt64_test)
- {
- AD_RawMessage rawMessage;
- Int32 position = 0;
- Int64 expectedVal = 0xFF;
- expectedVal = expectedVal << 56;
- char mem[8] = {00,00,00,00,0x00,0x00,0x00,0xFF};
- rawMessage.message = mem;
- rawMessage.length = 8;
- Int32 p = 0;
- Int64 val;
- decoder_decodeBuiltInDatatype(rawMessage.message, INT64, &p, &val);
- ck_assert_uint_eq(val, expectedVal);
- }
- END_TEST
- START_TEST(encodeInt64_test)
- {
- AD_RawMessage rawMessage;
- Int32 position = 0;
- UInt64 value = 0x0101FF00FF00FF00;
- //EncodeUInt16
- rawMessage.message = (char*)opcua_malloc(sizeof(UInt32));
- rawMessage.length = 8;
- Int32 p = 0;
- encodeUInt64(value, &p,rawMessage.message);
- ck_assert_uint_eq((Byte)rawMessage.message[0],0x00);
- ck_assert_uint_eq((Byte)rawMessage.message[1],0xFF);
- ck_assert_uint_eq((Byte)rawMessage.message[2],0x00);
- ck_assert_uint_eq((Byte)rawMessage.message[3],0xFF);
- ck_assert_uint_eq((Byte)rawMessage.message[4],0x00);
- ck_assert_uint_eq((Byte)rawMessage.message[5],0xFF);
- ck_assert_uint_eq((Byte)rawMessage.message[6],0x01);
- ck_assert_uint_eq((Byte)rawMessage.message[7],0x01);
- }
- END_TEST
- START_TEST(decodeFloat_test)
- {
- Float expectedValue = -6.5;
- Int32 pos = 0;
- char buf[4] = {0x00,0x00,0xD0,0xC0};
- Float calcVal;
- decoder_decodeBuiltInDatatype(buf, FLOAT, &pos, &calcVal);
- //val should be -6.5
- Int32 val = (calcVal > -6.501 && calcVal < -6.499);
- ck_assert_int_gt(val,0);
- opcua_free(buf);
- }
- END_TEST
- START_TEST(encodeFloat_test)
- {
- Float value = -6.5;
- Int32 pos = 0;
- char *buf = (char*)opcua_malloc(sizeof(Float));
- encodeFloat(value,&pos,buf);
- ck_assert_uint_eq((Byte)buf[2],0xD0);
- ck_assert_uint_eq((Byte)buf[3],0xC0);
- opcua_free(buf);
- }
- END_TEST
- START_TEST(decodeDouble_test)
- {
- }
- END_TEST
- START_TEST(encodeDouble_test)
- {
- Float value = -6.5;
- Int32 pos = 0;
- char *buf = (char*)opcua_malloc(sizeof(Float));
- encodeDouble(value,&pos,buf);
- ck_assert_uint_eq((Byte)buf[6],0xD0);
- ck_assert_uint_eq((Byte)buf[7],0xC0);
- opcua_free(buf);
- }
- END_TEST
- START_TEST(encodeUAString_test)
- {
- Int32 pos = 0;
- UA_String string;
- Int32 l = 11;
- char mem[11] = "ACPLT OPCUA";
- char *dstBuf = (char*) malloc(sizeof(Int32)+l);
- string.Data = mem;
- string.Length = 11;
- encodeUAString(&string, &pos, dstBuf);
- ck_assert_int_eq(dstBuf[0],11);
- ck_assert_int_eq(dstBuf[0+sizeof(Int32)],'A');
- }
- END_TEST
- START_TEST(decodeUAString_test)
- {
- Int32 pos = 0;
- UA_String string;
- Int32 l = 11;
- char binString[15] = {11,0x00,0x00,0x00,'A','C','P','L','T',' ','U','A'};
- char *dstBuf = (char*) malloc(l-sizeof(Int32));
- string.Data = dstBuf;
- string.Length = 0;
- decodeUAString(binString, &pos, &string);
- ck_assert_int_eq(string.Length,11);
- ck_assert_int_eq(string.Data[3],'L');
- }
- END_TEST
- START_TEST(diagnosticInfo_calcSize_test)
- {
- Int32 valreal = 0;
- Int32 valcalc = 0;
- UA_DiagnosticInfo diagnosticInfo;
- diagnosticInfo.EncodingMask = 0x01 | 0x02 | 0x04 | 0x08 | 0x10;
- diagnosticInfo.SymbolicId = 30;
- diagnosticInfo.NamespaceUri = 25;
- diagnosticInfo.LocalizedText = 22;
- diagnosticInfo.AdditionalInfo.Data = "OPCUA";
- diagnosticInfo.AdditionalInfo.Length = 5;
- valcalc = diagnosticInfo_calcSize(&diagnosticInfo);
- valreal = 26;
- ck_assert_int_eq(valcalc,valreal);
- }
- END_TEST
- START_TEST(extensionObject_calcSize_test)
- {
- Int32 valreal = 0;
- Int32 valcalc = 0;
- Byte data[3] = {1,2,3};
- UA_ExtensionObject extensionObject;
- extensionObject.TypeId.EncodingByte = NIEVT_TWO_BYTE;; // Numeric TWO BYTES
- extensionObject.TypeId.Identifier.Numeric = 0;
- extensionObject.Encoding = 0x00;
- extensionObject.Length = 0;
- //extensionObject.Body = &data;
- valcalc = extensionObject_calcSize(&extensionObject);
- valreal = 3;
- ck_assert_int_eq(valcalc, valreal);
- }
- END_TEST
- START_TEST(responseHeader_calcSize_test)
- {
- Int32 valreal = 0;
- Int32 valcalc = 0;
- T_ResponseHeader responseHeader;
- UA_DiagnosticInfo diagnosticInfo;
- UA_ExtensionObject extensionObject;
- //Should have the size of 16 Bytes
- responseHeader.timestamp = 150014;
- responseHeader.requestHandle = 514;
- responseHeader.serviceResult = 504;
- //Should have the size of 26 Bytes
- diagnosticInfo.EncodingMask = 0x01 | 0x02 | 0x04 | 0x08 | 0x10;
- diagnosticInfo.SymbolicId = 30;
- diagnosticInfo.NamespaceUri = 25;
- diagnosticInfo.LocalizedText = 22;
- diagnosticInfo.AdditionalInfo.Data = "OPCUA";
- diagnosticInfo.AdditionalInfo.Length = 5;
- responseHeader.serviceDiagnostics = &diagnosticInfo;
- //Should have the size of 4 Bytes
- responseHeader.noOfStringTable = 0;
- //Should have the size of 3 Bytes
- extensionObject.TypeId.EncodingByte = NIEVT_TWO_BYTE;
- extensionObject.TypeId.Identifier.Numeric = 0;
- extensionObject.Encoding = 0x00; //binaryBody = false, xmlBody = false
- responseHeader.additionalHeader = extensionObject;
- valcalc = responseHeader_calcSize(&responseHeader);
- valreal = 49;
- ck_assert_int_eq(valcalc,valreal);
- }
- END_TEST
- //ToDo: Function needs to be filled
- START_TEST(expandedNodeId_calcSize_test)
- {
- Int32 valreal = 300;
- Int32 valcalc = 0;
- ck_assert_int_eq(valcalc,valreal);
- }
- END_TEST
- START_TEST(encodeDataValue_test)
- {
- UA_DataValue dataValue;
- Int32 pos = 0;
- char *buf = (char*)opcua_malloc(15);
- UA_DateTime dateTime;
- dateTime = 80;
- dataValue.ServerTimestamp = dateTime;
- //--without Variant
- dataValue.EncodingMask = 0x08; //Only the SourvePicoseconds
- encodeDataValue(&dataValue, &pos, buf);
- ck_assert_int_eq(pos, 9);// represents the length
- ck_assert_int_eq(buf[0], 0x08);
- ck_assert_int_eq(buf[1], 80);
- ck_assert_int_eq(buf[2], 0);
- ck_assert_int_eq(buf[3], 0);
- ck_assert_int_eq(buf[4], 0);
- ck_assert_int_eq(buf[5], 0);
- ck_assert_int_eq(buf[6], 0);
- ck_assert_int_eq(buf[7], 0);
- ck_assert_int_eq(buf[8], 0);
- //TestCase for a DataValue with a Variant!
- //ToDo: Need to be checked after the function for encoding variants has been implemented
- pos = 0;
- dataValue.EncodingMask = 0x01 || 0x08; //Variant & SourvePicoseconds
- UA_Variant variant;
- variant.ArrayLength = 0;
- variant.EncodingMask = VTEMT_INT32;
- UA_VariantUnion variantUnion;
- variantUnion.Int32 = 45;
- variant.Value = &variantUnion;
- dataValue.Value = variant;
- encodeDataValue(&dataValue, &pos, buf);
- ck_assert_int_eq(pos, 14);// represents the length
- ck_assert_int_eq(buf[0], 0x08);
- ck_assert_int_eq(buf[1], 0x06);
- ck_assert_int_eq(buf[2], 45);
- ck_assert_int_eq(buf[3], 0);
- ck_assert_int_eq(buf[4], 0);
- ck_assert_int_eq(buf[5], 0);
- ck_assert_int_eq(buf[6], 80);
- ck_assert_int_eq(buf[7], 0);
- }
- END_TEST
- Suite *testSuite_getPacketType(void)
- {
- Suite *s = suite_create("getPacketType");
- TCase *tc_core = tcase_create("Core");
- tcase_add_test(tc_core,test_getPacketType_validParameter);
- suite_add_tcase(s,tc_core);
- return s;
- }
- Suite *testSuite_encodeByte(void)
- {
- Suite *s = suite_create("encodeByte_test");
- TCase *tc_core = tcase_create("Core");
- tcase_add_test(tc_core, encodeByte_test);
- suite_add_tcase(s,tc_core);
- return s;
- }
- Suite *testSuite_decodeInt16(void)
- {
- Suite *s = suite_create("decodeInt16_test");
- TCase *tc_core = tcase_create("Core");
- tcase_add_test(tc_core, decodeInt16_test);
- suite_add_tcase(s,tc_core);
- return s;
- }
- Suite*testSuite_encodeInt16(void)
- {
- Suite *s = suite_create("encodeInt16_test");
- TCase *tc_core = tcase_create("Core");
- tcase_add_test(tc_core, encodeInt16_test);
- suite_add_tcase(s,tc_core);
- return s;
- }
- Suite *testSuite_decodeUInt16(void)
- {
- Suite *s = suite_create("decodeUInt16_test");
- TCase *tc_core = tcase_create("Core");
- tcase_add_test(tc_core, decodeUInt16_test);
- suite_add_tcase(s,tc_core);
- return s;
- }
- Suite*testSuite_encodeUInt16(void)
- {
- Suite *s = suite_create("encodeUInt16_test");
- TCase *tc_core = tcase_create("Core");
- tcase_add_test(tc_core, encodeUInt16_test);
- suite_add_tcase(s,tc_core);
- return s;
- }
- Suite*testSuite_decodeUInt32(void)
- {
- Suite *s = suite_create("decodeUInt32_test");
- TCase *tc_core = tcase_create("Core");
- tcase_add_test(tc_core, decodeUInt32_test);
- suite_add_tcase(s,tc_core);
- return s;
- }
- Suite*testSuite_encodeUInt32(void)
- {
- Suite *s = suite_create("encodeUInt32_test");
- TCase *tc_core = tcase_create("Core");
- tcase_add_test(tc_core, encodeUInt32_test);
- suite_add_tcase(s,tc_core);
- return s;
- }
- Suite*testSuite_decodeInt32(void)
- {
- Suite *s = suite_create("decodeInt32_test");
- TCase *tc_core = tcase_create("Core");
- tcase_add_test(tc_core, decodeInt32_test);
- suite_add_tcase(s,tc_core);
- return s;
- }
- Suite*testSuite_encodeInt32(void)
- {
- Suite *s = suite_create("encodeInt32_test");
- TCase *tc_core = tcase_create("Core");
- tcase_add_test(tc_core, encodeInt32_test);
- suite_add_tcase(s,tc_core);
- return s;
- }
- Suite*testSuite_decodeUInt64(void)
- {
- Suite *s = suite_create("decodeUInt64_test");
- TCase *tc_core = tcase_create("Core");
- tcase_add_test(tc_core, decodeUInt64_test);
- suite_add_tcase(s,tc_core);
- return s;
- }
- Suite*testSuite_encodeUInt64(void)
- {
- Suite *s = suite_create("encodeUInt64_test");
- TCase *tc_core = tcase_create("Core");
- tcase_add_test(tc_core, encodeUInt64_test);
- suite_add_tcase(s,tc_core);
- return s;
- }
- Suite*testSuite_decodeInt64(void)
- {
- Suite *s = suite_create("decodeInt64_test");
- TCase *tc_core = tcase_create("Core");
- tcase_add_test(tc_core, decodeInt64_test);
- suite_add_tcase(s,tc_core);
- return s;
- }
- Suite*testSuite_encodeInt64(void)
- {
- Suite *s = suite_create("encodeInt64_test");
- TCase *tc_core = tcase_create("Core");
- tcase_add_test(tc_core, encodeInt64_test);
- suite_add_tcase(s,tc_core);
- return s;
- }
- Suite *testSuite_encodeFloat(void)
- {
- Suite *s = suite_create("encodeFloat_test");
- TCase *tc_core = tcase_create("Core");
- tcase_add_test(tc_core, encodeFloat_test);
- suite_add_tcase(s,tc_core);
- return s;
- }
- Suite *testSuite_decodeFloat(void)
- {
- Suite *s = suite_create("decodeFloat_test");
- TCase *tc_core = tcase_create("Core");
- tcase_add_test(tc_core, decodeFloat_test);
- suite_add_tcase(s,tc_core);
- return s;
- }
- Suite *testSuite_encodeDouble(void)
- {
- Suite *s = suite_create("encodeDouble_test");
- TCase *tc_core = tcase_create("Core");
- tcase_add_test(tc_core, encodeDouble_test);
- suite_add_tcase(s,tc_core);
- return s;
- }
- Suite *testSuite_decodeDouble(void)
- {
- Suite *s = suite_create("decodeDouble_test");
- TCase *tc_core = tcase_create("Core");
- tcase_add_test(tc_core, decodeDouble_test);
- suite_add_tcase(s,tc_core);
- return s;
- }
- Suite * testSuite_encodeUAString(void)
- {
- Suite *s = suite_create("encodeUAString_test");
- TCase *tc_core = tcase_create("Core");
- tcase_add_test(tc_core, encodeUAString_test);
- suite_add_tcase(s,tc_core);
- return s;
- }
- Suite * testSuite_decodeUAString(void)
- {
- Suite *s = suite_create("decodeUAString_test");
- TCase *tc_core = tcase_create("Core");
- tcase_add_test(tc_core, decodeUAString_test);
- suite_add_tcase(s,tc_core);
- return s;
- }
- Suite* testSuite_encodeDataValue()
- {
- Suite *s = suite_create("encodeDataValue");
- TCase *tc_core = tcase_create("Core");
- tcase_add_test(tc_core, encodeDataValue_test);
- suite_add_tcase(s,tc_core);
- return s;
- }
- Suite* testSuite_expandedNodeId_calcSize(void)
- {
- Suite *s = suite_create("expandedNodeId_calcSize");
- TCase *tc_core = tcase_create("Core");
- tcase_add_test(tc_core,expandedNodeId_calcSize_test);
- suite_add_tcase(s,tc_core);
- return s;
- }
- /*
- Suite* TL_<TESTSUITENAME>(void)
- {
- Suite *s = suite_create("<TESTSUITENAME>");
- TCase *tc_core = tcase_create("Core");
- tcase_add_test(tc_core,<TEST_NAME>);
- suite_add_tcase(s,tc_core);
- return s;
- }
- */
- Suite* testSuite_diagnosticInfo_calcSize()
- {
- Suite *s = suite_create("diagnosticInfo_calcSize");
- TCase *tc_core = tcase_create("Core");
- tcase_add_test(tc_core, diagnosticInfo_calcSize_test);
- suite_add_tcase(s,tc_core);
- return s;
- }
- Suite* testSuite_extensionObject_calcSize()
- {
- Suite *s = suite_create("extensionObject_calcSize");
- TCase *tc_core = tcase_create("Core");
- tcase_add_test(tc_core, extensionObject_calcSize_test);
- suite_add_tcase(s,tc_core);
- return s;
- }
- Suite* testSuite_responseHeader_calcSize()
- {
- Suite *s = suite_create("responseHeader_calcSize");
- TCase *tc_core = tcase_create("Core");
- tcase_add_test(tc_core, responseHeader_calcSize_test);
- suite_add_tcase(s,tc_core);
- return s;
- }
- int main (void)
- {
- int number_failed = 0;
- Suite *s = testSuite_getPacketType();
- SRunner *sr = srunner_create(s);
- srunner_run_all(sr,CK_NORMAL);
- number_failed = srunner_ntests_failed(sr);
- srunner_free(sr);
- s = testSuite_decodeInt16();
- sr = srunner_create(s);
- srunner_run_all(sr,CK_NORMAL);
- number_failed += srunner_ntests_failed(sr);
- srunner_free(sr);
- s = testSuite_encodeInt16();
- sr = srunner_create(s);
- srunner_run_all(sr,CK_NORMAL);
- number_failed += srunner_ntests_failed(sr);
- srunner_free(sr);
- s = testSuite_decodeUInt16();
- sr = srunner_create(s);
- srunner_run_all(sr,CK_NORMAL);
- number_failed += srunner_ntests_failed(sr);
- srunner_free(sr);
- s = testSuite_encodeUInt16();
- sr = srunner_create(s);
- srunner_run_all(sr,CK_NORMAL);
- number_failed += srunner_ntests_failed(sr);
- srunner_free(sr);
- s = testSuite_decodeUInt32();
- sr = srunner_create(s);
- srunner_run_all(sr,CK_NORMAL);
- number_failed += srunner_ntests_failed(sr);
- srunner_free(sr);
- s = testSuite_encodeUInt32();
- sr = srunner_create(s);
- srunner_run_all(sr,CK_NORMAL);
- number_failed += srunner_ntests_failed(sr);
- srunner_free(sr);
- s = testSuite_decodeInt32();
- sr = srunner_create(s);
- srunner_run_all(sr,CK_NORMAL);
- number_failed += srunner_ntests_failed(sr);
- srunner_free(sr);
- s = testSuite_encodeInt32();
- sr = srunner_create(s);
- srunner_run_all(sr,CK_NORMAL);
- number_failed += srunner_ntests_failed(sr);
- srunner_free(sr);
- s = testSuite_decodeUInt64();
- sr = srunner_create(s);
- srunner_run_all(sr,CK_NORMAL);
- number_failed += srunner_ntests_failed(sr);
- srunner_free(sr);
- s = testSuite_encodeUInt64();
- sr = srunner_create(s);
- srunner_run_all(sr,CK_NORMAL);
- number_failed += srunner_ntests_failed(sr);
- srunner_free(sr);
- s = testSuite_decodeInt64();
- sr = srunner_create(s);
- srunner_run_all(sr,CK_NORMAL);
- number_failed += srunner_ntests_failed(sr);
- srunner_free(sr);
- s = testSuite_encodeInt64();
- sr = srunner_create(s);
- srunner_run_all(sr,CK_NORMAL);
- number_failed += srunner_ntests_failed(sr);
- srunner_free(sr);
- s = testSuite_encodeFloat();
- sr = srunner_create(s);
- srunner_run_all(sr,CK_NORMAL);
- number_failed += srunner_ntests_failed(sr);
- srunner_free(sr);
- s = testSuite_encodeDouble();
- sr = srunner_create(s);
- srunner_run_all(sr,CK_NORMAL);
- number_failed += srunner_ntests_failed(sr);
- srunner_free(sr);
- s = testSuite_encodeByte();
- sr = srunner_create(s);
- srunner_run_all(sr,CK_NORMAL);
- number_failed += srunner_ntests_failed(sr);
- srunner_free(sr);
- s = testSuite_encodeUAString();
- sr = srunner_create(s);
- srunner_run_all(sr,CK_NORMAL);
- number_failed += srunner_ntests_failed(sr);
- srunner_free(sr);
- s = testSuite_decodeUAString();
- sr = srunner_create(s);
- srunner_run_all(sr,CK_NORMAL);
- number_failed += srunner_ntests_failed(sr);
- srunner_free(sr);
- s = testSuite_diagnosticInfo_calcSize();
- sr = srunner_create(s);
- srunner_run_all(sr,CK_NORMAL);
- number_failed += srunner_ntests_failed(sr);
- srunner_free(sr);
- s = testSuite_extensionObject_calcSize();
- sr = srunner_create(s);
- srunner_run_all(sr,CK_NORMAL);
- number_failed += srunner_ntests_failed(sr);
- srunner_free(sr);
- s = testSuite_responseHeader_calcSize();
- sr = srunner_create(s);
- srunner_run_all(sr,CK_NORMAL);
- number_failed += srunner_ntests_failed(sr);
- srunner_free(sr);
- s = testSuite_encodeDataValue();
- sr = srunner_create(s);
- srunner_run_all(sr,CK_NORMAL);
- number_failed += srunner_ntests_failed(sr);
- srunner_free(sr);
- s = testSuite_expandedNodeId_calcSize();
- sr = srunner_create(s);
- srunner_run_all(sr,CK_NORMAL);
- number_failed += srunner_ntests_failed(sr);
- srunner_free(sr);
- /* <TESTSUITE_TEMPLATE>
- s = <TESTSUITENAME>;
- sr = srunner_create(s);
- srunner_run_all(sr,CK_NORMAL);
- number_failed += srunner_ntests_failed(sr);
- srunner_free(sr);
- */
- return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
- }
|