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
ParserGenerator
Commits
e0096644
Commit
e0096644
authored
Dec 23, 2020
by
Pierre Aubert
Browse files
Add generic PStmt test
parent
ee3cd87d
Pipeline
#97144
passed with stages
in 9 minutes and 21 seconds
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
99 additions
and
6 deletions
+99
-6
TESTS/CMakeLists.txt
TESTS/CMakeLists.txt
+2
-0
TESTS/TEST_GENERIC_STMT/CMakeLists.txt
TESTS/TEST_GENERIC_STMT/CMakeLists.txt
+12
-0
TESTS/TEST_GENERIC_STMT/main.cpp
TESTS/TEST_GENERIC_STMT/main.cpp
+71
-0
TESTS/TEST_PARSE_CHARSET/CMakeLists.txt
TESTS/TEST_PARSE_CHARSET/CMakeLists.txt
+5
-0
TESTS/TEST_PARSE_CHARSET/main.cpp
TESTS/TEST_PARSE_CHARSET/main.cpp
+5
-5
src/GraphParser/PGraphParser.cpp
src/GraphParser/PGraphParser.cpp
+1
-1
src/Stmt/PStmt.h
src/Stmt/PStmt.h
+3
-0
No files found.
TESTS/CMakeLists.txt
View file @
e0096644
...
...
@@ -3,9 +3,11 @@ cmake_minimum_required(VERSION 3.0)
include
(
callTestParserDecGenerator.cmake
)
set
(
DEPENDENCIES_GENERIC_STMT phoenix_parser_stmt string_utils
)
set
(
DEPENDENCIES_GRAPH_PARSER phoenix_parser_graph_parser phoenix_parser_representation file_parser option_parser string_utils
)
set
(
DEPENDENCIES_GRAPH_CPP_BACKEND phoenix_parser_cpp_backend phoenix_parser_representation string_utils
)
add_subdirectory
(
TEST_GENERIC_STMT
)
add_subdirectory
(
TEST_PARSE_CHARSET
)
add_subdirectory
(
TEST_SHADOK_LIST
)
add_subdirectory
(
TEST_C_ENUM
)
...
...
TESTS/TEST_GENERIC_STMT/CMakeLists.txt
0 → 100644
View file @
e0096644
project
(
Phoenix
)
cmake_minimum_required
(
VERSION 3.0
)
add_executable
(
test_parser_generator_generic_stmt main.cpp
)
target_link_libraries
(
test_parser_generator_generic_stmt
${
DEPENDENCIES_GENERIC_STMT
}
)
add_test
(
NAME TestParserGenericStmt
COMMAND
${
CMAKE_CURRENT_BINARY_DIR
}
/test_parser_generator_generic_stmt
WORKING_DIRECTORY
${
CMAKE_CURRENT_BINARY_DIR
}
)
TESTS/TEST_GENERIC_STMT/main.cpp
0 → 100644
View file @
e0096644
/***************************************
Auteur : Pierre Aubert
Mail : aubertp7@gmail.com
Licence : CeCILL-C
****************************************/
#include "PStmt.h"
using
namespace
std
;
///Test the const PStmt
/** @param stmtA : PStmt to be checked
* @return true on success, false otherwise
*/
bool
testConstPStmt
(
const
PStmt
&
stmtA
){
bool
b
(
true
);
b
&=
stmtA
.
size
()
==
3lu
;
for
(
PStmt
::
const_iterator
it
(
stmtA
.
begin
());
it
!=
stmtA
.
end
();
++
it
){
b
&=
it
->
getSign
();
b
&=
it
->
isType
(
STMT_NONE
);
b
&=
it
->
getType
()
==
STMT_NONE
;
b
&=
it
->
getVecStmt
().
size
()
==
0lu
;
}
b
&=
stmtA
.
front
().
isType
(
STMT_NONE
);
b
&=
stmtA
.
back
().
isType
(
STMT_NONE
);
return
b
;
}
///Test the PStmt
/** @return true on success, false otherwise
*/
bool
testParsePStmt
(){
PStmt
stmtA
,
stmtB
;
stmtA
.
setSign
(
true
);
PVecStmt
vecStmt
;
vecStmt
.
push_back
(
stmtB
);
stmtA
.
setVecStmt
(
vecStmt
);
stmtA
.
addStmt
(
vecStmt
);
stmtA
.
push_back
(
vecStmt
);
bool
b
(
true
);
b
&=
stmtA
.
size
()
==
3lu
;
for
(
PStmt
::
iterator
it
(
stmtA
.
begin
());
it
!=
stmtA
.
end
();
++
it
){
b
&=
it
->
getSign
();
b
&=
it
->
isType
(
STMT_NONE
);
b
&=
it
->
getType
()
==
STMT_NONE
;
b
&=
it
->
getVecStmt
().
size
()
==
0lu
;
}
b
&=
stmtA
.
front
().
isType
(
STMT_NONE
);
b
&=
stmtA
.
back
().
isType
(
STMT_NONE
);
b
&=
testConstPStmt
(
stmtA
);
stmtA
.
clear
();
return
b
;
}
int
main
(
int
argc
,
char
**
argv
){
bool
b
(
true
);
b
&=
testParsePStmt
();
return
b
-
1
;
}
TESTS/TEST_PARSE_CHARSET/CMakeLists.txt
View file @
e0096644
...
...
@@ -4,3 +4,8 @@ cmake_minimum_required(VERSION 3.0)
add_executable
(
test_parser_generator_parse_charset main.cpp
)
target_link_libraries
(
test_parser_generator_parse_charset
${
DEPENDENCIES_GRAPH_PARSER
}
)
add_test
(
NAME TestParserCharset
COMMAND
${
CMAKE_CURRENT_BINARY_DIR
}
/test_parser_generator_parse_charset
WORKING_DIRECTORY
${
CMAKE_CURRENT_BINARY_DIR
}
)
TESTS/TEST_PARSE_CHARSET/main.cpp
View file @
e0096644
...
...
@@ -12,7 +12,7 @@ using namespace std;
/** @return true on success, false otherwise
*/
bool
testParseCharset
(){
std
::
string
fileContent
(
"CharSet cs
Number
=
\"
0123456789
\"
;"
);
std
::
string
fileContent
(
"CharSet cs
Test
=
\"
0123456789
\"
;"
);
std
::
string
fileName
(
"testCharset.txt"
);
if
(
!
saveFileContent
(
fileName
,
fileContent
)){
cerr
<<
"testParseCharset : can't save file '"
<<
fileName
<<
"'"
<<
endl
;
...
...
@@ -31,15 +31,15 @@ bool testParseCharset(){
return
false
;
}
PCharSet
&
charSet
=
vecCharSet
.
back
();
if
(
charSet
.
getName
()
==
"cs
Number
"
){
if
(
charSet
.
getName
()
==
"cs
Test
"
){
cerr
<<
termGreen
()
<<
"Ok for Name"
<<
termDefault
()
<<
endl
;
}
else
{
cerr
<<
termRed
()
<<
"Wrong name '"
<<
charSet
.
getName
()
<<
"' instead of 'cs
Number
'"
<<
termDefault
()
<<
endl
;
cerr
<<
termRed
()
<<
"Wrong name '"
<<
charSet
.
getName
()
<<
"' instead of 'cs
Test
'"
<<
termDefault
()
<<
endl
;
}
if
(
charSet
.
getCharSet
()
==
"
\
"
0123456789
\"
"
){
if
(
charSet
.
getCharSet
()
==
"0123456789"
){
cerr
<<
termGreen
()
<<
"Ok for charset"
<<
termDefault
()
<<
endl
;
}
else
{
cerr
<<
termRed
()
<<
"Wrong charset '"
<<
charSet
.
getCharSet
()
<<
"' instead of '
\"
0123456789
\"
'"
<<
termDefault
()
<<
endl
;
cerr
<<
termRed
()
<<
"Wrong charset '"
<<
charSet
.
getCharSet
()
<<
"' instead of '0123456789'"
<<
termDefault
()
<<
endl
;
}
return
true
;
...
...
src/GraphParser/PGraphParser.cpp
View file @
e0096644
...
...
@@ -194,7 +194,7 @@ std::string PGraphParser::getCharSetContent(const std::string & endCharset){
content
+=
" + "
;
}
}
content
+=
getStrComposedOf
(
p_charsetName
)
+
p_parser
->
getUntilKey
(
"
\"
"
);
content
+=
getStrComposedOf
(
p_charsetName
)
+
p_parser
->
getUntilKey
WithoutPatern
(
"
\"
"
);
}
else
{
std
::
string
charsetName
(
isCharSetExist
());
if
(
charsetName
==
""
){
...
...
src/Stmt/PStmt.h
View file @
e0096644
...
...
@@ -42,6 +42,9 @@ class PStmt{
const
PStmt
&
front
()
const
;
PStmt
&
front
();
typedef
std
::
vector
<
PStmt
>::
const_iterator
const_iterator
;
typedef
std
::
vector
<
PStmt
>::
iterator
iterator
;
std
::
vector
<
PStmt
>::
const_iterator
begin
()
const
;
std
::
vector
<
PStmt
>::
iterator
begin
();
...
...
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