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,171 @@
CLASS {{p}}t_mush_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
METHODS setup.
METHODS teardown.
METHODS add_batch
IMPORTING iv_room TYPE string iv_grade TYPE string
iv_batch TYPE string iv_weight TYPE decfloat34.
METHODS call
IMPORTING iv_a TYPE string iv_b TYPE string
EXPORTING ev_total TYPE decfloat34 ev_rooms TYPE i
ev_grade TYPE char1 ev_subrc TYPE sysubrc.
METHODS totals_two_rooms FOR TESTING.
METHODS ignores_other_room FOR TESTING.
METHODS ignores_bad_grade FOR TESTING.
METHODS ignores_zero_weight FOR TESTING.
METHODS ignores_negative_weight FOR TESTING.
METHODS counts_rooms FOR TESTING.
METHODS top_grade_by_weight FOR TESTING.
METHODS top_grade_tie FOR TESTING.
METHODS empty_table_raises FOR TESTING.
METHODS no_counting_row_raises FOR TESTING.
METHODS ignores_empty_room FOR TESTING.
ENDCLASS.
CLASS {{p}}t_mush_hidden IMPLEMENTATION.
METHOD setup.
DELETE FROM {{P}}HARVEST.
ENDMETHOD.
METHOD teardown.
DELETE FROM {{P}}HARVEST.
ENDMETHOD.
METHOD add_batch.
DATA ls_row TYPE {{P}}HARVEST.
ls_row-room_id = iv_room.
ls_row-grade = iv_grade.
ls_row-batch_no = iv_batch.
ls_row-weight_kg = iv_weight.
INSERT {{P}}HARVEST FROM @ls_row.
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
ENDMETHOD.
METHOD call.
CALL FUNCTION '{{P}}MUSH_HARVEST'
EXPORTING
iv_room_a = iv_a
iv_room_b = iv_b
IMPORTING
ev_total_kg = ev_total
ev_room_count = ev_rooms
ev_top_grade = ev_grade
EXCEPTIONS
no_stock = 1
OTHERS = 2.
ev_subrc = sy-subrc.
ENDMETHOD.
METHOD totals_two_rooms.
add_batch( iv_room = 'R01' iv_grade = 'A' iv_batch = '001' iv_weight = '10.000' ).
add_batch( iv_room = 'R01' iv_grade = 'B' iv_batch = '002' iv_weight = '2.500' ).
add_batch( iv_room = 'R02' iv_grade = 'A' iv_batch = '001' iv_weight = '1.500' ).
call( EXPORTING iv_a = 'R01' iv_b = 'R02'
IMPORTING ev_total = DATA(lv_total) ev_rooms = DATA(lv_rooms) ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '14' ) act = lv_total ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = lv_rooms ).
ENDMETHOD.
METHOD ignores_other_room.
add_batch( iv_room = 'R01' iv_grade = 'A' iv_batch = '001' iv_weight = '4.000' ).
add_batch( iv_room = 'R03' iv_grade = 'A' iv_batch = '001' iv_weight = '9.000' ).
call( EXPORTING iv_a = 'R01' iv_b = 'R02'
IMPORTING ev_total = DATA(lv_total) ev_rooms = DATA(lv_rooms) ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 4 ) act = lv_total ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_rooms ).
ENDMETHOD.
METHOD ignores_bad_grade.
add_batch( iv_room = 'R01' iv_grade = 'D' iv_batch = '001' iv_weight = '7.000' ).
add_batch( iv_room = 'R01' iv_grade = 'a' iv_batch = '002' iv_weight = '7.000' ).
add_batch( iv_room = 'R01' iv_grade = 'A' iv_batch = '003' iv_weight = '1.000' ).
call( EXPORTING iv_a = 'R01' iv_b = 'R02'
IMPORTING ev_total = DATA(lv_total) ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 1 ) act = lv_total ).
ENDMETHOD.
METHOD ignores_zero_weight.
add_batch( iv_room = 'R01' iv_grade = 'A' iv_batch = '001' iv_weight = '0.000' ).
add_batch( iv_room = 'R01' iv_grade = 'B' iv_batch = '002' iv_weight = '4.000' ).
call( EXPORTING iv_a = 'R01' iv_b = 'R02'
IMPORTING ev_total = DATA(lv_total) ev_grade = DATA(lv_grade) ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 4 ) act = lv_total ).
cl_abap_unit_assert=>assert_equals( exp = 'B' act = lv_grade ).
ENDMETHOD.
METHOD ignores_negative_weight.
add_batch( iv_room = 'R01' iv_grade = 'A' iv_batch = '001' iv_weight = '-3.000' ).
add_batch( iv_room = 'R01' iv_grade = 'B' iv_batch = '002' iv_weight = '4.000' ).
call( EXPORTING iv_a = 'R01' iv_b = 'R02'
IMPORTING ev_total = DATA(lv_total) ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 4 ) act = lv_total ).
ENDMETHOD.
METHOD counts_rooms.
add_batch( iv_room = 'R01' iv_grade = 'A' iv_batch = '001' iv_weight = '5.000' ).
add_batch( iv_room = 'R01' iv_grade = 'B' iv_batch = '002' iv_weight = '5.000' ).
add_batch( iv_room = 'R02' iv_grade = 'C' iv_batch = '001' iv_weight = '5.000' ).
call( EXPORTING iv_a = 'R01' iv_b = 'R02'
IMPORTING ev_total = DATA(lv_total) ev_rooms = DATA(lv_rooms) ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 15 ) act = lv_total ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = lv_rooms ).
ENDMETHOD.
METHOD top_grade_by_weight.
add_batch( iv_room = 'R01' iv_grade = 'A' iv_batch = '001' iv_weight = '1.000' ).
add_batch( iv_room = 'R01' iv_grade = 'B' iv_batch = '002' iv_weight = '9.000' ).
add_batch( iv_room = 'R02' iv_grade = 'C' iv_batch = '001' iv_weight = '2.000' ).
call( EXPORTING iv_a = 'R01' iv_b = 'R02'
IMPORTING ev_grade = DATA(lv_grade) ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
cl_abap_unit_assert=>assert_equals( exp = 'B' act = lv_grade ).
ENDMETHOD.
METHOD top_grade_tie.
add_batch( iv_room = 'R01' iv_grade = 'C' iv_batch = '001' iv_weight = '5.000' ).
add_batch( iv_room = 'R01' iv_grade = 'A' iv_batch = '002' iv_weight = '5.000' ).
call( EXPORTING iv_a = 'R01' iv_b = 'R01'
IMPORTING ev_grade = DATA(lv_grade) ev_rooms = DATA(lv_rooms) ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
cl_abap_unit_assert=>assert_equals( exp = 'A' act = lv_grade ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_rooms ).
ENDMETHOD.
METHOD empty_table_raises.
call( EXPORTING iv_a = 'R01' iv_b = 'R02'
IMPORTING ev_total = DATA(lv_total) ev_rooms = DATA(lv_rooms)
ev_grade = DATA(lv_grade) ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_rc ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 0 ) act = lv_total ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rooms ).
cl_abap_unit_assert=>assert_initial( act = lv_grade ).
ENDMETHOD.
METHOD no_counting_row_raises.
add_batch( iv_room = 'R01' iv_grade = 'D' iv_batch = '001' iv_weight = '5.000' ).
add_batch( iv_room = 'R01' iv_grade = 'A' iv_batch = '002' iv_weight = '0.000' ).
call( EXPORTING iv_a = 'R01' iv_b = 'R02'
IMPORTING ev_total = DATA(lv_total) ev_rooms = DATA(lv_rooms) ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_rc ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 0 ) act = lv_total ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rooms ).
ENDMETHOD.
METHOD ignores_empty_room.
add_batch( iv_room = '' iv_grade = 'A' iv_batch = '001' iv_weight = '9.000' ).
add_batch( iv_room = 'R01' iv_grade = 'A' iv_batch = '001' iv_weight = '1.000' ).
call( EXPORTING iv_a = '' iv_b = 'R01'
IMPORTING ev_total = DATA(lv_total) ev_rooms = DATA(lv_rooms) ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 1 ) act = lv_total ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_rooms ).
ENDMETHOD.
ENDCLASS.