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:
254
tasks_gen/eval/G0127/files/hidden/t02_hidden.clas.abap
Normal file
254
tasks_gen/eval/G0127/files/hidden/t02_hidden.clas.abap
Normal file
@@ -0,0 +1,254 @@
|
||||
CLASS {{p}}t02_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
DATA mo_cut TYPE REF TO {{p}}ferry_load_check.
|
||||
DATA mo_error TYPE REF TO {{p}}cx_ferry_error.
|
||||
METHODS setup.
|
||||
METHODS valid_car_is_ok FOR TESTING.
|
||||
METHODS valid_truck_hazard_ok FOR TESTING.
|
||||
METHODS empty_plate_rejected FOR TESTING.
|
||||
METHODS bad_plate_char_rejected FOR TESTING.
|
||||
METHODS unknown_category_rejected FOR TESTING.
|
||||
METHODS zero_weight_rejected FOR TESTING.
|
||||
METHODS zero_size_rejected FOR TESTING.
|
||||
METHODS hazard_in_car_rejected FOR TESTING.
|
||||
METHODS too_high_rejected FOR TESTING.
|
||||
METHODS weight_limit_rejected FOR TESTING.
|
||||
METHODS length_limit_rejected FOR TESTING.
|
||||
METHODS plate_error_wins FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}t02_hidden IMPLEMENTATION.
|
||||
METHOD setup.
|
||||
mo_cut = NEW {{p}}ferry_load_check( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD valid_car_is_ok.
|
||||
DATA(ls_vehicle) = VALUE {{p}}ferry_load_check=>ty_vehicle(
|
||||
plate = 'b ab 1234'
|
||||
category = 'C'
|
||||
weight_kg = 1500
|
||||
length_cm = 450
|
||||
height_cm = 150
|
||||
hazard = abap_false ).
|
||||
TRY.
|
||||
mo_cut->check_loading( is_vehicle = ls_vehicle
|
||||
iv_free_weight = 5000
|
||||
iv_free_length = 2000
|
||||
iv_max_height = 200 ).
|
||||
CATCH {{p}}cx_ferry_error INTO mo_error.
|
||||
cl_abap_unit_assert=>fail( msg = mo_error->reason ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD valid_truck_hazard_ok.
|
||||
DATA(ls_vehicle) = VALUE {{p}}ferry_load_check=>ty_vehicle(
|
||||
plate = 'HH-TR 900'
|
||||
category = 'T'
|
||||
weight_kg = 12000
|
||||
length_cm = 1200
|
||||
height_cm = 380
|
||||
hazard = abap_true ).
|
||||
TRY.
|
||||
mo_cut->check_loading( is_vehicle = ls_vehicle
|
||||
iv_free_weight = 20000
|
||||
iv_free_length = 5000
|
||||
iv_max_height = 400 ).
|
||||
CATCH {{p}}cx_ferry_error INTO mo_error.
|
||||
cl_abap_unit_assert=>fail( msg = mo_error->reason ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD empty_plate_rejected.
|
||||
DATA(ls_vehicle) = VALUE {{p}}ferry_load_check=>ty_vehicle(
|
||||
plate = space
|
||||
category = 'C'
|
||||
weight_kg = 1500
|
||||
length_cm = 450
|
||||
height_cm = 150
|
||||
hazard = abap_false ).
|
||||
TRY.
|
||||
mo_cut->check_vehicle( is_vehicle = ls_vehicle ).
|
||||
cl_abap_unit_assert=>fail( msg = 'empty plate accepted' ).
|
||||
CATCH {{p}}cx_ferry_error INTO mo_error.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_ferry_reason=>c_reason-plate
|
||||
act = mo_error->reason ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD bad_plate_char_rejected.
|
||||
DATA(ls_vehicle) = VALUE {{p}}ferry_load_check=>ty_vehicle(
|
||||
plate = 'B-AB#123'
|
||||
category = 'C'
|
||||
weight_kg = 1500
|
||||
length_cm = 450
|
||||
height_cm = 150
|
||||
hazard = abap_false ).
|
||||
TRY.
|
||||
mo_cut->check_vehicle( is_vehicle = ls_vehicle ).
|
||||
cl_abap_unit_assert=>fail( msg = 'bad plate accepted' ).
|
||||
CATCH {{p}}cx_ferry_error INTO mo_error.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_ferry_reason=>c_reason-plate
|
||||
act = mo_error->reason ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD unknown_category_rejected.
|
||||
DATA(ls_vehicle) = VALUE {{p}}ferry_load_check=>ty_vehicle(
|
||||
plate = 'B-AB 1234'
|
||||
category = 'X'
|
||||
weight_kg = 1500
|
||||
length_cm = 450
|
||||
height_cm = 150
|
||||
hazard = abap_false ).
|
||||
TRY.
|
||||
mo_cut->check_vehicle( is_vehicle = ls_vehicle ).
|
||||
cl_abap_unit_assert=>fail( msg = 'unknown category accepted' ).
|
||||
CATCH {{p}}cx_ferry_error INTO mo_error.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_ferry_reason=>c_reason-category
|
||||
act = mo_error->reason ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD zero_weight_rejected.
|
||||
DATA(ls_vehicle) = VALUE {{p}}ferry_load_check=>ty_vehicle(
|
||||
plate = 'B-AB 1234'
|
||||
category = 'C'
|
||||
weight_kg = 0
|
||||
length_cm = 450
|
||||
height_cm = 150
|
||||
hazard = abap_false ).
|
||||
TRY.
|
||||
mo_cut->check_vehicle( is_vehicle = ls_vehicle ).
|
||||
cl_abap_unit_assert=>fail( msg = 'zero weight accepted' ).
|
||||
CATCH {{p}}cx_ferry_error INTO mo_error.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_ferry_reason=>c_reason-weight
|
||||
act = mo_error->reason ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD zero_size_rejected.
|
||||
DATA(ls_vehicle) = VALUE {{p}}ferry_load_check=>ty_vehicle(
|
||||
plate = 'B-AB 1234'
|
||||
category = 'C'
|
||||
weight_kg = 1500
|
||||
length_cm = 0
|
||||
height_cm = 150
|
||||
hazard = abap_false ).
|
||||
TRY.
|
||||
mo_cut->check_vehicle( is_vehicle = ls_vehicle ).
|
||||
cl_abap_unit_assert=>fail( msg = 'zero size accepted' ).
|
||||
CATCH {{p}}cx_ferry_error INTO mo_error.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_ferry_reason=>c_reason-size
|
||||
act = mo_error->reason ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD hazard_in_car_rejected.
|
||||
DATA(ls_vehicle) = VALUE {{p}}ferry_load_check=>ty_vehicle(
|
||||
plate = 'B-AB 1234'
|
||||
category = 'C'
|
||||
weight_kg = 1500
|
||||
length_cm = 450
|
||||
height_cm = 150
|
||||
hazard = abap_true ).
|
||||
TRY.
|
||||
mo_cut->check_vehicle( is_vehicle = ls_vehicle ).
|
||||
cl_abap_unit_assert=>fail( msg = 'hazard in car accepted' ).
|
||||
CATCH {{p}}cx_ferry_error INTO mo_error.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_ferry_reason=>c_reason-hazard
|
||||
act = mo_error->reason ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD too_high_rejected.
|
||||
DATA(ls_vehicle) = VALUE {{p}}ferry_load_check=>ty_vehicle(
|
||||
plate = 'B-AB 1234'
|
||||
category = 'C'
|
||||
weight_kg = 1500
|
||||
length_cm = 450
|
||||
height_cm = 250
|
||||
hazard = abap_false ).
|
||||
TRY.
|
||||
mo_cut->check_loading( is_vehicle = ls_vehicle
|
||||
iv_free_weight = 5000
|
||||
iv_free_length = 2000
|
||||
iv_max_height = 200 ).
|
||||
cl_abap_unit_assert=>fail( msg = 'too high accepted' ).
|
||||
CATCH {{p}}cx_ferry_error INTO mo_error.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_ferry_reason=>c_reason-height
|
||||
act = mo_error->reason ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD weight_limit_rejected.
|
||||
DATA(ls_vehicle) = VALUE {{p}}ferry_load_check=>ty_vehicle(
|
||||
plate = 'B-AB 1234'
|
||||
category = 'C'
|
||||
weight_kg = 6000
|
||||
length_cm = 450
|
||||
height_cm = 150
|
||||
hazard = abap_false ).
|
||||
TRY.
|
||||
mo_cut->check_loading( is_vehicle = ls_vehicle
|
||||
iv_free_weight = 5000
|
||||
iv_free_length = 2000
|
||||
iv_max_height = 200 ).
|
||||
cl_abap_unit_assert=>fail( msg = 'weight limit accepted' ).
|
||||
CATCH {{p}}cx_ferry_error INTO mo_error.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_ferry_reason=>c_reason-weight_limit
|
||||
act = mo_error->reason ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD length_limit_rejected.
|
||||
DATA(ls_vehicle) = VALUE {{p}}ferry_load_check=>ty_vehicle(
|
||||
plate = 'B-AB 1234'
|
||||
category = 'C'
|
||||
weight_kg = 1500
|
||||
length_cm = 2500
|
||||
height_cm = 150
|
||||
hazard = abap_false ).
|
||||
TRY.
|
||||
mo_cut->check_loading( is_vehicle = ls_vehicle
|
||||
iv_free_weight = 5000
|
||||
iv_free_length = 2000
|
||||
iv_max_height = 200 ).
|
||||
cl_abap_unit_assert=>fail( msg = 'length limit accepted' ).
|
||||
CATCH {{p}}cx_ferry_error INTO mo_error.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_ferry_reason=>c_reason-length_limit
|
||||
act = mo_error->reason ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD plate_error_wins.
|
||||
DATA(ls_vehicle) = VALUE {{p}}ferry_load_check=>ty_vehicle(
|
||||
plate = space
|
||||
category = 'C'
|
||||
weight_kg = 9999
|
||||
length_cm = 450
|
||||
height_cm = 150
|
||||
hazard = abap_false ).
|
||||
TRY.
|
||||
mo_cut->check_loading( is_vehicle = ls_vehicle
|
||||
iv_free_weight = 1000
|
||||
iv_free_length = 2000
|
||||
iv_max_height = 200 ).
|
||||
cl_abap_unit_assert=>fail( msg = 'empty plate accepted' ).
|
||||
CATCH {{p}}cx_ferry_error INTO mo_error.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_ferry_reason=>c_reason-plate
|
||||
act = mo_error->reason ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
Reference in New Issue
Block a user