Пример #1
0
TEST_F( Reflect, ReflectWithTwoElementsWithException )
{
	run(
		q::with( queue, 17, 3.14f )
		.then( EXPECT_CALL_WRAPPER( spy )(
		[ ]( int i, float f ) -> std::tuple< int, float >
		{
			EXPECT_EQ( 17, i );
			EXPECT_FLOAT_EQ( (float)3.14, f );
			throw Error( );
		} ) )
		.reflect( )
		.then( EXPECT_CALL_WRAPPER( spy )(
		[ ]( q::expect< std::tuple< int, float > >&& exp )
		{
			EXPECT_TRUE( exp.has_exception( ) );
			std::rethrow_exception( exp.exception( ) );
		} ) )
		.fail( EXPECT_CALL_WRAPPER( spy )(
		[ ]( Error& )
		{
		} ) )
	);

}
Пример #2
0
TEST_F( SetDefault, NoDefault )
{
	auto promise1 = q::with( queue ).share( );

	auto main_thread_name = q::detail::get_thread_name( );

	auto promise2 = promise1
	.then( EXPECT_CALL_WRAPPER( spy )(
		[ &main_thread_name ]( )
		{
			auto thread_name = q::detail::get_thread_name( );
			EXPECT_NE( main_thread_name, thread_name );
		}
	), tp_queue )
	.then( EXPECT_CALL_WRAPPER( spy )(
		[ &main_thread_name ]( )
		{
			auto thread_name = q::detail::get_thread_name( );
			EXPECT_EQ( main_thread_name, thread_name );
		}
	) );

	run(
		q::all(
			std::move( promise1 ),
			std::move( promise2 )
		)
	);
}
Пример #3
0
TEST_F( Reflect, ReflectTupleWithZeroElementsWithException )
{
	run(
		q::with( queue )
		.then( EXPECT_CALL_WRAPPER( spy )(
		[ ]( )
		{
			throw Error( );
		} ) )
		.reflect_tuple( )
		.then( EXPECT_CALL_WRAPPER( spy )(
		[ ]( q::expect< std::tuple< > >&& exp )
		{
			EXPECT_TRUE( exp.has_exception( ) );
		} ) )
		.fail( EXPECT_NO_CALL_WRAPPER( spy )(
		[ ]( std::exception_ptr )
		{
		} ) )
	);
}
Пример #4
0
TEST_F( Reflect, ReflectTupleWithOneElementWithException )
{
	run(
		q::with( queue, 17 )
		.then( EXPECT_CALL_WRAPPER( spy )(
		[ ]( int i ) -> int
		{
			EXPECT_EQ( 17, i );
			throw Error( );
		} ) )
		.reflect_tuple( )
		.then( EXPECT_CALL_WRAPPER( spy )(
		[ ]( q::expect< std::tuple< int > >&& exp )
		{
			EXPECT_TRUE( exp.has_exception( ) );
			std::rethrow_exception( exp.exception( ) );
		} ) )
		.fail( EXPECT_CALL_WRAPPER( spy )(
		[ ]( Error& )
		{
		} ) )
	);
}
Пример #5
0
TEST_F( Reflect, ReflectWithZeroElements )
{
	run(
		q::with( queue )
		.reflect( )
		.then( EXPECT_CALL_WRAPPER( spy )(
		[ ]( q::expect< >&& exp )
		{
			EXPECT_FALSE( exp.has_exception( ) );
		} ) )
		.fail( EXPECT_NO_CALL_WRAPPER( spy )(
		[ ]( std::exception_ptr )
		{
		} ) )
	);
}
Пример #6
0
TEST_F( Reflect, ReflectTupleWithOneElement )
{
	run(
		q::with( queue, 17 )
		.reflect_tuple( )
		.then( EXPECT_CALL_WRAPPER( spy )(
		[ ]( q::expect< std::tuple< int > >&& exp )
		{
			EXPECT_FALSE( exp.has_exception( ) );
			EXPECT_EQ( 17, std::get< 0 >( exp.get( ) ) );
		} ) )
		.fail( EXPECT_NO_CALL_WRAPPER( spy )(
		[ ]( std::exception_ptr )
		{
		} ) )
	);
}
Пример #7
0
TEST_F( Reflect, ReflectTupleWithTwoElements )
{
	run(
		q::with( queue, 17, 3.14f )
		.reflect_tuple( )
		.then( EXPECT_CALL_WRAPPER( spy )(
		[ ]( q::expect< std::tuple< int, float > >&& exp )
		{
			EXPECT_FALSE( exp.has_exception( ) );
			EXPECT_EQ( 17, std::get< 0 >( exp.get( ) ) );
			EXPECT_FLOAT_EQ( (float)3.14, std::get< 1 >( exp.get( ) ) );
		} ) )
		.fail( EXPECT_NO_CALL_WRAPPER( spy )(
		[ ]( std::exception_ptr )
		{
		} ) )
	);

}
Пример #8
0
Q_TEST_MAKE_SCOPE( fail );
/*
	 *   * exception_ptr -> tuple< T... >
	 *   * exception_ptr -> P< tuple< T... > >
	 *   * E             -> tuple< T... >
	 *   * E             -> P< tuple< T... > >
*/

TEST_F( fail, exception_ptr_to_value )
{
	run(
		q::with( queue )
		.then( EXPECT_CALL_WRAPPER(
		[ ]( ) -> int
		{
			Q_THROW( Error( ) );
		} ) )
		.then( EXPECT_NO_CALL( int, int )( 4711 ) )
		.fail( EXPECT_CALL_WRAPPER(
		[ ]( std::exception_ptr e )
		{
			return 17;
		} ) )
		.then( EXPECT_CALL_WRAPPER(
		[ ]( int value )
		{
			EXPECT_EQ( 17, value );
		} ) )
	);
}