Commit 6aeaf3a7 authored by Pascal Palenda's avatar Pascal Palenda
Browse files

Move replacement filter tests - WIP

parent fe1df9ed
......@@ -81,60 +81,4 @@ TEST_F ( MasterSimulationControllerTest, attachResultHandler )
EXPECT_LE ( handler->resultVector.size ( ), 50 );
}
TEST ( ReplacementFilter, filterReplace1 )
{
std::list<std::unique_ptr<IUpdateMessage>> list;
list.push_back ( std::make_unique<CUpdateScene> ( 1 ) );
list.push_back ( std::make_unique<CUpdateScene> ( 1 ) );
list.push_back ( std::make_unique<CUpdateScene> ( 1 ) );
list.push_back ( std::make_unique<CUpdateScene> ( 1 ) );
auto lastUpdate = std::make_unique<CUpdateScene> ( 1 );
auto rawLastUpdate = lastUpdate.get ( );
list.push_back ( std::move ( lastUpdate ) );
CReplacementFilter::filterReplace ( list );
EXPECT_EQ ( 1, list.size ( ) );
auto afterReplace = list.front ( ).release ( );
auto ptr1 = dynamic_cast< CUpdateScene* >( rawLastUpdate );
auto ptr2 = dynamic_cast< CUpdateScene* >( afterReplace );
EXPECT_EQ ( *ptr1, *ptr2 );
}
TEST ( ReplacementFilter, filterReplace2 )
{
std::list<std::unique_ptr<IUpdateMessage>> list;
list.push_back ( std::make_unique<CUpdateConfig> ( ) );
list.push_back ( std::make_unique<CUpdateConfig> ( ) );
list.push_back ( std::make_unique<CUpdateConfig> ( ) );
list.push_back ( std::make_unique<CUpdateConfig> ( ) );
list.push_back ( std::make_unique<CUpdateConfig> ( ) );
CReplacementFilter::filterReplace ( list );
EXPECT_EQ ( 5, list.size ( ) );
}
TEST ( ReplacementFilter, filterReplace3 )
{
std::list<std::unique_ptr<IUpdateMessage>> list;
list.push_back ( std::make_unique<CUpdateScene> ( 1 ) );
list.push_back ( std::make_unique<CUpdateScene> ( 2 ) );
list.push_back ( std::make_unique<CUpdateConfig> ( ) );
list.push_back ( std::make_unique<CUpdateScene> ( 1 ) );
list.push_back ( std::make_unique<CUpdateScene> ( 2 ) );
CReplacementFilter::filterReplace ( list );
EXPECT_EQ ( 3, list.size ( ) );
}
#include <list>
#include <memory>
#include <ITA/simulation_scheduler/update_scene.h>
#include <ITA/simulation_scheduler/update_config.h>
#include "../src/ITA/simulation_scheduler/room_acoustics/replacement_filter.h"
// GTest
#include "gtest/gtest.h"
using namespace ITA::simulation_scheduler;
using namespace room_acoustics;
TEST ( ReplacementFilter, filterReplace1 )
{
std::list<std::unique_ptr<IUpdateMessage>> list;
list.push_back ( std::make_unique<CUpdateScene> ( 1 ) );
list.push_back ( std::make_unique<CUpdateScene> ( 1 ) );
list.push_back ( std::make_unique<CUpdateScene> ( 1 ) );
list.push_back ( std::make_unique<CUpdateScene> ( 1 ) );
auto lastUpdate = std::make_unique<CUpdateScene> ( 1 );
auto rawLastUpdate = lastUpdate.get ( );
list.push_back ( std::move ( lastUpdate ) );
CReplacementFilter::filterReplace ( list );
EXPECT_EQ ( 1, list.size ( ) );
auto afterReplace = list.front ( ).release ( );
auto ptr1 = dynamic_cast< CUpdateScene* >( rawLastUpdate );
auto ptr2 = dynamic_cast< CUpdateScene* >( afterReplace );
EXPECT_EQ ( *ptr1, *ptr2 );
}
TEST ( ReplacementFilter, filterReplace2 )
{
std::list<std::unique_ptr<IUpdateMessage>> list;
list.push_back ( std::make_unique<CUpdateConfig> ( ) );
list.push_back ( std::make_unique<CUpdateConfig> ( ) );
list.push_back ( std::make_unique<CUpdateConfig> ( ) );
list.push_back ( std::make_unique<CUpdateConfig> ( ) );
list.push_back ( std::make_unique<CUpdateConfig> ( ) );
CReplacementFilter::filterReplace ( list );
EXPECT_EQ ( 5, list.size ( ) );
}
TEST ( ReplacementFilter, filterReplace3 )
{
std::list<std::unique_ptr<IUpdateMessage>> list;
list.push_back ( std::make_unique<CUpdateScene> ( 1 ) );
list.push_back ( std::make_unique<CUpdateScene> ( 2 ) );
list.push_back ( std::make_unique<CUpdateConfig> ( ) );
list.push_back ( std::make_unique<CUpdateScene> ( 1 ) );
list.push_back ( std::make_unique<CUpdateScene> ( 2 ) );
CReplacementFilter::filterReplace ( list );
EXPECT_EQ ( 3, list.size ( ) );
}
\ No newline at end of file
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