Commit 03bee25f authored by Johnny Jazeix's avatar Johnny Jazeix

Créé un dossier stubs (bouchons) pour les tests et fait en sorte qu'ils

compilent et fonctionnent.
parent cdb0d249
......@@ -3,7 +3,7 @@
#include <sstream>
#ifndef TEST_MESSAGE
#ifndef VITE_DEBUG
/* Release mode */
#include "../interface/interface.hpp"
......@@ -22,6 +22,10 @@ public:
void information(const std::string& s) {
std::cerr <<"INFORMATION: " << s << std::endl;
}
std::string get_filename(){
return "filename ";
}
};
#endif
......
......@@ -19,7 +19,7 @@ class Line{
private:
std::vector<std::string> _tokens;
TokenSource::TokenSource _source;
TokenSource _source;
bool _is_eof;
unsigned int _line_count;
......
......@@ -3,7 +3,12 @@
#include <string>
#include "../message/Errors.hpp"
#ifndef VITE_DEBUG
#include "../message/Errors.hpp"
#else
// For debugging
#include "../../tests/stubs/Errors.hpp"
#endif
/*!
* \class Parser Parser.hpp "../parser/src/Parser.hpp"
......
......@@ -7,7 +7,13 @@
#include "Definition.hpp"
#include "Line.hpp"
#include "../message/Errors.hpp"
#ifndef VITE_DEBUG
#include "../message/Errors.hpp"
#else
// For debugging
#include "../../tests/stubs/Errors.hpp"
#endif
/*!
*
......
......@@ -6,14 +6,18 @@
#include "Definition.hpp"
#include "Line.hpp"
#include "../trace/values/Values.hpp"
#include "../message/Errors.hpp"
//#ifdef DEBUG_PRINT_TRACE
//#include "../../tests/parser/stub/trace.hpp"
//#else
#include "../trace/Trace.hpp"
//#endif
#ifndef VITE_DEBUG
#include "../trace/values/Values.hpp"
#include "../trace/Trace.hpp"
#include "../message/Errors.hpp"
#else
// For debugging
#include "../../tests/stubs/Trace.hpp"
#include "../../tests/stubs/Errors.hpp"
#endif
/**
* \class ParserEventDecoder
* \brief Reads Hash Table to find fill the Str
......
......@@ -9,13 +9,16 @@
#include "ParserEventDecoder.hpp"
#include "Parser.hpp"
#include "Line.hpp"
#include "../message/Errors.hpp"
//#ifdef DEBUG_PRINT_TRACE
//#include "../../tests/parser/stub/trace.hpp"
//#else
#include "../trace/Trace.hpp"
//#endif
#ifndef VITE_DEBUG
#include "../trace/Trace.hpp"
#include "../message/Errors.hpp"
#else
// For debugging
#include "../../tests/stubs/Trace.hpp"
#include "../../tests/stubs/Errors.hpp"
#endif
/*!
*
......
#ifndef STRING_HPP
#define STRING_HPP
/*!
*
* \file String.hpp
* \author Johnny Jazeix and CV
* \brief
* \date 2009 January 30th
*
*/
#include "Value.hpp"
/*!
*
* \class String
* \brief Store a string in the trace
*
*/
class String: public Value {
private:
std::string _value;
#ifndef STRING_HPP
#define STRING_HPP
/*!
*
* \file String.hpp
* \author Johnny Jazeix and CV
* \brief
* \date 2009 January 30th
*
*/
#include "Value.hpp"
/*!
*
* \class String
* \brief Store a string in the trace
*
*/
class String: public Value {
private:
std::string _value;
public:
/*!
* \brief Functor hash function
*/
*/
struct hash {
/*!
* \fn operator()(const String &)
......@@ -46,46 +46,46 @@ public:
bool operator()(const String &, const String &);
};
/*!
* \brief Constructor
*/
String();
/*!
* \brief Constructor
*/
String(std::string);
/*!
*
* \fn instantiate(const std::string &in, String &out)
* \brief Convert a string to a String
* \param in string to convert
* \param out String to be initialized
* \return true for coherence with the other values
*
*/
static bool instantiate(const std::string &in, String &out);
/*!
* \fn to_string() const
*/
std::string to_string() const;
/*!
* \fn operator ==(const std::string &) const
* \return true if they are equals.
*/
bool operator ==(const std::string &) const;
/*!
* \fn operator= (const std::string &)
* \return this String with the new value.
*/
/*!
* \brief Constructor
*/
String();
/*!
* \brief Constructor
*/
String(std::string);
/*!
*
* \fn instantiate(const std::string &in, String &out)
* \brief Convert a string to a String
* \param in string to convert
* \param out String to be initialized
* \return true for coherence with the other values
*
*/
static bool instantiate(const std::string &in, String &out);
/*!
* \fn to_string() const
*/
std::string to_string() const;
/*!
* \fn operator ==(const std::string &) const
* \return true if they are equals.
*/
bool operator ==(const std::string &) const;
/*!
* \fn operator= (const std::string &)
* \return this String with the new value.
*/
String operator= (const std::string &);
};
#endif // STRING_HPP
};
#endif // STRING_HPP
CXX=g++
CXXFLAGS = -Wall -g
BIN_DIR = ../../bin/
SRC_DIR = ../../src/message/
OBJECT_FILE_BIN = $(BIN_DIR)enderror.o $(BIN_DIR)endwarning.o $(BIN_DIR)endinformation.o $(BIN_DIR)message.o $(BIN_DIR)message_ns.o
OBJECT_FILE = enderror.o endwarning.o endinformation.o message.o message_ns.o
TEST_FLAGS = -DTEST_MESSAGE
all : make_src test_enderror test_endwarning test_endinformation
OBJECT_FILE_BIN = $(BIN_DIR)Message.o
OBJECT_FILE = Message.o
TEST_FLAGS = -DVITE_DEBUG
## Qt include path
INCPATH = -I/usr/share/qt4/mkspecs/linux-g++ -I/usr/include/qt4/QtUiTools -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtOpenGL -I/usr/include/qt4
## Qt libs
LIBS = -L/usr/lib -L/usr/X11R6/lib -lglut -lGLEW -lQtXml -lQtOpenGL -lQtGui -lQtCore -lQtUiTools -lGLU -lGL -lpthread
all : make_src test_message
@echo " "
@echo "Message files compiled successfully ! (test)"
@echo " "
# All the source files is compiled
make_src: $(OBJECT_FILE)
make_src: $(OBJECT_FILE)
test_%: test_%.cpp $(SRC_DIR)%.cpp $(SRC_DIR)%.hpp
$(CXX) $(CXXFLAGS) $< -o $(BIN_DIR)$@ $(OBJECT_FILE_BIN) $(TEST_FLAGS)
test_message: test_message.cpp
$(CXX) $(CXXFLAGS) $< -o $@ $(OBJECT_FILE_BIN) $(TEST_FLAGS) $(INCPATH)
%.o:$(SRC_DIR)%.cpp $(SRC_DIR)%.hpp
$(CXX) -c $(CXXFLAGS) $< -o $(BIN_DIR)$@ $(TEST_FLAGS)
\ No newline at end of file
$(CXX) -c $(CXXFLAGS) $< -o $(BIN_DIR)$@ $(TEST_FLAGS) $(INCPATH)
\ No newline at end of file
/*!
* \brief Test error message
*/
#include <cstdlib>
#include "../src/message_ns.hpp"
using namespace std;
Interface i;
using namespace message_ns;
int main(int argc, char** argv){
Enderror ende;
Message::set_interface_instance(&i);
message << "ttt" << 45<<ende;
message << ende;
return EXIT_SUCCESS;
}
/*!
* \brief Test error message
*/
#include <cstdlib>
#include "../src/message_ns.hpp"
using namespace std;
Interface i;
using namespace message_ns;
int main(int argc, char** argv){
Enderror ende;
Message::set_interface_instance(&i);
message << "ttt" << 45<<ende;
message << ende;
return EXIT_SUCCESS;
}
/*!
* \brief Test error message
*/
#include <cstdlib>
#include "../src/message_ns.hpp"
using namespace std;
Interface i;
using namespace message_ns;
int main(int argc, char** argv){
Endwarning endw;
Message::set_interface_instance(&i);
message << "ttt" << 45<<endw;
message << endw;
return EXIT_SUCCESS;
}
/*!
* \brief Test error message
*/
#include <cstdlib>
#include "../../src/message/Message.hpp"
using namespace std;
int main(int argc, char** argv){
// Creation of an interface
Interface *interface = new Interface();
Message::set_interface(interface);
// Print of an info
*Message::get_instance() << "this is an information" << Message::endi;
// Print of a warn
*Message::get_instance() << "this is a warning" << Message::endw;
// Print of an error
*Message::get_instance() << "this is an error" << Message::ende;
// Liberation of memory
Message::kill();
delete interface;
return EXIT_SUCCESS;
}
CC = g++
LD = g++
OBJ = ../../trace/src/values/*.o stub/*.o ../../bin/*.o
DIR_SRC = ../src
DIR_STUB = stub
DIR_VALUES = ../../trace/src/values
CXX=g++
CXXFLAGS = -W -Wall -g
BIN_DIR = ../../bin/
SRC_DIR = ../../src/parser/
OPT = -g -Wall -W -DDEBUG
OBJECT_FILE_BIN = $(BIN_DIR)Line.o $(BIN_DIR)TokenSource.o $(BIN_DIR)ParserDefinitionDecoder.o $(BIN_DIR)Message.o $(BIN_DIR)Errors.o $(BIN_DIR)Definition.o $(BIN_DIR)ParserEventDecoder.o $(BIN_DIR)ParserPaje.o $(BIN_DIR)Trace.o $(BIN_DIR)Color.o $(BIN_DIR)Date.o $(BIN_DIR)Double.o $(BIN_DIR)Integer.o $(BIN_DIR)Hex.o $(BIN_DIR)Name.o $(BIN_DIR)String.o
all: ParserPaje.o ParserEventDecoder.o test_ligne test_token test_parser_definition test_parser_evenement test_parser_paje
OBJECT_FILE = Line.o ParserDefinitionDecoder.o TokenSource.o Definition.o ParserEventDecoder.o ParserPaje.o Trace.o Color.o Date.o Double.o Integer.o Hex.o Name.o String.o
test_token: test_token.cpp $(OBJ)
$(CC) $(OPT) -o $@ $^
TEST_FLAGS = -DVITE_DEBUG
test_ligne: test_ligne.cpp $(OBJ)
$(CC) $(OPT) -o $@ $^
## Qt include path
INCPATH = -I/usr/share/qt4/mkspecs/linux-g++ -I/usr/include/qt4/QtUiTools -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtOpenGL -I/usr/include/qt4
## Qt libs
LIBS = -L/usr/lib -L/usr/X11R6/lib -lglut -lGLEW -lQtXml -lQtOpenGL -lQtGui -lQtCore -lQtUiTools -lGLU -lGL -lpthread
test_parser_definition: test_parser_definition.cpp $(OBJ)
$(CC) $(OPT) -o $@ $^
test_parser_evenement: test_parser_event.cpp $(OBJ)
$(CC) $(OPT) -o $@ $^
# Making
all: make_src test_token test_ligne test_parser_definition test_parser_evenement test_parser_paje
ParserPaje.o : ../src/ParserPaje.cpp ../src/ParserPaje.hpp
$(CC) -c $(OPT) ../src/ParserPaje.cpp -o ../../bin/ParserPaje.o
# All the source files is compiled
make_src: Message.o Errors.o $(OBJECT_FILE)
ParserEventDecoder.o : ../src/ParserEventDecoder.cpp ../src/ParserEventDecoder.hpp
$(CC) -c $(OPT) ../src/ParserEventDecoder.cpp -o ../../bin/ParserPaje.o
test_token: test_token.cpp
$(CXX) $(CXXFLAGS) $< -o $@ $(TEST_FLAGS) $(INCPATH) $(BIN_DIR)TokenSource.o $(BIN_DIR)Message.o
$(OBJ):
@(cd $(DIR_SRC) && make allbutparser)
@(cd $(DIR_STUB) && make)
@(cd $(DIR_VALUES) && make)
test_ligne: test_ligne.cpp
$(CXX) $(CXXFLAGS) $< -o $@ $(TEST_FLAGS) $(INCPATH) $(BIN_DIR)Line.o $(BIN_DIR)TokenSource.o $(BIN_DIR)Message.o
test_parser_paje: test_parser_paje.cpp $(OBJ)
$(CC) $(OPT) -o $@ $^
test_parser_definition: test_parser_definition.cpp
$(CXX) $(CXXFLAGS) $< -o $@ $(OBJECT_FILE_BIN) $(TEST_FLAGS) $(INCPATH)
test_parser_evenement: test_parser_event.cpp
$(CXX) $(CXXFLAGS) $< -o $@ $(OBJECT_FILE_BIN) $(TEST_FLAGS) $(INCPATH)
%.o:$(SRC_DIR)%.cpp $(SRC_DIR)%.hpp
$(CXX) -c $(CXXFLAGS) $< -o $(BIN_DIR)$@ $(TEST_FLAGS)
Message.o: ../../src/message/Message.cpp ../../src/message/Message.hpp
$(CXX) -c $(CXXFLAGS) $< -o $(BIN_DIR)$@ $(TEST_FLAGS)
Trace.o: ../stubs/Trace.cpp ../stubs/Trace.hpp
$(CXX) -c $(CXXFLAGS) $< -o $(BIN_DIR)$@ $(TEST_FLAGS)
Color.o: ../stubs/Color.cpp ../stubs/Color.hpp
$(CXX) -c $(CXXFLAGS) $< -o $(BIN_DIR)$@ $(TEST_FLAGS)
Date.o: ../stubs/Date.cpp ../stubs/Date.hpp
$(CXX) -c $(CXXFLAGS) $< -o $(BIN_DIR)$@ $(TEST_FLAGS)
Double.o: ../stubs/Double.cpp ../stubs/Double.hpp
$(CXX) -c $(CXXFLAGS) $< -o $(BIN_DIR)$@ $(TEST_FLAGS)
Integer.o: ../stubs/Integer.cpp ../stubs/Integer.hpp
$(CXX) -c $(CXXFLAGS) $< -o $(BIN_DIR)$@ $(TEST_FLAGS)
Hex.o: ../stubs/Hex.cpp ../stubs/Hex.hpp
$(CXX) -c $(CXXFLAGS) $< -o $(BIN_DIR)$@ $(TEST_FLAGS)
Name.o: ../stubs/Name.cpp ../stubs/Name.hpp
$(CXX) -c $(CXXFLAGS) $< -o $(BIN_DIR)$@ $(TEST_FLAGS)
String.o: ../stubs/String.cpp ../stubs/String.hpp
$(CXX) -c $(CXXFLAGS) $< -o $(BIN_DIR)$@ $(TEST_FLAGS)
Errors.o: ../../src/message/Errors.cpp ../../src/message/Errors.hpp
$(CXX) -c $(CXXFLAGS) $< -o $(BIN_DIR)$@ $(TEST_FLAGS)
test_parser_paje: test_parser_paje.cpp
$(CXX) $(CXXFLAGS) $< -o $@ $(OBJECT_FILE_BIN) $(TEST_FLAGS) $(INCPATH)
clean:
@(cd $(DIR_SRC) && make clean)
@(cd $(DIR_STUB) && make clean)
@(cd $(DIR_VALUES) && make clean)
$(RM) *.o *.*~ Makefile~
$(RM) $(BIN_DIR)*.o *.*~ Makefile~
distclean: clean
$(RM) test_token test_ligne test_parser_definition test_parser_evenement test_parser_paje
#include "date.hpp"
Date::Date(std::string &s){
me = s;
}
std::string &Date::tostring() {
return me;
}
#ifndef DATE_HPP
#define DATE_HPP
#include <iostream>
/*!
*
* \file date.hpp
* \author NOISETTE
* \brief Bouchon
*
*/
class Date{
private:
std::string me;
public:
Date(std::string &);
std::string &tostring();
};
#endif // DATE_HPP
#include "name.hpp"
Name::Name(std::string& s){
me = s;
}
std::string &Name::tostring() {
return me;
}
#include "string.hpp"
String::String(std::string& s){
me = s;
}
std::string &String::tostring() {
return me;
}
#include "../src/Line.hpp"
#include "../../src/parser/Line.hpp"
#include <iostream>
#include <fstream>
......@@ -6,10 +6,6 @@ using namespace std;
int main(int argc, char **argv){
Line line;
if (argc<2)
line.open("trace_to_parse.trace");
......@@ -18,20 +14,16 @@ int main(int argc, char **argv){
int linecount = 0;
while(!line.eof()){
while(!line.is_eof()){
line.newline();
linecount++;
line.print();
}
cout << "lu :" << linecount << endl;
return 0;
}
#include "../src/Line.hpp"
#include "../src/ParserDefinitionDecoder.hpp"
#include "../tests/stub/trace.hpp"
#include "../../src/parser/Line.hpp"
#include "../../src/parser/ParserDefinitionDecoder.hpp"
#include "../stubs/Trace.hpp"
#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <cstdlib>
using namespace std;
int main(int argc, char** argv){
ParserDefinitionDecoder *parserdefinition = new ParserDefinitionDecoder();
Line line;
if (argc<2)
......@@ -21,7 +21,7 @@ int main(int argc, char** argv){
int linecount = 0;
static const string percent = "%";
while(!line.eof()){
while(!line.is_eof()){
line.newline();
......
#include "../src/Line.hpp"
#include "../src/ParserDefinitionDecoder.hpp"
#include "../src/ParserEventDecoder.hpp"
#include "../tests/stub/trace.hpp"
#include "../../src/parser/Line.hpp"
#include "../../src/parser/ParserDefinitionDecoder.hpp"
#include "../../src/parser/ParserEventDecoder.hpp"
#include "../stubs/Trace.hpp"
#include <iostream>
#include <fstream>
#include <cstdlib>
......@@ -21,31 +21,28 @@ int main(int argc, char** argv){
Line line;
if (argc<2)
line.open("trace_to_parse.trace");
line.open("trace_to_parse.trace");
else
line.open(argv[1]);
line.open(argv[1]);
int linecount = 0;
static const string percent = "%";
string event_identity_string;
int event_identity;
while(!line.eof()){
while(!line.is_eof()){
line.newline();
if(line.starts_with(percent)){
parserdefinition->store_definition(line);
linecount ++;
}
else if (!line.item(0, event_identity_string)){
}
continue;
}
else{
stop();
stop();
DIE_IF(sscanf(event_identity_string.c_str(), "%d", &event_identity) != 1, "expected identifier for a definition");
......