blob: dc3b671a85f2a825355148c86279488cccfe7cb8 [file] [log] [blame]
RoomModel InitializationTest {
import room.basic.types.boolean
import room.basic.types.int16
import room.basic.types.int32
import room.basic.test.TestInstance
async ActorClass InitializationTest {
@TestInstance
Structure {
usercode1 '''
struct structType {
int32 number;
structType* refStruct;
} typedef structType;
class ClassType {
public:
ClassType(bool boolAttr, int32 number) : boolAttr(boolAttr), number(number) {}
bool boolAttr;
int32 number;
};'''
Attribute caseId: int16
// c/c++ struct
Attribute structAttr1: structType
Attribute structAttr2: structType = "{2, NULL}"
Attribute arrayStructAttr [2]: structType = "{{1, NULL}, {2, NULL}}"
// static array
Attribute arrayInt32Attr1 [5]: int32
Attribute arrayInt32Attr2 [5]: int32 = ""
Attribute arrayInt32Attr3 [5]: int32 = "1"
Attribute arrayInt32Attr4 [5]: int32 = "{1, 2, 3, 4, 5}"
// data class
Attribute dataClassAttr1: SubDataClass
Attribute dataClassAttr2: SubDataClass = "true, 2"
// Attribute arrayDataClassAttr[2]: SubDataClass // = "..." init NOT possible
// external class
Attribute extClassAttr1: ClassType
Attribute extClassAttr2: ClassType = "true, 2"
// Attribute arrayExtClassAttr[2] : ClassType // = "..." init NOT possible
}
Behavior {
ctor '''
caseId = etUnit_openAll("log", "InitializationTest", "org.eclipse.etrice.generator.cpp.tests.InitializationTest", "InitializationTest_case");
testInitValues(caseId);'''
dtor '''etUnit_closeAll(caseId);'''
Operation testInitValues(caseId: int16) '''
// c/c++ struct
EXPECT_EQUAL_INT32(caseId, "<|MODEL_LOCATION|>", 1, structAttr1.number);
EXPECT_TRUE(caseId, "<|MODEL_LOCATION|>", structAttr1.refStruct == NULL);
EXPECT_EQUAL_INT32(caseId, "<|MODEL_LOCATION|>", 2, structAttr2.number);
EXPECT_TRUE(caseId, "<|MODEL_LOCATION|>", structAttr2.refStruct == NULL);
EXPECT_EQUAL_INT32(caseId, "<|MODEL_LOCATION|>", 1, arrayStructAttr[0].number);
EXPECT_TRUE(caseId, "<|MODEL_LOCATION|>", arrayStructAttr[0].refStruct == NULL);
EXPECT_EQUAL_INT32(caseId, "<|MODEL_LOCATION|>", 2, arrayStructAttr[1].number);
EXPECT_TRUE(caseId, "<|MODEL_LOCATION|>", arrayStructAttr[1].refStruct == NULL);
// static array
EXPECT_EQUAL_INT32(caseId, "<|MODEL_LOCATION|>", 0, arrayInt32Attr1[0]);
EXPECT_EQUAL_INT32(caseId, "<|MODEL_LOCATION|>", 1, arrayInt32Attr3[0]);
EXPECT_EQUAL_INT32(caseId, "<|MODEL_LOCATION|>", 1, arrayInt32Attr4[0]);
EXPECT_EQUAL_INT32(caseId, "<|MODEL_LOCATION|>", 5, arrayInt32Attr4[4]);
// data class
EXPECT_FALSE(caseId, "<|MODEL_LOCATION|>", dataClassAttr1.boolAttr);
EXPECT_EQUAL_INT32(caseId, "<|MODEL_LOCATION|>", 0, dataClassAttr1.number);
EXPECT_TRUE(caseId, "<|MODEL_LOCATION|>", dataClassAttr2.boolAttr);
EXPECT_EQUAL_INT32(caseId, "<|MODEL_LOCATION|>", 2, dataClassAttr2.number);
// external class
EXPECT_FALSE(caseId, "<|MODEL_LOCATION|>", extClassAttr1.boolAttr);
EXPECT_EQUAL_INT32(caseId, "<|MODEL_LOCATION|>", 0, extClassAttr1.number);
EXPECT_TRUE(caseId, "<|MODEL_LOCATION|>", extClassAttr2.boolAttr);
EXPECT_EQUAL_INT32(caseId, "<|MODEL_LOCATION|>", 2, extClassAttr2.number);'''
StateMachine {
State finish {
entry '''etUnit_testFinished(caseId);'''
}
Transition init: initial -> finish
}
}
}
DataClass BaseDataClass {
Attribute boolAttr: boolean
}
DataClass SubDataClass extends BaseDataClass {
Attribute number: int32
}
ExternalType ClassType -> "ClassType" default "false, 0"
ExternalType structType -> "structType" default "{1, NULL}"
}