Commit 1b4e30ea authored by Johnny Jazeix's avatar Johnny Jazeix
Browse files

Ajout de tests (pas encore fonctionnels).

parent bb8ff737
#include "Date.hpp"
Date::Date(std::string& s){
me = s;
}
std::string &Date::tostring() {
return me;
}
/*!
*
* \file Trace.hpp
* \author NOISETTE
* \brief Bouchon
*
*
*
*/
#include "Trace.hpp"
#include <iostream>
void Trace::define_container_type(String container_type_parent, Name alias){
std::cout<<"define_container_type "<< container_type_parent.tostring() << " " << alias.tostring()<<std::endl;
}
Trace Trace::create_container(Date time, Name alias, String container, String parent){
std::cout<<"create_container "<< time.tostring() << alias.tostring()<<std::endl;
}
void Trace::destroy_container(Date time, Name alias, String type){
std::cout<<"destroy_container " << time.tostring() << " " << alias.tostring() << " " << type.tostring() << std::endl;
}
void Trace::define_event_type(Name alias, String container_type){
std::cout<<"define_event_type " << alias.tostring()<< " " << container_type.tostring()<<std::endl;
}
void Trace::define_state_type(Name alias, String container_type){
std::cout<<"define_state_type " << alias.tostring() << " " << container_type.tostring() << std::endl;
}
void Trace::define_variable_type(Name alias, String container_type){
std::cout<<"define_variable_type " << alias.tostring() << " " << container_type.tostring() << std::endl;
}
void Trace::define_link_type(Name alias, String container_type_ancestor, String type_container_source, String type_container_destination){
std::cout<<"define_link_type "<< alias.tostring() << " " << container_type_ancestor.tostring() << " " << type_container_source.tostring() << " " << type_container_destination.tostring()<< std::endl;
}
void Trace::define_entity_value(Name alias, String entity_type){
std::cout<<"define_entity_value " << alias.tostring() << " " << entity_type.tostring() << std::endl;
}
void Trace::set_state(Date time, String type, String container, String value){
std::cout<<"set_state " << time.tostring() << " " << type.tostring() << " " << container.tostring() << " " << value.tostring() << std::endl;
}
void Trace::push_state(Date time, String type, String container, String value){
std::cout<<"push_state " << time.tostring() << " " << type.tostring() << " " << container.tostring() << " " << value.tostring() << std::endl;
}
void Trace::pop_state(Date time, String type, String container){
std::cout<<"pop_state " << time.tostring() << " " << type.tostring() << " " << container.tostring() << " " << std::endl;
}
void Trace::new_event(Date time, String type, String container, String value){
std::cout<<"new_event " << time.tostring() << " " << type.tostring() << " " << container.tostring() << " " << value.tostring() << std::endl;
}
void Trace::set_variable(Date time, String type, String container, double value){
std::cout<<"set_variable " << time.tostring() << " " << type.tostring() << " " << container.tostring() << " " << value << std::endl;
}
void add_variable(Date time, String type, String container, double value){
std::cout<<"add_variable " << time.tostring() << " " << type.tostring() << " " << container.tostring() << " " << value << std::endl;
}
void Trace::sub_variable(Date time, String type, String container, double value){
std::cout<<"sub_variable " << time.tostring() << " " << type.tostring() << " " << container.tostring() << " " << value << std::endl;
}
void Trace::start_link(Date time, String type, String container, String src, String value, String key){
std::cout<<"start_link " << time.tostring() << " " << type.tostring() << " " << container.tostring() << " " << src.tostring() << " " << value.tostring() << " " << key.tostring() << std::endl;
}
void Trace::end_link(Date time, String type, String container, String dest, String value, String key){
std::cout<<"end_link "<< time.tostring() << " " << type.tostring() << " " << container.tostring() << " " << value.tostring() << " " << key.tostring() << std::endl;
}
#ifndef TRACE
#define TRACE
#include "String.hpp"
#include "Name.hpp"
#include "Date.hpp"
/*!
*
* \file Trace.hpp
* \author NOISETTE
* \brief Bouchon
*
*
*
*/
class Trace{
public :
/*!
*
*\fn define_container_type()
*\brief This function is to define a container type
*
*\param String : the type of his parent container
* Name : an object that can contain a name, an alias or both
*/
void define_container_type(String container_type_parent, Name alias);
/*!
*
*\fn create_container()
*\brief This function is to create a container
*
*
*\param
* Date :
* Name : an object that can contain a name, an alias or both
* String : the type of the container
* String : the parent of the container
*/
Trace create_container(Date time, Name alias, String container, String parent);
/*!
*
*\fn destroy_container()
*\brief This function is to destroy a container
*
*\param
* Date :
* Name : an object that can contain a name, an alias or both
* String : the type of the container
*/
void destroy_container(Date time, Name alias, String type);
/*!
*
*\fn define_event_type()
*\brief This function is to define a type of event
*
*\param
* Name : an object that can contain a name, an alias or both
* String : the type of the container
*/
void define_event_type(Name alias, String container_type);
/*!
*
*\fn define_state_type()
*\brief This function is to define a type of state
*
*\param
* Name : an object that can contain a name, an alias or both
* String : the type of the container
*
*/
void define_state_type(Name alias, String container_type);
/*!
*
*\fn define_variable_type()
*\brief This function is to define a type of variable
*
*\param
* Name : an object that can contain a name, an alias or both
* String : the type of the container
*
*/
void define_variable_type(Name alias, String container_type);
/*!
*
*\fn define_link_type()
*\brief This function is to define a type of link
*
*\param
* Name : an object that can contain a name, an alias or both
* String : the type of the container that is the common ancestor of both container
* String : the type of the container where the link starts
* String : the type of the container where the link goes
*
*/
void define_link_type(Name alias, String container_type_ancestor, String type_container_source, String type_container_destination);
/*!
*
*\fn define_entity_value()
*\brief This function is to define_entity_value
*
*\param
* Name : an object that can contain a name, an alias or both
* String : the type of the entity
*
*/
void define_entity_value(Name alias, String entity_type);
/*!
*
*\fn set_state()
*\brief This function is to set a state
*
*\param
* Date :
* String : the type of the entity
* String : the container
* String : the new value of the state
*
*/
void set_state(Date time, String type, String container, String value);
/*!
*
*\fn push_state()
*\brief This function is to push a state on the stack
*
*\param
* Date :
* String : the type of the entity
* String : the container
* String : the new value of the state
*
*/
void push_state(Date time, String type, String container, String value);
/*!
*
*\fn pop_state()
*\brief This function is to pop a state from the stack
*
*\param
* Date :
* String : the type of the entity
* String : the container
*
*/
void pop_state(Date time, String type, String container);
/*!
*
*\fn new_event()
*\brief This function is to create a new event
*
*\param
* Date :
* String : the type of the entity
* String : the container
* String : the value of the event
*
*/
void new_event(Date time, String type, String container, String value);
/*!
*
*\fn set_variable()
*\brief This function is to set a value to the variable
*
*\param
* Date :
* String : the type of the entity
* String : the container
* double : the value of the variable
*/
void set_variable(Date time, String type, String container, double value);
/*!
*
*\fn add_variable()
*\brief This function is to add a new variable
*
*\param
* Date :
* String : the type of the entity
* String : the container
* double : the value of the variable
*
*/
void add_variable(Date time, String type, String container, double value);
/*!
*
*\fn sub_variable()
*\brief This function is to substract a value to the variable
*
*\param
* Date :
* String : the type of the entity
* String : the container
* double : the value of the variable
*
*/
void sub_variable(Date time, String type, String container, double value);
/*!
*
*\fn start_link()
*\brief This function is to start a link
*
*\param
* Date :
* String : the type of the entity
* String : the container
* String : the source of the link
* String : the value of the variable
*
*/
void start_link(Date time, String type, String container, String src, String value, String key);
/*!
*
*\fn end_link()
*\brief This function is to end a link
*
*\param
* Date :
* String : the type of the entity
* String : the container
* String : the destination of the link
* String : the value of the variable
*
*/
void end_link(Date time, String type, String container, String dest, String value, String key);
};//end class
#endif
......@@ -29,7 +29,10 @@ cout << "-" <<endl ;
Line::~Line(){}
bool Line::starts_with(const string & s) const{
if(!_tokens.empty())
return _tokens[0] == s;
else // tokens is empty
return false;
}
......@@ -75,7 +78,9 @@ bool Line::eof(){
return _eof;
}
void Line::newline(){
clear();
if(!_tokens.empty()){
clear();
}
char *tok;
string str;
......
......@@ -7,7 +7,7 @@
#include <fstream>
#include "TokenSource.hpp"
#define BUFFSIZE 256
/*! \class Line Line.hpp "../parser/src/Line.hpp"
* Contains the definition of a line.
......@@ -34,7 +34,7 @@ public:
* \param : A reference of the line to be copied
*/
Line(Line &);
Line(string &filename);
Line(string &filename);
Line(const char* filename);
/*!
* \brief Destructor
......@@ -54,7 +54,7 @@ public:
*/
bool eof();
bool eof();
void newline();
......
......@@ -5,7 +5,7 @@ ParserEventDecoder::ParserEventDecoder(){
}
void ParserEventDecoder::sort_definition(Definition& d,Line& line){
//void ParserEventDecoder::sort_definition(Definition& d,Line& line){
}
//}
......@@ -12,7 +12,7 @@
#include "../../values/integer.hpp"
#include "../../values/name.hpp"
#include "../../values/string.hpp"
#include "../../structureDonnee/trace.hpp"
// #include "../../structureDonnee/trace.hpp"
/**
* \class ParserEventDecoder
......@@ -27,7 +27,8 @@ private:
public:
ParserEventDecoder();
void store_event(Definition &, Line &, Trace &);
void store_event(Definition &, Line &// , Trace &
);
......
......@@ -3,8 +3,8 @@
using namespace std;
void ParserPaje::parse(string filename, Trace &trace){
ParserDefinitionDecoder parser_definition_decoder;
//ParserEventDecoder* parser_event_decoder = new ParserEventDecoder(&parser_definition_decoder);
ParserDefinitionDecoder parser_definition_decoder;
ParserEventDecoder* parser_event_decoder = new ParserEventDecoder();
Line line(filename);
......@@ -22,8 +22,8 @@ void ParserPaje::parse(string filename, Trace &trace){
else{
std::cout<<"ligne de type 2"<<endl;
// new event
//parser_event_decoder.store_event(line, file, trace);
// trace;
//parser_event_decoder.store_event(line, file, trace);
// trace;
}
}
......
......@@ -2,7 +2,7 @@
#define PARSERPAJE_HPP
#include <string>
#include "../Bouchon/trace.hpp"
#include "../tests/stub/trace.hpp"
#include "ParserDefinitionDecoder.hpp"
#include "ParserEventDecoder.hpp"
......@@ -22,6 +22,10 @@ public:
* \param : the structure of data to fill
*/
void parse(std::string filename, Trace &trace);
};
#endif // PARSERPAJE_HPP
......
CC = g++
LD = g++
OBJ = ../src/Line.o ../src/ParserDefinitionDecoder.o ../src/Definition.o ../src/TokenSource.o ../src/ParserEventDecoder.o
OBJ = ../src/Line.o ../src/ParserDefinitionDecoder.o ../src/Definition.o ../src/TokenSource.o ../src/ParserPaje.o
OPT = -g -Wall -W
all: test_token test_parser
all: test_token test_parser_definition test_parser_global
test_token: test_token.cpp $(OBJ)
$(CC) $(OPT) -o $@ $^
test_parser: test_parser.cpp $(OBJ)
test_parser_definition: test_parser_definition.cpp $(OBJ)
$(CC) $(OPT) -o $@ $^
test_parser_global: test_parser_global.cpp $(OBJ)
$(CC) $(OPT) -o $@ $^
$(OBJ):%.o: %.cpp %.hpp
......
#include "date.hpp"
Date::Date(std::string &s){
me = s;
}
std::string &Date::tostring() {
return me;
}
#ifndef DATE_H
#define DATE_H
#ifndef DATE_HPP
#define DATE_HPP
#include <iostream>
/*!
*
* \file Trace.hpp
* \file date.hpp
* \author NOISETTE
* \brief Bouchon
*
*
*
*/
class Date{
std::string me;
public:
Date(std::string&);
std::string &tostring();
private:
std::string me;
public:
Date(std::string &);
std::string &tostring();
};
#endif
#endif // DATE_HPP
#include "Name.hpp"
#include "name.hpp"
Name::Name(std::string& s){
me = s;
me = s;
}
std::string &Name::tostring() {
std::string &Name::tostring() {
return me;
}
#ifndef NAME
#define NAME
#ifndef NAME_HPP
#define NAME_HPP
#include <iostream>
/*!
*
* \file Trace.hpp
* \file name.hpp
* \author NOISETTE
* \brief Bouchon
*
*
*
*/
class Name{
std::string me;
private:
std::string me;
public:
Name(std::string&);
std::string &Name::tostring();
Name(std::string&);
std::string &tostring();
};
#endif
#endif // NAME_HPP
#include "String.hpp"
#include "string.hpp"
String::String(std::string& s){
me = s;
me = s;
}
std::string &String::tostring() {
return me;
}
#ifndef STRING
#define STRING
#ifndef STRING_HPP
#define STRING_HPP
#include <iostream>
/*!
*