Fix coverage with several contract classes; table annotation and file path checks; clean task dir on write
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
This commit is contained in:
151
tasks_gen/eval/G0128/reference/crew_duty_check.testclasses.abap
Normal file
151
tasks_gen/eval/G0128/reference/crew_duty_check.testclasses.abap
Normal file
@@ -0,0 +1,151 @@
|
||||
CLASS ltc_crew_duty_check DEFINITION FINAL FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
TYPES ty_hours TYPE p LENGTH 4 DECIMALS 1.
|
||||
DATA mo_cut TYPE REF TO {{p}}crew_duty_check.
|
||||
METHODS setup.
|
||||
METHODS base_duty
|
||||
RETURNING VALUE(rs_duty) TYPE {{p}}crew_duty_check=>ty_duty.
|
||||
METHODS valid_duty_is_ok FOR TESTING.
|
||||
METHODS invalid_licence FOR TESTING.
|
||||
METHODS missing_rating FOR TESTING.
|
||||
METHODS rest_below_minimum FOR TESTING.
|
||||
METHODS rest_at_minimum FOR TESTING.
|
||||
METHODS duty_above_maximum FOR TESTING.
|
||||
METHODS duty_at_maximum FOR TESTING.
|
||||
METHODS month_limit_exceeded FOR TESTING.
|
||||
METHODS month_limit_exact FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS ltc_crew_duty_check IMPLEMENTATION.
|
||||
METHOD setup.
|
||||
mo_cut = NEW {{p}}crew_duty_check( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD base_duty.
|
||||
CLEAR rs_duty.
|
||||
rs_duty-crew_id = 'C0001'.
|
||||
rs_duty-licence_valid = abap_true.
|
||||
rs_duty-type_rating = 'A320'.
|
||||
rs_duty-aircraft_type = 'A320'.
|
||||
rs_duty-rest_hours = '12.0'.
|
||||
rs_duty-duty_hours = '8.0'.
|
||||
rs_duty-month_hours = '40.0'.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD valid_duty_is_ok.
|
||||
DATA(ls_duty) = base_duty( ).
|
||||
TRY.
|
||||
mo_cut->check( ls_duty ).
|
||||
CATCH cx_root.
|
||||
cl_abap_unit_assert=>fail( msg = 'valid duty was rejected' ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD invalid_licence.
|
||||
DATA(ls_duty) = base_duty( ).
|
||||
ls_duty-licence_valid = abap_false.
|
||||
TRY.
|
||||
mo_cut->check( ls_duty ).
|
||||
cl_abap_unit_assert=>fail( msg = 'invalid licence was accepted' ).
|
||||
CATCH {{p}}cx_licence_invalid.
|
||||
CATCH cx_root.
|
||||
cl_abap_unit_assert=>fail( msg = 'wrong exception type' ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD missing_rating.
|
||||
DATA(ls_duty) = base_duty( ).
|
||||
ls_duty-type_rating = 'B737'.
|
||||
TRY.
|
||||
mo_cut->check( ls_duty ).
|
||||
cl_abap_unit_assert=>fail( msg = 'missing rating was accepted' ).
|
||||
CATCH {{p}}cx_rating_missing INTO DATA(lo_exc).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'A320'
|
||||
act = lo_exc->mv_required ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'B737'
|
||||
act = lo_exc->mv_held ).
|
||||
CATCH cx_root.
|
||||
cl_abap_unit_assert=>fail( msg = 'wrong exception type' ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rest_below_minimum.
|
||||
DATA(ls_duty) = base_duty( ).
|
||||
ls_duty-rest_hours = '9.9'.
|
||||
DATA lv_expected TYPE ty_hours.
|
||||
lv_expected = '9.9'.
|
||||
TRY.
|
||||
mo_cut->check( ls_duty ).
|
||||
cl_abap_unit_assert=>fail( msg = 'short rest was accepted' ).
|
||||
CATCH {{p}}cx_rest_too_short INTO DATA(lo_exc).
|
||||
cl_abap_unit_assert=>assert_equals( exp = lv_expected
|
||||
act = lo_exc->mv_rest_hours ).
|
||||
CATCH cx_root.
|
||||
cl_abap_unit_assert=>fail( msg = 'wrong exception type' ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rest_at_minimum.
|
||||
DATA(ls_duty) = base_duty( ).
|
||||
ls_duty-rest_hours = '10.0'.
|
||||
TRY.
|
||||
mo_cut->check( ls_duty ).
|
||||
CATCH cx_root.
|
||||
cl_abap_unit_assert=>fail( msg = 'minimum rest was rejected' ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD duty_above_maximum.
|
||||
DATA(ls_duty) = base_duty( ).
|
||||
ls_duty-duty_hours = '13.1'.
|
||||
DATA lv_expected TYPE ty_hours.
|
||||
lv_expected = '13.1'.
|
||||
TRY.
|
||||
mo_cut->check( ls_duty ).
|
||||
cl_abap_unit_assert=>fail( msg = 'long duty was accepted' ).
|
||||
CATCH {{p}}cx_duty_too_long INTO DATA(lo_exc).
|
||||
cl_abap_unit_assert=>assert_equals( exp = lv_expected
|
||||
act = lo_exc->mv_duty_hours ).
|
||||
CATCH cx_root.
|
||||
cl_abap_unit_assert=>fail( msg = 'wrong exception type' ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD duty_at_maximum.
|
||||
DATA(ls_duty) = base_duty( ).
|
||||
ls_duty-duty_hours = '13.0'.
|
||||
TRY.
|
||||
mo_cut->check( ls_duty ).
|
||||
CATCH cx_root.
|
||||
cl_abap_unit_assert=>fail( msg = 'maximum duty was rejected' ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD month_limit_exceeded.
|
||||
DATA(ls_duty) = base_duty( ).
|
||||
ls_duty-month_hours = '95.0'.
|
||||
DATA lv_expected TYPE ty_hours.
|
||||
lv_expected = '103.0'.
|
||||
TRY.
|
||||
mo_cut->check( ls_duty ).
|
||||
cl_abap_unit_assert=>fail( msg = 'month limit was ignored' ).
|
||||
CATCH {{p}}cx_month_limit INTO DATA(lo_exc).
|
||||
cl_abap_unit_assert=>assert_equals( exp = lv_expected
|
||||
act = lo_exc->mv_total_hours ).
|
||||
CATCH cx_root.
|
||||
cl_abap_unit_assert=>fail( msg = 'wrong exception type' ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD month_limit_exact.
|
||||
DATA(ls_duty) = base_duty( ).
|
||||
ls_duty-duty_hours = '8.0'.
|
||||
ls_duty-month_hours = '92.0'.
|
||||
TRY.
|
||||
mo_cut->check( ls_duty ).
|
||||
CATCH cx_root.
|
||||
cl_abap_unit_assert=>fail( msg = 'exact monthly limit was rejected' ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
Reference in New Issue
Block a user