Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: e3c521dd36d4ad1cbe97522d8f499b9af2ff4943 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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();
}

Back to the top