18 PString name(classConfig.
getName()), strConst(
"");
22 fs <<
"///Check the equality between two "+name+
" classes\n";
23 fs <<
"/**\t@param var : variable to be checked\n";
24 fs <<
" * \t@param reference : reference\n";
25 fs <<
" * \t@return true on success, false otherwise\n";
27 fs <<
"bool check"+name+
"Equality";
31 fs <<
"(" + strConst + name +
" & var, " + strConst + name +
" & reference){\n";
32 fs <<
"\tbool b(true);\n";
34 for(PVecClassAttribute::const_iterator it(listAttr.begin()); it != listAttr.end(); ++it){
35 PString attrName(it->getName().firstToUpper());
38 if(isSimpleType || it->getIsPointer() || it->getType() ==
"PString"){
39 fs <<
"\tb &= var.get"+attrName+
"() == reference.get"+attrName+
"();\n";
42 fs <<
"\treturn b;\n";
52 for(PVecClassAttribute::const_iterator it(listAttr.begin()); it != listAttr.end(); ++it){
64 PString name(classConfig.
getName());
65 fs <<
"///Check copy of class "+name+
"\n";
66 fs <<
"void check"+name+
"Copy(){\n";
67 fs <<
"\t"+name+
" reference;\n";
68 fs <<
"\t//Let's use the setters\n";
70 for(PVecClassAttribute::const_iterator it(listAttr.begin()); it != listAttr.end(); ++it){
72 if(defaultValue !=
""){
73 fs <<
"\treference.set"+attrName+
"("+defaultValue+
");\n";
76 fs <<
"\t"+name+
" varCopy(reference);\n";
77 fs <<
"\t"+name+
" varEqual;\n";
78 fs <<
"\tvarEqual = reference;\n";
79 fs <<
"\t"<<mode.
assertCall<<
"(check"+name+
"Equality(varCopy, reference));\n";
80 fs <<
"\t"<<mode.
assertCall<<
"(check"+name+
"EqualityConst(varCopy, reference));\n";
81 fs <<
"\t"<<mode.
assertCall<<
"(check"+name+
"Equality(varEqual, reference));\n";
82 fs <<
"\t"<<mode.
assertCall<<
"(check"+name+
"EqualityConst(varEqual, reference));\n";
153 PString name(classConfig.
getName());
155 fs <<
"\t//Cannot create check"+name+
"Copy() because there is no getter enabled" << std::endl;
159 fs <<
"\t//Cannot create check"+name+
"Copy() because "+name+
" owns a pointer attribute and is not copyable anymore" << std::endl;
162 fs <<
"\tcheck"+name+
"Copy();\n";
void class_createCheckClassEquality(std::ofstream &fs, const PClassConfig &classConfig, bool isConst)
Create the class check.
bool copy_hasPointerAttribute(const PClassConfig &classConfig)
Check if the given class owns at least one pointer attribute.
void class_createTestClassCopy(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode)
Create the class check.
std::vector< PClassAttribute > PVecClassAttribute
virtual void publicMethodDeclaration(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Declaration of public methods.
virtual void publicMethodImplementation(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Implementation of public methods.
CppTraitCopy()
Consctructor of CppTraitCopy.
virtual void testFunction(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Implementation of test function.
virtual ~CppTraitCopy()
Desctructor of CppTraitCopy.
virtual void protectedMethodImplementation(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Implementation of protected methods.
virtual void protectedMethodDeclaration(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Declaration of protected methods.
virtual void testCallFunction(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Call of the test function.
Class to describe a basic class.
const std::vector< PClassAttribute > & getListAttribute() const
Returns the list of attributes of the class.
const PString & getName() const
Returns the class name.
bool getIsEnum() const
Say if the current PClassConfig is an enum.
bool enableGetter
True to enable getters trait generator.
PString assertCall
Assert to be used.
bool enableCopy
True to enable copy trait generator.
PString getTestDefaultValueTypeInCpp(const PString &type)
Get the default value of a type in C++.
bool getIsPointerType(const PString &varType)
Say if a given type is a pointer type (i.e. it ends with a '*').
bool getIsSimpleType(const PString &varType)
Check if the given type is a simple type.