Skip to content

Commit

Permalink
Added 2 small tests
Browse files Browse the repository at this point in the history
Removed commented code
answer-module also depends on boost_date-time
  • Loading branch information
Rodrigo Fernandes committed Oct 1, 2013
1 parent 292d167 commit 02018fb
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 11 deletions.
4 changes: 1 addition & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ list(APPEND CMAKE_CXX_FLAGS "-std=c++11 -pedantic -Wall")
###################### #####################################
# INCLUDES, SOURCE FILES AND CMAKE MODULES
###########################################################
find_package(Boost COMPONENTS serialization REQUIRED QUIET)
find_package(Boost COMPONENTS serialization date_time REQUIRED QUIET)

include_directories (
include
Expand All @@ -37,14 +37,12 @@ file (GLOB headersArchiveHH
# TARGET GENERATION
###########################################################
#Module support

add_library (${PROJECT_NAME}-module SHARED ${MODULE_SRC_FILES})
set_target_properties(${PROJECT_NAME}-module PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION})
target_link_libraries (${PROJECT_NAME}-module
${Boost_LIBRARIES}
)

find_package(Boost COMPONENTS serialization date_time REQUIRED QUIET)

#Library
add_library (${PROJECT_NAME} SHARED ${ADAPTER_SRC_FILES})
Expand Down
1 change: 0 additions & 1 deletion include/answer/Module.hh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ namespace answer{
public:

static ModuleStore& Instance();
// const StoreT& getStore() const;
void registerModule(Module *const module);

virtual FlowStatus inFlow(Context &context);
Expand Down
7 changes: 1 addition & 6 deletions src/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,10 @@ ModuleStore& ModuleStore::Instance(){
return store;
}

// const ModuleStore::StoreT& ModuleStore::getStore() const{
// return _store;
// }

void ModuleStore::registerModule(/*const string& name,*/ answer::Module*const module){
void ModuleStore::registerModule(answer::Module*const module){
_store.push_back(module);
}


Module::FlowStatus ModuleStore::inFlow(Context &context)
{
for (auto &module: _store){
Expand Down
1 change: 0 additions & 1 deletion src/Operation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ void OperationStore::registerOperation( const string& serviceName, const string&
_map[serviceName + string("/") + filteredName] = move(webMethodHandle);
}

//TODO: fix this
OperationStore& OperationStore::Instance() {
static OperationStore inst;
return inst;
Expand Down
17 changes: 17 additions & 0 deletions tests/module/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
find_package(Boost COMPONENTS unit_test_framework REQUIRED QUIET)

add_executable(moduleTest
ModuleTest.cpp
)

include_directories(
${Boost_INCLUDE_DIRS}
)

target_link_libraries(moduleTest
${Boost_LIBRARIES}
answer-module
)

add_test(module moduleTest)

33 changes: 33 additions & 0 deletions tests/module/ModuleTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#define BOOST_TEST_MODULE ModuleTest
#include <boost/test/included/unit_test.hpp>

#include "answer/Module.hh"

using namespace std;

class TestModule: public answer::Module{
public:
virtual FlowStatus inFlow ( answer::Context& context );
virtual FlowStatus outFlow ( answer::Context& context );
virtual FlowStatus outFlowFault ( answer::Context& context );
};

answer::Module::FlowStatus TestModule::inFlow ( answer::Context& context ) {
return OK;
}

answer::Module::FlowStatus TestModule::outFlow ( answer::Context& context ) {
return OK;
}

answer::Module::FlowStatus TestModule::outFlowFault ( answer::Context& context ) {
return OK;
}

ANSWER_REGISTER_MODULE(TestModule);

BOOST_AUTO_TEST_CASE( module )
{
BOOST_CHECK(true);
}

17 changes: 17 additions & 0 deletions tests/registration/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
find_package(Boost COMPONENTS unit_test_framework REQUIRED QUIET)

add_executable(registrationTest
RegistrationTest.cpp
)

include_directories(
${Boost_INCLUDE_DIRS}
)

target_link_libraries(registrationTest
${Boost_LIBRARIES}
answer
)

add_test(registration registrationTest)

25 changes: 25 additions & 0 deletions tests/registration/RegistrationTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#define BOOST_TEST_MODULE SerializationTest
#include <boost/test/included/unit_test.hpp>

//Normally this is defined in the build file, it's usually the project name
#define ANSWER_SERVICE_NAME "SerializationTest"

#include "answer/Operation.hh"

using namespace std;

class Operation{
public:
int test(string X){
return X.size();
}
};

ANSWER_REGISTER_OPERATION(Operation::test);

BOOST_AUTO_TEST_CASE( registration )
{
list<string> operations = answer::OperationStore::Instance().operationList();
BOOST_CHECK(operations.front() == string("SerializationTest/test"));
}

0 comments on commit 02018fb

Please sign in to comment.