163 lines
6.5 KiB
ABAP
163 lines
6.5 KiB
ABAP
CLASS {{p}}keg_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
|
|
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
|
PRIVATE SECTION.
|
|
DATA mo_cut TYPE REF TO {{p}}keg_tour_merger.
|
|
METHODS setup.
|
|
METHODS merge_two_lists FOR TESTING.
|
|
METHODS merge_same_key FOR TESTING.
|
|
METHODS merge_ignores_zero FOR TESTING.
|
|
METHODS merge_ignores_negative FOR TESTING.
|
|
METHODS merge_upper_case FOR TESTING.
|
|
METHODS merge_is_sorted FOR TESTING.
|
|
METHODS merge_empty_lists FOR TESTING.
|
|
METHODS top_ranks_pubs FOR TESTING.
|
|
METHODS top_limits_rows FOR TESTING.
|
|
METHODS top_zero_count FOR TESTING.
|
|
METHODS top_ignores_invalid FOR TESTING.
|
|
ENDCLASS.
|
|
|
|
|
|
CLASS {{p}}keg_hidden IMPLEMENTATION.
|
|
METHOD setup.
|
|
mo_cut = NEW {{p}}keg_tour_merger( ).
|
|
ENDMETHOD.
|
|
|
|
METHOD merge_two_lists.
|
|
DATA(lt_a) = VALUE {{p}}keg_tour_merger=>tt_entry(
|
|
( pub_id = 'P01' keg_type = 'LAG' kegs = 10 )
|
|
( pub_id = 'P02' keg_type = 'LAG' kegs = 4 ) ).
|
|
DATA(lt_b) = VALUE {{p}}keg_tour_merger=>tt_entry(
|
|
( pub_id = 'P01' keg_type = 'PIL' kegs = 6 ) ).
|
|
DATA(lt_exp) = VALUE {{p}}keg_tour_merger=>tt_entry(
|
|
( pub_id = 'P01' keg_type = 'LAG' kegs = 10 )
|
|
( pub_id = 'P01' keg_type = 'PIL' kegs = 6 )
|
|
( pub_id = 'P02' keg_type = 'LAG' kegs = 4 ) ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = lt_exp
|
|
act = mo_cut->merge_tours( it_tour_a = lt_a it_tour_b = lt_b ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD merge_same_key.
|
|
DATA(lt_a) = VALUE {{p}}keg_tour_merger=>tt_entry(
|
|
( pub_id = 'P01' keg_type = 'LAG' kegs = 10 )
|
|
( pub_id = 'P01' keg_type = 'LAG' kegs = 5 ) ).
|
|
DATA(lt_b) = VALUE {{p}}keg_tour_merger=>tt_entry(
|
|
( pub_id = 'P01' keg_type = 'LAG' kegs = 2 ) ).
|
|
DATA(lt_exp) = VALUE {{p}}keg_tour_merger=>tt_entry(
|
|
( pub_id = 'P01' keg_type = 'LAG' kegs = 17 ) ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = lt_exp
|
|
act = mo_cut->merge_tours( it_tour_a = lt_a it_tour_b = lt_b ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD merge_ignores_zero.
|
|
DATA(lt_a) = VALUE {{p}}keg_tour_merger=>tt_entry(
|
|
( pub_id = 'P01' keg_type = 'LAG' kegs = 0 )
|
|
( pub_id = 'P02' keg_type = 'LAG' kegs = 5 ) ).
|
|
DATA(lt_b) = VALUE {{p}}keg_tour_merger=>tt_entry(
|
|
( pub_id = 'P02' keg_type = 'LAG' kegs = 0 ) ).
|
|
DATA(lt_exp) = VALUE {{p}}keg_tour_merger=>tt_entry(
|
|
( pub_id = 'P02' keg_type = 'LAG' kegs = 5 ) ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = lt_exp
|
|
act = mo_cut->merge_tours( it_tour_a = lt_a it_tour_b = lt_b ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD merge_ignores_negative.
|
|
DATA(lt_a) = VALUE {{p}}keg_tour_merger=>tt_entry(
|
|
( pub_id = 'P01' keg_type = 'LAG' kegs = -3 )
|
|
( pub_id = 'P02' keg_type = 'LAG' kegs = 5 ) ).
|
|
DATA(lt_b) = VALUE {{p}}keg_tour_merger=>tt_entry(
|
|
( pub_id = 'P02' keg_type = 'LAG' kegs = -1 ) ).
|
|
DATA(lt_exp) = VALUE {{p}}keg_tour_merger=>tt_entry(
|
|
( pub_id = 'P02' keg_type = 'LAG' kegs = 5 ) ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = lt_exp
|
|
act = mo_cut->merge_tours( it_tour_a = lt_a it_tour_b = lt_b ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD merge_upper_case.
|
|
DATA(lt_a) = VALUE {{p}}keg_tour_merger=>tt_entry(
|
|
( pub_id = 'p01' keg_type = 'lag' kegs = 3 ) ).
|
|
DATA(lt_b) = VALUE {{p}}keg_tour_merger=>tt_entry(
|
|
( pub_id = 'P01' keg_type = 'LAG' kegs = 5 ) ).
|
|
DATA(lt_exp) = VALUE {{p}}keg_tour_merger=>tt_entry(
|
|
( pub_id = 'P01' keg_type = 'LAG' kegs = 8 ) ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = lt_exp
|
|
act = mo_cut->merge_tours( it_tour_a = lt_a it_tour_b = lt_b ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD merge_is_sorted.
|
|
DATA(lt_a) = VALUE {{p}}keg_tour_merger=>tt_entry(
|
|
( pub_id = 'P03' keg_type = 'LAG' kegs = 1 )
|
|
( pub_id = 'P01' keg_type = 'PIL' kegs = 2 )
|
|
( pub_id = 'P01' keg_type = 'LAG' kegs = 3 ) ).
|
|
DATA(lt_exp) = VALUE {{p}}keg_tour_merger=>tt_entry(
|
|
( pub_id = 'P01' keg_type = 'LAG' kegs = 3 )
|
|
( pub_id = 'P01' keg_type = 'PIL' kegs = 2 )
|
|
( pub_id = 'P03' keg_type = 'LAG' kegs = 1 ) ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = lt_exp
|
|
act = mo_cut->merge_tours( it_tour_a = lt_a
|
|
it_tour_b = VALUE #( ) ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD merge_empty_lists.
|
|
DATA(lt_act) = mo_cut->merge_tours( it_tour_a = VALUE #( )
|
|
it_tour_b = VALUE #( ) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 0 act = lines( lt_act ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD top_ranks_pubs.
|
|
DATA(lt_tour) = VALUE {{p}}keg_tour_merger=>tt_entry(
|
|
( pub_id = 'P01' keg_type = 'LAG' kegs = 5 )
|
|
( pub_id = 'P01' keg_type = 'PIL' kegs = 4 )
|
|
( pub_id = 'P02' keg_type = 'LAG' kegs = 9 )
|
|
( pub_id = 'P03' keg_type = 'LAG' kegs = 12 ) ).
|
|
DATA(lt_exp) = VALUE {{p}}keg_tour_merger=>tt_pub(
|
|
( pub_id = 'P03' kegs = 12 )
|
|
( pub_id = 'P01' kegs = 9 )
|
|
( pub_id = 'P02' kegs = 9 ) ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = lt_exp
|
|
act = mo_cut->top_pubs( it_tour = lt_tour iv_count = 3 ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD top_limits_rows.
|
|
DATA(lt_tour) = VALUE {{p}}keg_tour_merger=>tt_entry(
|
|
( pub_id = 'P01' keg_type = 'LAG' kegs = 5 )
|
|
( pub_id = 'P01' keg_type = 'PIL' kegs = 4 )
|
|
( pub_id = 'P02' keg_type = 'LAG' kegs = 9 )
|
|
( pub_id = 'P03' keg_type = 'LAG' kegs = 12 ) ).
|
|
DATA(lt_exp) = VALUE {{p}}keg_tour_merger=>tt_pub(
|
|
( pub_id = 'P03' kegs = 12 )
|
|
( pub_id = 'P01' kegs = 9 ) ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = lt_exp
|
|
act = mo_cut->top_pubs( it_tour = lt_tour iv_count = 2 ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD top_zero_count.
|
|
DATA(lt_tour) = VALUE {{p}}keg_tour_merger=>tt_entry(
|
|
( pub_id = 'P01' keg_type = 'LAG' kegs = 5 ) ).
|
|
DATA(lt_zero) = mo_cut->top_pubs( it_tour = lt_tour iv_count = 0 ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 0 act = lines( lt_zero ) ).
|
|
DATA(lt_neg) = mo_cut->top_pubs( it_tour = lt_tour iv_count = -1 ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 0 act = lines( lt_neg ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD top_ignores_invalid.
|
|
DATA(lt_tour) = VALUE {{p}}keg_tour_merger=>tt_entry(
|
|
( pub_id = 'P01' keg_type = 'LAG' kegs = 0 )
|
|
( pub_id = 'P02' keg_type = 'LAG' kegs = -4 )
|
|
( pub_id = 'P03' keg_type = 'LAG' kegs = 6 )
|
|
( pub_id = 'p03' keg_type = 'PIL' kegs = 4 ) ).
|
|
DATA(lt_exp) = VALUE {{p}}keg_tour_merger=>tt_pub(
|
|
( pub_id = 'P03' kegs = 10 ) ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = lt_exp
|
|
act = mo_cut->top_pubs( it_tour = lt_tour iv_count = 5 ) ).
|
|
ENDMETHOD.
|
|
ENDCLASS.
|