Docker-in-Docker (DinD) capabilities of public runners deactivated. More info

Commit e0096644 authored by Pierre Aubert's avatar Pierre Aubert
Browse files

Add generic PStmt test

parent ee3cd87d
Pipeline #97144 passed with stages
in 9 minutes and 21 seconds
......@@ -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)
......
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}
)
/***************************************
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;
}
......@@ -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}
)
......@@ -12,7 +12,7 @@ using namespace std;
/** @return true on success, false otherwise
*/
bool testParseCharset(){
std::string fileContent("CharSet csNumber = \"0123456789\";");
std::string fileContent("CharSet csTest = \"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() == "csNumber"){
if(charSet.getName() == "csTest"){
cerr << termGreen() << "Ok for Name" << termDefault() << endl;
}else{
cerr << termRed() << "Wrong name '" << charSet.getName() << "' instead of 'csNumber'" << termDefault() << endl;
cerr << termRed() << "Wrong name '" << charSet.getName() << "' instead of 'csTest'" << 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;
......
......@@ -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->getUntilKeyWithoutPatern("\"");
}else{
std::string charsetName(isCharSetExist());
if(charsetName == ""){
......
......@@ -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();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment