Skip to content
Snippets Groups Projects
Commit 7b7ca845 authored by Tommaso Fulghesu's avatar Tommaso Fulghesu Committed by Sebastien Ponce
Browse files

Add tests for empty RelationTable

parent 95c43f63
No related branches found
No related tags found
2 merge requests!3788Draft: Update SciFi cluster monitoring,!3694Add tests for empty RelationTable
......@@ -221,6 +221,8 @@ namespace Functors::Functional {
using std::next;
using std::make_pair;
if ( begin( range ) == end( range ) ) throw std::runtime_error( "Attempt to iterate over an empty range" );
auto min_entry = std::accumulate(
next( begin( range ) ), end( range ),
make_pair( *begin( range ), functor( mask_arg, mask, *begin( range ), input... ) ),
......@@ -264,6 +266,8 @@ namespace Functors::Functional {
using std::next;
using std::make_pair;
if ( begin( range ) == end( range ) ) throw std::runtime_error( "Attempt to iterate over an empty range" );
auto max_entry = std::accumulate(
next( begin( range ) ), end( range ),
make_pair( *begin( range ), functor( mask_arg, mask, *begin( range ), input... ) ),
......
......@@ -1222,6 +1222,7 @@ BOOST_AUTO_TEST_CASE( test_relation_table_isolation ) {
Functors::TopLevelInfo top_level;
IsolationTable table = make_relations2D( parts );
IsolationTable empty_table;
auto const front_weight =
Functors::chain( Functors::Common::Weight{}, Functors::Functional::Front{}, Functors::Common::Relations{} );
......@@ -1246,13 +1247,26 @@ BOOST_AUTO_TEST_CASE( test_relation_table_isolation ) {
PT, Functors::Common::To{}, Functors::Functional::EntryWithMaxRelatedValueOf( Functors::Common::Weight{} ),
Functors::Common::Relations{} );
auto const pt_to_max_weight_entry_prepped = pt_to_max_weight_entry.prepare( evtCtx, top_level );
auto empty_test = pt_to_min_weight_entry_prepped( true, empty_table, parts( 0 ) );
auto empty_test2 = pt_to_max_weight_entry_prepped( true, empty_table, parts( 1 ) );
auto pt_wmin = pt_to_min_weight_entry_prepped( true, table, parts( 2 ) );
auto pt_wmax = pt_to_max_weight_entry_prepped( true, table, parts( 2 ) );
BOOST_CHECK( !empty_test.has_value() );
BOOST_CHECK( !empty_test2.has_value() );
BOOST_CHECK( pt_wmin.has_value() );
BOOST_CHECK( pt_wmax.has_value() );
BOOST_CHECK( LHCb::Utils::as_arithmetic( pt_wmin.value() ) < 100 );
BOOST_CHECK( LHCb::Utils::as_arithmetic( pt_wmax.value() ) > 100 );
auto const value_or_pt_to_min_weight_entry = Functors::chain(
Functors::Functional::ValueOr{0}, PT, Functors::Common::To{},
Functors::Functional::EntryWithMinRelatedValueOf( Functors::Common::Weight{} ), Functors::Common::Relations{} );
auto const value_or_pt_to_min_weight_entry_prepped = value_or_pt_to_min_weight_entry.prepare( evtCtx, top_level );
auto value_or_empty_test = value_or_pt_to_min_weight_entry_prepped( true, empty_table, parts( 0 ) );
BOOST_CHECK( LHCb::Utils::as_arithmetic( value_or_empty_test ) == 0 );
auto const relation = Functors::Common::Relations{}( table, parts( 1 ) );
BOOST_CHECK( relation.has_value() );
auto pt_to = chain( PT, Functors::Common::To{} );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment