-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from lunkpeter/CPPtest
Added test cases for the basic CPP types
- Loading branch information
Showing
16 changed files
with
1,115 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 0 additions & 31 deletions
31
...on.test/src/com/incquerylabs/emdw/cpp/transformation/test/dynamicbehavior/DummyTest.xtend
This file was deleted.
Oops, something went wrong.
103 changes: 103 additions & 0 deletions
103
.../src/com/incquerylabs/emdw/cpp/transformation/test/mappings/CPPAttributeMappingTest.xtend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
package com.incquerylabs.emdw.cpp.transformation.test.mappings | ||
|
||
import com.ericsson.xtumlrt.oopl.cppmodel.CPPAttribute | ||
import com.ericsson.xtumlrt.oopl.cppmodel.CPPClass | ||
import com.ericsson.xtumlrt.oopl.cppmodel.CPPComponent | ||
import com.ericsson.xtumlrt.oopl.cppmodel.CPPModel | ||
import com.incquerylabs.emdw.cpp.transformation.test.wrappers.TransformationWrapper | ||
import org.eclipse.papyrusrt.xtumlrt.common.Model | ||
import org.eclipse.papyrusrt.xtumlrt.common.VisibilityKind | ||
import org.eclipse.papyrusrt.xtumlrt.xtuml.XTClass | ||
import org.eclipse.papyrusrt.xtumlrt.xtuml.XTComponent | ||
import org.eclipse.papyrusrt.xtumlrt.xtuml.XTPackage | ||
import org.junit.runner.RunWith | ||
import org.junit.runners.Parameterized | ||
|
||
import static org.junit.Assert.* | ||
|
||
import static extension com.incquerylabs.emdw.cpp.transformation.test.TransformationTestUtil.* | ||
|
||
@RunWith(Parameterized) | ||
class CPPAttributeInClassTest extends MappingBaseTest<XTClass, CPPClass> { | ||
new(TransformationWrapper wrapper, String wrapperType) { | ||
super(wrapper, wrapperType) | ||
} | ||
|
||
override protected prepareXtUmlModel(Model model) { | ||
val pack = model.createXtPackage("RootPackage") | ||
val component = pack.createXtComponent("Component") | ||
val xtClass = component.createXtClass("Class") | ||
xtClass.createSingleAttribute(xtClass, VisibilityKind.PUBLIC, false, "Attribute") | ||
|
||
xtClass | ||
} | ||
|
||
override protected prepareCppModel(CPPModel cppModel) { | ||
val xtmodel = cppModel.commonModel | ||
val xtPackage = xtmodel.rootPackages.head as XTPackage | ||
val cppPackage = createCPPPackage(cppModel, xtPackage) | ||
val xtComponent = xtPackage.entities.head as XTComponent | ||
val cppComponent = createCPPComponent(cppPackage, xtComponent, null, null, null, null) | ||
val xtClass = xtComponent.ownedClasses.head as XTClass | ||
val cppClass = createCPPClass(cppComponent, xtClass, null, null) | ||
|
||
cppClass | ||
} | ||
|
||
override protected assertResult(Model input, CPPModel result, XTClass xtObject, CPPClass cppObject) { | ||
val xtAttr = xtObject.attributes | ||
val cppAttrs = cppObject.subElements.filter(CPPAttribute) | ||
assertEquals(xtAttr.size,cppAttrs.size) | ||
cppAttrs.forEach[ | ||
assertNotNull(ooplNameProvider) | ||
assertNotNull(commonAttribute) | ||
] | ||
} | ||
|
||
override protected clearXtUmlElement(XTClass xtObject) { | ||
xtObject.attributes.clear | ||
} | ||
|
||
} | ||
|
||
|
||
@RunWith(Parameterized) | ||
class CPPAttributeInComponentTest extends MappingBaseTest<XTComponent, CPPComponent> { | ||
new(TransformationWrapper wrapper, String wrapperType) { | ||
super(wrapper, wrapperType) | ||
} | ||
|
||
override protected prepareXtUmlModel(Model model) { | ||
val pack = model.createXtPackage("RootPackage") | ||
val component = pack.createXtComponent("Component") | ||
val xtClass = component.createXtClass("Class") | ||
component.createSingleAttribute(xtClass, VisibilityKind.PUBLIC, false, "Attribute") | ||
|
||
component | ||
} | ||
|
||
override protected prepareCppModel(CPPModel cppModel) { | ||
val xtmodel = cppModel.commonModel | ||
val xtPackage = xtmodel.rootPackages.head as XTPackage | ||
val cppPackage = createCPPPackage(cppModel, xtPackage) | ||
val xtComponent = xtPackage.entities.head as XTComponent | ||
val cppComponent = createCPPComponent(cppPackage, xtComponent, null, null, null, null) | ||
|
||
cppComponent | ||
} | ||
|
||
override protected assertResult(Model input, CPPModel result, XTComponent xtObject, CPPComponent cppObject) { | ||
val xtAttr = xtObject.attributes | ||
val cppAttrs = cppObject.subElements.filter(CPPAttribute) | ||
assertEquals(xtAttr.size,cppAttrs.size) | ||
cppAttrs.forEach[ | ||
assertNotNull(ooplNameProvider) | ||
assertNotNull(commonAttribute) | ||
] | ||
} | ||
|
||
override protected clearXtUmlElement(XTComponent xtObject) { | ||
xtObject.attributes.clear | ||
} | ||
|
||
} |
153 changes: 153 additions & 0 deletions
153
...test/src/com/incquerylabs/emdw/cpp/transformation/test/mappings/CPPClassMappingTest.xtend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
package com.incquerylabs.emdw.cpp.transformation.test.mappings | ||
|
||
import com.ericsson.xtumlrt.oopl.cppmodel.CPPClass | ||
import com.ericsson.xtumlrt.oopl.cppmodel.CPPComponent | ||
import com.ericsson.xtumlrt.oopl.cppmodel.CPPDirectory | ||
import com.ericsson.xtumlrt.oopl.cppmodel.CPPModel | ||
import com.ericsson.xtumlrt.oopl.cppmodel.CPPPackage | ||
import com.incquerylabs.emdw.cpp.transformation.test.wrappers.TransformationWrapper | ||
import org.eclipse.papyrusrt.xtumlrt.common.Model | ||
import org.eclipse.papyrusrt.xtumlrt.xtuml.XTClass | ||
import org.eclipse.papyrusrt.xtumlrt.xtuml.XTComponent | ||
import org.eclipse.papyrusrt.xtumlrt.xtuml.XTPackage | ||
import org.junit.runner.RunWith | ||
import org.junit.runners.Parameterized | ||
|
||
import static org.junit.Assert.* | ||
|
||
import static extension com.incquerylabs.emdw.cpp.transformation.test.TransformationTestUtil.* | ||
|
||
@RunWith(Parameterized) | ||
class CPPClassInPackageTest extends MappingBaseTest<XTPackage, CPPPackage> { | ||
CPPDirectory rootDir; | ||
|
||
new(TransformationWrapper wrapper, String wrapperType) { | ||
super(wrapper, wrapperType) | ||
} | ||
|
||
override protected prepareXtUmlModel(Model model) { | ||
val pack = model.createXtPackage("RootPackage") | ||
pack.createXtClass("Class") | ||
|
||
pack | ||
} | ||
|
||
override protected prepareCppModel(CPPModel cppModel) { | ||
val res = cppModel.eResource | ||
rootDir = res.createCPPDirectory | ||
val xtmodel = cppModel.commonModel | ||
val xtPackage = xtmodel.rootPackages.head as XTPackage | ||
val cppPackage = createCPPPackage(cppModel, xtPackage) | ||
|
||
cppPackage | ||
} | ||
|
||
override protected assertResult(Model input, CPPModel result, XTPackage xtObject, CPPPackage cppObject) { | ||
val xtClasses = xtObject.entities.filter(XTClass) | ||
val cppClasses = cppObject.subElements.filter(CPPClass) | ||
assertEquals(xtClasses.size,cppClasses.size) | ||
assertEquals(xtClasses.size,rootDir.countCppHeaderFiles) | ||
assertEquals(xtClasses.size,rootDir.countCppBodyFiles) | ||
cppClasses.forEach[ | ||
assertNotNull(ooplNameProvider) | ||
assertNotNull(xtClass) | ||
assertNotNull(headerFile) | ||
assertNotNull(bodyFile) | ||
] | ||
} | ||
|
||
override protected clearXtUmlElement(XTPackage xtObject) { | ||
val classes = xtObject.entities.filter(XTComponent) | ||
xtObject.entities.removeAll(classes) | ||
} | ||
|
||
} | ||
|
||
|
||
@RunWith(Parameterized) | ||
class CPPClassInModelTest extends MappingBaseTest<Model, CPPModel> { | ||
CPPDirectory rootDir; | ||
|
||
new(TransformationWrapper wrapper, String wrapperType) { | ||
super(wrapper, wrapperType) | ||
} | ||
|
||
override protected prepareXtUmlModel(Model model) { | ||
model.createXtClass("Class") | ||
|
||
model | ||
} | ||
|
||
override protected prepareCppModel(CPPModel cppModel) { | ||
val res = cppModel.eResource | ||
rootDir = res.createCPPDirectory | ||
cppModel | ||
} | ||
|
||
override protected assertResult(Model input, CPPModel result, Model xtObject, CPPModel cppObject) { | ||
val xtClasses = xtObject.topEntities.filter(XTClass) | ||
val cppClasses = cppObject.subElements.filter(CPPClass) | ||
assertEquals(xtClasses.size,cppClasses.size) | ||
assertEquals(xtClasses.size,rootDir.countCppHeaderFiles) | ||
assertEquals(xtClasses.size,rootDir.countCppBodyFiles) | ||
cppClasses.forEach[ | ||
assertNotNull(ooplNameProvider) | ||
assertNotNull(xtClass) | ||
assertNotNull(headerFile) | ||
assertNotNull(bodyFile) | ||
] | ||
} | ||
|
||
override protected clearXtUmlElement(Model xtObject) { | ||
val classes = xtObject.topEntities.filter(XTComponent) | ||
xtObject.topEntities.removeAll(classes) | ||
} | ||
|
||
} | ||
|
||
@RunWith(Parameterized) | ||
class CPPClassInComponentTest extends MappingBaseTest<XTComponent, CPPComponent> { | ||
CPPDirectory rootDir; | ||
|
||
new(TransformationWrapper wrapper, String wrapperType) { | ||
super(wrapper, wrapperType) | ||
} | ||
|
||
override protected prepareXtUmlModel(Model model) { | ||
val pack = model.createXtPackage("RootPackage") | ||
val component = pack.createXtComponent("Component") | ||
component.createXtClass("Class") | ||
|
||
component | ||
} | ||
|
||
override protected prepareCppModel(CPPModel cppModel) { | ||
val res = cppModel.eResource | ||
rootDir = res.createCPPDirectory | ||
val xtmodel = cppModel.commonModel | ||
val xtPackage = xtmodel.rootPackages.head as XTPackage | ||
val cppPackage = createCPPPackage(cppModel, xtPackage) | ||
val xtComponent = xtPackage.entities.head as XTComponent | ||
val cppComponent = createCPPComponent(cppPackage, xtComponent, null, null, null, null) | ||
cppComponent | ||
} | ||
|
||
override protected assertResult(Model input, CPPModel result, XTComponent xtObject, CPPComponent cppObject) { | ||
val xtClasses = xtObject.ownedClasses | ||
val cppClasses = cppObject.subElements.filter(CPPClass) | ||
assertEquals(xtClasses.size,cppClasses.size) | ||
assertEquals(xtClasses.size,rootDir.countCppHeaderFiles) | ||
assertEquals(xtClasses.size,rootDir.countCppBodyFiles) | ||
cppClasses.forEach[ | ||
assertNotNull(ooplNameProvider) | ||
assertNotNull(xtClass) | ||
assertNotNull(headerFile) | ||
assertNotNull(bodyFile) | ||
] | ||
} | ||
|
||
override protected clearXtUmlElement(XTComponent xtObject) { | ||
xtObject.ownedClasses.clear | ||
} | ||
|
||
} |
Oops, something went wrong.