Skip to content

Instantly share code, notes, and snippets.

@biot023
Created December 18, 2011 15:07
Show Gist options
  • Save biot023/1493656 to your computer and use it in GitHub Desktop.
Save biot023/1493656 to your computer and use it in GitHub Desktop.
#include "gtest/gtest.h"
#include "rtga/operator.h"
#include "rtga/rtga.h"
#include <vector>
#include <memory>
using namespace std;
using namespace rtga;
template <typename T>
struct SingleConnectionOperatorTest : public ::testing::Test
{
typedef typename T::value_type value_type;
typedef IArray<value_type> array_i;
typedef RWArray<vector<value_type>> array_t;
typedef IConnectionNet<value_type> connection_net_i;
typedef ConnectionNet<value_type> connection_net_t;
typedef IOperator<value_type> operator_i;
typedef T operator_t;
protected:
shared_ptr<vector<shared_ptr<array_i>>> _arrays;
shared_ptr<connection_net_i> _connection_net;
shared_ptr<operator_i> _operator;
shared_ptr<operator_t> _casted_operator;
uint _connection_index;
SingleConnectionOperatorTest() :
_arrays( make_shared<vector<shared_ptr<array_i>>>() ),
_connection_index( 1 )
{
_arrays->push_back( make_shared<array_t>
( array_t( make_shared<vector<value_type>>
( vector<value_type>( { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 } ) ) ) ) );
_connection_net = make_shared<connection_net_t>( connection_net_t( 10, _arrays ) );
_operator = make_shared<operator_t>( operator_t( _connection_index ) );
_casted_operator = dynamic_pointer_cast<operator_t>( _operator );
}
};
typedef ::testing::Types<NullOperator<int>> Implementations;
TYPED_TEST_CASE( SingleConnectionOperatorTest, Implementations );
TYPED_TEST( SingleConnectionOperatorTest, ShouldStoreTheIndexParam ) {
EXPECT_EQ( _connection_index, _operator->connection_index() );
}
TYPED_TEST( SingleConnectionOperatorTest, ShouldInitialiseWithANullConnection ) {
EXPECT_EQ( nullptr, _casted_operator->connection().lock() );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment