diff options
author | Thomas Schuetz | 2012-01-30 15:05:42 +0000 |
---|---|---|
committer | Thomas Schuetz | 2012-01-30 15:05:42 +0000 |
commit | d5afc9c0c42138ac147199ae60193899953869cb (patch) | |
tree | c27b93e12a6cd508f5486a1a2a78f064663f3469 /tests/org.eclipse.etrice.generator.c.tests/src/test | |
parent | 17c0786b480e757f538d5e334e6e5c93f6751a4a (diff) | |
download | org.eclipse.etrice-d5afc9c0c42138ac147199ae60193899953869cb.tar.gz org.eclipse.etrice-d5afc9c0c42138ac147199ae60193899953869cb.tar.xz org.eclipse.etrice-d5afc9c0c42138ac147199ae60193899953869cb.zip |
[generator.c.tests] moved testcases for C-generator to generator.c.tests
Diffstat (limited to 'tests/org.eclipse.etrice.generator.c.tests/src/test')
14 files changed, 636 insertions, 0 deletions
diff --git a/tests/org.eclipse.etrice.generator.c.tests/src/test/generator/RunCGeneratorTestcases.c b/tests/org.eclipse.etrice.generator.c.tests/src/test/generator/RunCGeneratorTestcases.c new file mode 100644 index 000000000..cf2d11e9c --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/src/test/generator/RunCGeneratorTestcases.c @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2011 protos software gmbh (http://www.protos.de). + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * CONTRIBUTORS: + * Thomas Schuetz (initial contribution) + * + *******************************************************************************/ + +/* + * RunCGeneratorTestcases.c + * + * Created on: 12.01.2012 + * Author: tschuetz + */ + +#include "RunCGeneratorTestcases.h" + +#include "TestDataClass.h" +#include "etUnit.h" + + +void RunCGeneratorTestcases(void){ + etUnit_open("tmp/testlog","TestCGenerator"); + TestDataClass_runSuite(); + etUnit_close(); +} diff --git a/tests/org.eclipse.etrice.generator.c.tests/src/test/generator/RunCGeneratorTestcases.h b/tests/org.eclipse.etrice.generator.c.tests/src/test/generator/RunCGeneratorTestcases.h new file mode 100644 index 000000000..03d5c4276 --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/src/test/generator/RunCGeneratorTestcases.h @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2011 protos software gmbh (http://www.protos.de). + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * CONTRIBUTORS: + * Thomas Schuetz (initial contribution) + * + *******************************************************************************/ + + +/* + * RunCGeneratorTestcases.h + * + * Created on: 12.01.2012 + * Author: tschuetz + */ + +#ifndef _RUNCGENERATORTESTCASES_H_ +#define _RUNCGENERATORTESTCASES_H_ + +void RunCGeneratorTestcases(void); + +#endif /* _RUNCGENERATORTESTCASES_H_ */ diff --git a/tests/org.eclipse.etrice.generator.c.tests/src/test/generator/TestDataClass.c b/tests/org.eclipse.etrice.generator.c.tests/src/test/generator/TestDataClass.c new file mode 100644 index 000000000..e3c521dd3 --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/src/test/generator/TestDataClass.c @@ -0,0 +1,67 @@ +/******************************************************************************* + * Copyright (c) 2011 protos software gmbh (http://www.protos.de). + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * CONTRIBUTORS: + * Thomas Schuetz (initial contribution) + * + *******************************************************************************/ + + +/* + * TestDataClass.c + * + * Created on: 12.01.2012 + * Author: tschuetz + */ + + +#include "TestDataClass.h" + +#include "etUnit.h" + +#include "../../../src-gen/cGenRef/DataClass1.h" + +void TestDataClass_Operations(void){ + + DataClass1 d; + d.Attr1 = 123; + d.ComplexAttr.Attr1 = 456; + d.ComplexAttr.Attr2 = (float32)789.123; + d.ComplexAttr.Attr3 = 789; + d.Attr3 = (float32)321.123; + + EXPECT_EQUAL_INT32("Operation DataClass1_MultiplyWithAttr1", 246, DataClass1_MultiplyWithAttr1(&d, 2)); + EXPECT_EQUAL_FLOAT32("Operation DataClass1_MultiplyWithAttr3", (float32)642.246, DataClass1_MultiplyWithAttr3(&d, 2), (float32)0.0001); + +} + + +void TestDataClass_testDataClassDeepCopy(void){ + + DataClass1 d, e; + d.Attr1 = 123; + d.ComplexAttr.Attr1 = 456; + d.ComplexAttr.Attr2 = (float32)789.123; + d.ComplexAttr.Attr3 = 789; + d.Attr3 = (float32)321.123; + + DataClass1_deepCopy(&d,&e); + + EXPECT_EQUAL_INT32("Attr1", 123, e.Attr1); + EXPECT_EQUAL_INT32("ComplexAttr.Attr1", 456, e.ComplexAttr.Attr1); + EXPECT_EQUAL_FLOAT32("ComplexAttr.Attr2", (float32)789.123, e.ComplexAttr.Attr2, 0.001f); + EXPECT_EQUAL_INT32("ComplexAttr.Attr3", 789, e.ComplexAttr.Attr3); + EXPECT_EQUAL_FLOAT32("Attr3", (float32)321.123, e.Attr3, (float32)0.0001); + +} + +void TestDataClass_runSuite(void){ + etUnit_openTestSuite("TestDataClass"); + ADD_TESTCASE(TestDataClass_Operations); + ADD_TESTCASE(TestDataClass_testDataClassDeepCopy); + etUnit_closeTestSuite(); +} diff --git a/tests/org.eclipse.etrice.generator.c.tests/src/test/generator/TestDataClass.h b/tests/org.eclipse.etrice.generator.c.tests/src/test/generator/TestDataClass.h new file mode 100644 index 000000000..3cbce4bc1 --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/src/test/generator/TestDataClass.h @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2011 protos software gmbh (http://www.protos.de). + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * CONTRIBUTORS: + * Thomas Schuetz (initial contribution) + * + *******************************************************************************/ + + +/* + * TestEmDataClass.h + * + * Created on: 12.01.2012 + * Author: tschuetz + */ + +#ifndef _TESTDATACLASS_H_ +#define _TESTDATACLASS_H_ + +void TestDataClass_runSuite(void); + +#endif /* _TESTDATACLASS_H_ */ diff --git a/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/RunCRuntimeTestcases.c b/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/RunCRuntimeTestcases.c new file mode 100644 index 000000000..a9a502f3b --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/RunCRuntimeTestcases.c @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright (c) 2011 protos software gmbh (http://www.protos.de). + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * CONTRIBUTORS: + * Thomas Schuetz (initial contribution) + * + *******************************************************************************/ + + +/* + * RunRuntimeTestcases.c + * + * Created on: 12.01.2012 + * Author: tschuetz + */ + + + +#include "RunCRuntimeTestcases.h" + +#include "TestEtMessage.h" +#include "TestEtMessageQueue.h" +#include "TestEtMessageService.h" +#include "TestEtUnit.h" + +#include "etUnit.h" + + +void RunCRuntimeTestcases(void){ + etUnit_open("tmp/testlog","TestCRuntime"); + + TestEtMessage_runSuite(); + TestEtMessageQueue_runSuite(); + TestEtMessageService_runSuite(); + TestEtUnit_runSuite(); + + etUnit_close(); + + /* special situation for testing openAll and closeAll of etUnit + * this has to be done outside of etUnit_open and etUnit_close */ + etUnit_openAll("tmp/testlog","TestEtUnitSpecial", "etUnit", "openAll and closeAll"); + EXPECT_TRUE("Open and Close", TRUE); + etUnit_closeAll(); +} + diff --git a/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/RunCRuntimeTestcases.h b/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/RunCRuntimeTestcases.h new file mode 100644 index 000000000..5d17f7ddb --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/RunCRuntimeTestcases.h @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2011 protos software gmbh (http://www.protos.de). + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * CONTRIBUTORS: + * Thomas Schuetz (initial contribution) + * + *******************************************************************************/ + + +/* + * RunRuntimeTestcases.h + * + * Created on: 12.01.2012 + * Author: tschuetz + */ + +#ifndef _RUNCRUNTIMETESTCASES_H_ +#define _RUNCRUNTIMETESTCASES_H_ + +void RunCRuntimeTestcases(void); + +#endif /* _RUNCRUNTIMETESTCASES_H_ */ diff --git a/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtMessage.c b/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtMessage.c new file mode 100644 index 000000000..c360b0a84 --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtMessage.c @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (c) 2011 protos software gmbh (http://www.protos.de). + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * CONTRIBUTORS: + * Thomas Schuetz (initial contribution) + * + *******************************************************************************/ + +#include "TestEtMessage.h" + +#include <stddef.h> +#include "etUnit.h" +#include "etMessage.h" + + + +void TestEtMessage_testBasicMessage(void){ + + etMessage msg1 = {(etMessage*)1234567, 123,456,}; + etMessage msg2 = {NULL, 222,333}; + + // basic checks -> detects structure changes that would cause problems for generated code + EXPECT_EQUAL_PTR("Message.next", 1234567, msg1.next); + EXPECT_EQUAL_INT16("Message.address", 123, msg1.address); + EXPECT_EQUAL_INT16("Message.evtID", 456, msg1.evtID); + + // build pointer ring + msg1.next = &msg2; + msg2.next = &msg1; + + EXPECT_EQUAL_INT16("msg1.NextMsg", msg2.evtID, msg1.next->evtID); + EXPECT_EQUAL_INT16("msg2.NextMsg", msg1.evtID, msg2.next->evtID); + +} + +void TestEtMessage_runSuite(void){ + etUnit_openTestSuite("TestMessage"); + ADD_TESTCASE(TestEtMessage_testBasicMessage); + etUnit_closeTestSuite(); +} + diff --git a/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtMessage.h b/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtMessage.h new file mode 100644 index 000000000..67b45e4e1 --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtMessage.h @@ -0,0 +1,20 @@ +/******************************************************************************* + * Copyright (c) 2011 protos software gmbh (http://www.protos.de). + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * CONTRIBUTORS: + * Thomas Schuetz (initial contribution) + * + *******************************************************************************/ + +#ifndef _TESTMESSAGE_H_ +#define _TESTMESSAGE_H_ + + +void TestEtMessage_runSuite(void); + + +#endif /* _TESTMESSAGE_H_ */ diff --git a/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtMessageQueue.c b/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtMessageQueue.c new file mode 100644 index 000000000..3a453962c --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtMessageQueue.c @@ -0,0 +1,99 @@ +/******************************************************************************* + * Copyright (c) 2011 protos software gmbh (http://www.protos.de). + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * CONTRIBUTORS: + * Thomas Schuetz (initial contribution) + * + *******************************************************************************/ + +#include "TestEtMessageQueue.h" +#include "etUnit.h" +#include "etMessageQueue.h" + +void TestEtMessageQueue_testPushPop(void){ + + etMessage msg1 = {NULL, 123, 456}; + etMessage msg2 = {NULL, 222, 333}; + + etMessageQueue queue1; + etMessageQueue_init(&queue1); + + etMessageQueue_push(&queue1, &msg1); + etMessageQueue_push(&queue1, &msg2); + + EXPECT_EQUAL_INT16("etMessageQueue.size before", 2, queue1.size); + EXPECT_EQUAL_INT16("etMessageQueue.highWaterMark before", 2, queue1.highWaterMark); + + etMessage* rcvMsg1 = etMessageQueue_pop(&queue1); + etMessage* rcvMsg2 = etMessageQueue_pop(&queue1); + + EXPECT_EQUAL_INT16("etMessageQueue.size after", 0, queue1.size); + EXPECT_EQUAL_INT16("etMessageQueue.highWaterMark after", 2, queue1.highWaterMark); + + EXPECT_EQUAL_INT16("rcvMsg1->address", 123, rcvMsg1->address); + EXPECT_EQUAL_INT16("rcvMsg1->evtID", 456, rcvMsg1->evtID); + EXPECT_EQUAL_PTR("rcvMsg1->next", NULL, rcvMsg1->next); + + EXPECT_EQUAL_INT16("rcvMsg2->address", 222, rcvMsg2->address); + EXPECT_EQUAL_INT16("rcvMsg2->evtID", 333, rcvMsg2->evtID); + EXPECT_EQUAL_PTR("rcvMsg2->next", NULL, rcvMsg2->next); + + EXPECT_EQUAL_PTR("etMessageQueue->first", NULL, queue1.first); + EXPECT_EQUAL_PTR("etMessageQueue->last", NULL, queue1.last); + + etMessage* rcvMsg3 = etMessageQueue_pop(&queue1); + EXPECT_EQUAL_PTR("etMessageQueue_pop if empty", NULL, rcvMsg3); + +} + +#define MAX 1000 + +void TestEtMessageQueue_testMassiveMessaging(void){ + + etMessage msgArray[MAX]; + + etMessageQueue queue1; + etMessageQueue_init(&queue1); + + int16 i; + for(i=0; i<MAX; i++){ + //etMessage_init(&msgArray[i]); + msgArray[i].address = i; + msgArray[i].evtID = i; + } + + int j; + for(j=0; j<3; j++){ + for (i=0; i<MAX; i++){ + etMessageQueue_push(&queue1, &(msgArray[i])); + } + for (i=0; i<MAX; i++){ + etMessage* msg = etMessageQueue_pop(&queue1); + // EXPECTS are hidden to avoid too many testcases in log + if (msg == NULL){ + EXPECT_FALSE("msg == NULL", TRUE); + break; + } + if (msg->address != msg->evtID){ + EXPECT_FALSE("msg->address != msg->evtID", TRUE); + break; + } + if (msg->address != i){ + EXPECT_FALSE("msg->address != i", TRUE); + break; + } + } + EXPECT_EQUAL_INT32("i==MAX", MAX, i); + } +} + +void TestEtMessageQueue_runSuite(void){ + etUnit_openTestSuite("TestEtMessageQueue"); + ADD_TESTCASE(TestEtMessageQueue_testPushPop); + ADD_TESTCASE(TestEtMessageQueue_testMassiveMessaging); + etUnit_closeTestSuite(); +} diff --git a/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtMessageQueue.h b/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtMessageQueue.h new file mode 100644 index 000000000..afceea8f8 --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtMessageQueue.h @@ -0,0 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2011 protos software gmbh (http://www.protos.de). + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * CONTRIBUTORS: + * Thomas Schuetz (initial contribution) + * + *******************************************************************************/ + +#ifndef _TESTRMESSAGEQUEUE_H_ +#define _TESTRMESSAGEQUEUE_H_ + +void TestEtMessageQueue_runSuite(void); + +#endif /* _TESTRMESSAGEQUEUE_H_ */ diff --git a/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtMessageService.c b/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtMessageService.c new file mode 100644 index 000000000..1d8b6cce8 --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtMessageService.c @@ -0,0 +1,116 @@ +/******************************************************************************* + * Copyright (c) 2011 protos software gmbh (http://www.protos.de). + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * CONTRIBUTORS: + * Thomas Schuetz (initial contribution) + * + *******************************************************************************/ + +#include "TestEtMessageService.h" +#include "etUnit.h" +#include "etMessageService.h" + + +void TestEtMessageService_init(void){ + + etMessageService msgService; + uint16 max = 6; + uint16 blockSize = 32; + + uint8 msgBuffer[max*blockSize]; + + etMessageService_init(&msgService, msgBuffer, max, blockSize); + + EXPECT_EQUAL_PTR("msgService.messagePool.first", msgBuffer, msgService.messagePool.first); + EXPECT_EQUAL_PTR("msgService.messagePool in between", &msgBuffer[3*blockSize], msgService.messagePool.first->next->next->next); + EXPECT_EQUAL_PTR("msgService.messagePool.last(1)", &msgBuffer[5*blockSize], msgService.messagePool.first->next->next->next->next->next); + EXPECT_EQUAL_PTR("msgService.messagePool.last(2)", &msgBuffer[5*blockSize], msgService.messagePool.last); + EXPECT_EQUAL_PTR("msgService.messagePool.last.next", 0, msgService.messagePool.last->next); + +} + +void TestEtMessageService_GetPushPopReturn(void){ + + etMessageService msgService; + uint16 max = 6; + uint16 blockSize = 32; + uint8 msgBuffer[max*blockSize]; + + etMessageService_init(&msgService, msgBuffer, max, blockSize); + + // get messages from pool + etMessage* msg1 = etMessageService_getMessageBuffer(&msgService, sizeof(etMessage)); + etMessage* msg2 = etMessageService_getMessageBuffer(&msgService, sizeof(etMessage)); + + EXPECT_EQUAL_INT16("msgService.messagePool.size", 4, msgService.messagePool.size); + + // define content + msg1->address = 11; + msg1->evtID = 111; + msg2->address = 22; + msg2->evtID = 222; + + // push messages to queue + etMessageService_pushMessage(&msgService, msg2); + etMessageService_pushMessage(&msgService, msg1); + + EXPECT_EQUAL_INT16("msgService.messageQueue.size", 2, msgService.messageQueue.size); + + // pop messages from queue + etMessage* rcvMsg1 = etMessageService_popMessage(&msgService); + etMessage* rcvMsg2 = etMessageService_popMessage(&msgService); + + EXPECT_EQUAL_INT16("msgService.messageQueue.size",0, msgService.messageQueue.size); + + + EXPECT_EQUAL_INT16("msgService.popMessage", 22, rcvMsg1->address); + EXPECT_EQUAL_INT16("msgService.popMessage", 222, rcvMsg1->evtID); + EXPECT_EQUAL_INT16("msgService.popMessage", 11, rcvMsg2->address); + EXPECT_EQUAL_INT16("msgService.popMessage", 111, rcvMsg2->evtID); + + etMessageService_returnMessageBuffer(&msgService, rcvMsg1); + etMessageService_returnMessageBuffer(&msgService, rcvMsg2); + + EXPECT_EQUAL_INT16("msgService.messagePool.size", 6, msgService.messagePool.size); + +} + +void TestEtMessageService_GetReturn(void){ + + etMessageService msgService; + uint16 max = 2; + uint16 blockSize = 32; + uint8 msgBuffer[max*blockSize]; + + etMessageService_init(&msgService, msgBuffer, max, blockSize); + + // get on message too much from pool + etMessage* msg1 = etMessageService_getMessageBuffer(&msgService, sizeof(etMessage)); + etMessage* msg2 = etMessageService_getMessageBuffer(&msgService, sizeof(etMessage)); + etMessage* msg3 = etMessageService_getMessageBuffer(&msgService, sizeof(etMessage)); + EXPECT_TRUE("msgService getMessageBuffer", msg1!=NULL); + EXPECT_TRUE("msgService getMessageBuffer", msg2!=NULL); + EXPECT_EQUAL_PTR("msgService getMessageBuffer", msg3, NULL); + + // return messages + etMessageService_returnMessageBuffer(&msgService, msg1); + etMessageService_returnMessageBuffer(&msgService, msg2); + EXPECT_EQUAL_INT16("msgService.messagePool.size", 2, msgService.messagePool.size); + + // get message bigger than blocksize + etMessage* msg4 = etMessageService_getMessageBuffer(&msgService, 33); + EXPECT_EQUAL_PTR("msgService getMessageBuffer", msg4, NULL); + +} + +void TestEtMessageService_runSuite(void){ + etUnit_openTestSuite("TestEtMessageService"); + ADD_TESTCASE(TestEtMessageService_init); + ADD_TESTCASE(TestEtMessageService_GetPushPopReturn); + ADD_TESTCASE(TestEtMessageService_GetReturn); + etUnit_closeTestSuite(); +} diff --git a/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtMessageService.h b/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtMessageService.h new file mode 100644 index 000000000..43a85baee --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtMessageService.h @@ -0,0 +1,21 @@ +/******************************************************************************* + * Copyright (c) 2011 protos software gmbh (http://www.protos.de). + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * CONTRIBUTORS: + * Thomas Schuetz (initial contribution) + * + *******************************************************************************/ + +#ifndef _TESTRMESSAGESERVICE_H_ +#define _TESTRMESSAGESERVICE_H_ + +#include "etMessageService.h" + +void TestEtMessageService_runSuite(void); + + +#endif /* _TESTRMESSAGESERVICE_H_ */ diff --git a/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtUnit.c b/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtUnit.c new file mode 100644 index 000000000..3f01d0587 --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtUnit.c @@ -0,0 +1,67 @@ +/******************************************************************************* + * Copyright (c) 2011 protos software gmbh (http://www.protos.de). + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * CONTRIBUTORS: + * Thomas Schuetz (initial contribution) + * + *******************************************************************************/ + + +/* + * TestEtUnit.c + * + * Created on: 16.01.2012 + * Author: tschuetz + */ + +#include "TestEtUnit.h" +#include "etUnit.h" + +void TestEtUnit_Expect(void){ + EXPECT_TRUE("EXPECT_TRUE", TRUE); + EXPECT_FALSE("EXPECT_FALSE", FALSE); + + /* signed integer values */ + EXPECT_EQUAL_INT8("EXPECT_EQUAL_INT8", -123, -123); + EXPECT_EQUAL_INT16("EXPECT_EQUAL_INT16", -12345, -12345); + EXPECT_EQUAL_INT32("EXPECT_EQUAL_INT32", -1234567, -1234567); + + /* unsigned integer values */ + EXPECT_EQUAL_UINT8("EXPECT_EQUAL_INT8", 123, 123); + EXPECT_EQUAL_UINT16("EXPECT_EQUAL_INT16", 12345, 12345); + EXPECT_EQUAL_UINT32("EXPECT_EQUAL_INT32", 1234567, 1234567); + + /* float values */ + EXPECT_EQUAL_FLOAT32("EXPECT_EQUAL_FLOAT32", (etFloat32) 123.456, (etFloat32) 123.456, (etFloat32) 0.0001); + EXPECT_EQUAL_FLOAT64("EXPECT_EQUAL_FLOAT64", (etFloat64) 123.456, (etFloat64) 123.456, (etFloat64) 0.0001); + + /* Pointers */ + etUInt16 value; + etUInt16* valuePtr = &value; + + EXPECT_EQUAL_PTR("EXPECT_EQUAL_PTR", &value, valuePtr) \ + +} + + +void TestEtUnit_Expect_Order(void){ + etInt16 list[] = {1,2,3,4}; + EXPECT_ORDER_START(list, 4); + EXPECT_ORDER("id=1", 1); + EXPECT_ORDER("id=2", 2); + EXPECT_ORDER("id=3", 3); + EXPECT_ORDER_END("id=4", 4); +} + +void TestEtUnit_runSuite(void){ + etUnit_openTestSuite("TestEtUnit"); + ADD_TESTCASE(TestEtUnit_Expect_Order); + ADD_TESTCASE(TestEtUnit_Expect); + etUnit_closeTestSuite(); +} + + diff --git a/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtUnit.h b/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtUnit.h new file mode 100644 index 000000000..e591d27ef --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtUnit.h @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2011 protos software gmbh (http://www.protos.de). + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * CONTRIBUTORS: + * Thomas Schuetz (initial contribution) + * + *******************************************************************************/ + + +/* + * TestEtUnit.h + * + * Created on: 16.01.2012 + * Author: tschuetz + */ + +#ifndef _TESTETUNIT_H_ +#define _TESTETUNIT_H_ + +void TestEtUnit_runSuite(void); + +#endif /* _TESTETUNIT_H_ */ |