Stage 2 summary at 50 accepted trajectories

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Kral
2026-10-05 18:02:52 +02:00
parent 332fb4601d
commit 5bcd1bf9cd
1230 changed files with 77563 additions and 33 deletions

View File

@@ -0,0 +1,120 @@
CLASS {{P}}T14_TEST DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
METHODS line_for
IMPORTING iv_donor TYPE string
iv_group TYPE string
iv_units TYPE i
RETURNING VALUE(rv_line) TYPE string.
METHODS totals_for
IMPORTING iv_donations TYPE string
EXPORTING ev_totals TYPE string
ev_count TYPE i.
METHODS groups_donations FOR TESTING.
METHODS counts_donors FOR TESTING.
METHODS rejects_zero_units FOR TESTING.
METHODS empty_input FOR TESTING.
ENDCLASS.
CLASS {{P}}T14_TEST IMPLEMENTATION.
METHOD line_for.
rv_line = iv_donor && ';' && iv_group && ';' && |{ iv_units }|.
ENDMETHOD.
METHOD totals_for.
DATA lv_totals TYPE string.
CALL FUNCTION '{{P}}DON_SUM'
EXPORTING
iv_donations = iv_donations
IMPORTING
ev_donor_count = ev_count
CHANGING
cv_totals = lv_totals
EXCEPTIONS
invalid_units = 1
OTHERS = 2.
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
ev_totals = lv_totals.
ENDMETHOD.
METHOD groups_donations.
DATA lv_totals TYPE string.
DATA lv_count TYPE i.
DATA(lv_input) = line_for( iv_donor = 'D1' iv_group = 'A+' iv_units = 2 )
&& cl_abap_char_utilities=>newline
&& line_for( iv_donor = 'D1' iv_group = 'a+' iv_units = 3 )
&& cl_abap_char_utilities=>newline
&& line_for( iv_donor = 'D2' iv_group = 'O-' iv_units = 1 ).
totals_for( EXPORTING iv_donations = lv_input
IMPORTING ev_totals = lv_totals
ev_count = lv_count ).
DATA(lv_expected) = line_for( iv_donor = 'D1' iv_group = 'A+' iv_units = 5 )
&& cl_abap_char_utilities=>newline
&& line_for( iv_donor = 'D2' iv_group = 'O-' iv_units = 1 ).
cl_abap_unit_assert=>assert_equals( exp = lv_expected act = lv_totals ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = lv_count ).
ENDMETHOD.
METHOD counts_donors.
DATA lv_totals TYPE string.
DATA lv_count TYPE i.
DATA(lv_input) = line_for( iv_donor = 'D1' iv_group = 'A+' iv_units = 1 )
&& cl_abap_char_utilities=>newline
&& line_for( iv_donor = 'D1' iv_group = 'O-' iv_units = 1 )
&& cl_abap_char_utilities=>newline
&& line_for( iv_donor = 'D2' iv_group = 'A+' iv_units = 1 ).
totals_for( EXPORTING iv_donations = lv_input
IMPORTING ev_totals = lv_totals
ev_count = lv_count ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = lv_count ).
cl_abap_unit_assert=>assert_equals(
exp = 3
act = strlen( lv_totals ) - strlen( replace( val = lv_totals sub = cl_abap_char_utilities=>newline with = '' occ = 0 ) ) + 1 ).
ENDMETHOD.
METHOD rejects_zero_units.
DATA lv_totals TYPE string.
DATA lv_count TYPE i.
DATA(lv_input) = line_for( iv_donor = 'D1' iv_group = 'A+' iv_units = 0 ).
CALL FUNCTION '{{P}}DON_SUM'
EXPORTING
iv_donations = lv_input
IMPORTING
ev_donor_count = lv_count
CHANGING
cv_totals = lv_totals
EXCEPTIONS
invalid_units = 1
OTHERS = 2.
cl_abap_unit_assert=>assert_equals( exp = 1 act = sy-subrc ).
ENDMETHOD.
METHOD empty_input.
DATA lv_totals TYPE string.
DATA lv_count TYPE i.
totals_for( EXPORTING iv_donations = ''
IMPORTING ev_totals = lv_totals
ev_count = lv_count ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_count ).
cl_abap_unit_assert=>assert_equals( exp = '' act = lv_totals ).
ENDMETHOD.
ENDCLASS.