Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
CTA-LAPP
PHOENIX_LIBS
PhoenixGenerator
Commits
271ad962
Commit
271ad962
authored
Dec 26, 2020
by
Pierre Aubert
Browse files
Add class config test
parent
5739316b
Pipeline
#98115
passed with stages
in 25 minutes
Changes
5
Pipelines
11
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
152 additions
and
1 deletion
+152
-1
TESTS/CMakeLists.txt
TESTS/CMakeLists.txt
+1
-0
TESTS/TEST_CLASS_CONFIG/CMakeLists.txt
TESTS/TEST_CLASS_CONFIG/CMakeLists.txt
+13
-0
TESTS/TEST_CLASS_CONFIG/main.cpp
TESTS/TEST_CLASS_CONFIG/main.cpp
+118
-0
src/class_attribute_utils.cpp
src/class_attribute_utils.cpp
+19
-0
src/class_attribute_utils.h
src/class_attribute_utils.h
+1
-1
No files found.
TESTS/CMakeLists.txt
View file @
271ad962
project
(
Phoenix
)
cmake_minimum_required
(
VERSION 2.8
)
add_subdirectory
(
TEST_CLASS_CONFIG
)
TESTS/TEST_CLASS_CONFIG/CMakeLists.txt
0 → 100644
View file @
271ad962
project
(
Phoenix
)
cmake_minimum_required
(
VERSION 2.8
)
add_executable
(
test_pclass_config main.cpp
)
target_link_libraries
(
test_pclass_config phoenix_generator file_parser string_utils
)
add_test
(
NAME TestPClassConfig
COMMAND
${
CMAKE_CURRENT_BINARY_DIR
}
/test_pclass_config
WORKING_DIRECTORY
${
CMAKE_CURRENT_BINARY_DIR
}
)
TESTS/TEST_CLASS_CONFIG/main.cpp
0 → 100644
View file @
271ad962
/***************************************
Auteur : Pierre Aubert
Mail : aubertp7@gmail.com
Licence : CeCILL-C
****************************************/
#include <iostream>
#include "class_attribute_utils.h"
#include "saveClassConfig.h"
///Print PClassAttribute
/** @param[out] attr : PClassAttribute to be printed
*/
void
printPClassAttribute
(
PClassAttribute
&
attr
){
std
::
cout
<<
"PClassAttribute(type = '"
<<
attr
.
getType
()
<<
"', name = '"
<<
attr
.
getName
()
<<
"', isPointer = "
<<
attr
.
getIsPointer
()
<<
", isReference = "
<<
attr
.
getIsReference
()
<<
", doc = '"
<<
attr
.
getDocumentation
()
<<
"'"
<<
std
::
endl
;
}
///Print PClassAttribute
/** @param[out] attr : PClassAttribute to be printed
*/
void
printPClassAttributeConst
(
const
PClassAttribute
&
attr
){
std
::
cout
<<
"const PClassAttribute(type = '"
<<
attr
.
getType
()
<<
"', name = '"
<<
attr
.
getName
()
<<
"', isPointer = "
<<
attr
.
getIsPointer
()
<<
", isReference = "
<<
attr
.
getIsReference
()
<<
", doc = '"
<<
attr
.
getDocumentation
()
<<
"'"
<<
std
::
endl
;
}
///Test the PClassConfig
/** @return true on success, false otherwise
*/
bool
testClassConfig
(){
bool
b
(
true
);
PClassConfig
conf
;
PClassAttribute
attrA
(
createClassAttribute
(
"int"
,
"attr1"
,
"some attribute doc"
)),
attrB
,
attrC
,
attrD
;
attrB
=
createClassAttribute
(
"int"
,
"attr2"
,
false
,
true
,
"some attribute doc"
);
attrC
=
createClassAttribute
(
"double"
,
"attr3"
,
true
,
false
,
"some attribute doc"
);
attrD
=
createClassAttribute
(
"float"
,
"attr4"
,
true
,
true
,
"some attribute doc"
);
printPClassAttribute
(
attrA
);
printPClassAttributeConst
(
attrA
);
conf
.
setClassDocumentation
(
"Some documentation of the class"
);
conf
.
setName
(
"Shadok"
);
std
::
list
<
PClassAttribute
>
listAttribute1
,
listAttribute2
;
listAttribute1
.
push_back
(
attrA
);
listAttribute1
.
push_back
(
attrB
);
listAttribute2
.
push_back
(
attrD
);
conf
.
setListAttribute
(
listAttribute1
);
conf
.
addAttribute
(
attrC
);
conf
.
addListAttribute
(
listAttribute2
);
std
::
list
<
PClassConfig
>
listClassConfig
;
listClassConfig
.
push_back
(
conf
);
b
&=
saveClassImplDecl
(
listClassConfig
,
"Shadok"
);
return
b
;
}
///Test the PClassConfig
/** @return true on success, false otherwise
*/
bool
testClassConfigInheritance
(){
bool
b
(
true
);
PClassConfig
conf
;
PClassAttribute
attrA
(
createClassAttribute
(
"int"
,
"attr1"
,
false
,
false
,
"some attribute doc"
)),
attrB
,
attrC
,
attrD
;
attrB
=
createClassAttribute
(
"int"
,
"attr2"
,
false
,
true
,
"some attribute doc"
);
attrC
=
createClassAttribute
(
"double"
,
"attr3"
,
true
,
false
,
"some attribute doc"
);
attrD
=
createClassAttribute
(
"float"
,
"attr4"
,
true
,
true
,
"some attribute doc"
);
printPClassAttribute
(
attrA
);
printPClassAttributeConst
(
attrA
);
conf
.
setClassDocumentation
(
"Some documentation of the class"
);
conf
.
setName
(
"Shadok"
);
conf
.
addParentClass
(
"SomeParent"
);
std
::
list
<
std
::
string
>
listParentClass
;
listParentClass
.
push_back
(
"OtherParent"
);
listParentClass
.
push_back
(
"OtherParent2"
);
conf
.
addListParentClass
(
listParentClass
);
std
::
list
<
PClassAttribute
>
listAttribute1
,
listAttribute2
;
listAttribute1
.
push_back
(
attrA
);
listAttribute1
.
push_back
(
attrB
);
listAttribute2
.
push_back
(
attrD
);
conf
.
setListAttribute
(
listAttribute1
);
conf
.
addAttribute
(
attrC
);
conf
.
addListAttribute
(
listAttribute2
);
std
::
list
<
PClassConfig
>
listClassConfig
;
listClassConfig
.
push_back
(
conf
);
std
::
list
<
std
::
string
>
listInclude
;
listInclude
.
push_back
(
"SomeParent"
);
listInclude
.
push_back
(
"OtherParent"
);
listInclude
.
push_back
(
"OtherParent2"
);
b
&=
saveClassImplDecl
(
listClassConfig
,
"ShadokParent"
,
listInclude
);
return
b
;
}
int
main
(
int
argc
,
char
**
argv
){
bool
b
(
testClassConfig
());
b
&=
testClassConfigInheritance
();
return
b
-
1
;
}
src/class_attribute_utils.cpp
View file @
271ad962
...
...
@@ -20,4 +20,23 @@ PClassAttribute createClassAttribute(const std::string & type, const std::string
return
attr
;
}
///Create an attribute
/** @param typeName : type of the attribute
* @param name : name of the attribute
* @param isPointer : true if the attribute is a pointer
* @param isReference : true if the attribute is a reference
* @param documentation : documentation of the attribute
* @return PClassAttribute
*/
PClassAttribute
createClassAttribute
(
const
std
::
string
&
typeName
,
const
std
::
string
&
name
,
bool
isPointer
,
bool
isReference
,
const
std
::
string
&
documentation
){
PClassAttribute
attr
;
attr
.
setType
(
typeName
);
attr
.
setName
(
name
);
attr
.
setIsPointer
(
isPointer
);
attr
.
setIsReference
(
isReference
);
attr
.
setDocumentation
(
documentation
);
return
attr
;
}
src/class_attribute_utils.h
View file @
271ad962
...
...
@@ -10,6 +10,6 @@
#include "PClassAttribute.h"
PClassAttribute
createClassAttribute
(
const
std
::
string
&
type
,
const
std
::
string
&
name
,
const
std
::
string
&
documentation
=
""
);
PClassAttribute
createClassAttribute
(
const
std
::
string
&
typeName
,
const
std
::
string
&
name
,
bool
isPointer
,
bool
isReference
,
const
std
::
string
&
documentation
);
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment