Files
abap-llm/tasks_gen/eval/G0157/reference/t14_test.clas.abap

59 lines
1.7 KiB
ABAP

CLASS {{p}}t14_test DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
METHODS deposit_of
IMPORTING iv_code TYPE c
iv_quantity TYPE i
iv_damaged TYPE abap_bool DEFAULT abap_false
RETURNING VALUE(rv_deposit) TYPE decfloat34.
METHODS full_deposit FOR TESTING.
METHODS damaged_deposit FOR TESTING.
METHODS invalid_input FOR TESTING.
ENDCLASS.
CLASS {{p}}t14_test IMPLEMENTATION.
METHOD deposit_of.
CALL FUNCTION '{{P}}DEP_CALC'
EXPORTING
iv_code = iv_code
iv_quantity = iv_quantity
iv_damaged = iv_damaged
IMPORTING
ev_deposit = rv_deposit
EXCEPTIONS
invalid_quantity = 1
invalid_container = 2
OTHERS = 3.
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
ENDMETHOD.
METHOD full_deposit.
DATA lv_exp TYPE decfloat34 VALUE '6.00'.
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = deposit_of( iv_code = 'B' iv_quantity = 2 ) ).
ENDMETHOD.
METHOD damaged_deposit.
DATA lv_exp TYPE decfloat34 VALUE '0.39'.
DATA lv_act TYPE decfloat34.
lv_act = deposit_of( iv_code = 'P' iv_quantity = 3 iv_damaged = abap_true ).
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = lv_act ).
ENDMETHOD.
METHOD invalid_input.
DATA lv_deposit TYPE decfloat34.
CALL FUNCTION '{{P}}DEP_CALC'
EXPORTING
iv_code = 'Z'
iv_quantity = 1
iv_damaged = abap_false
IMPORTING
ev_deposit = lv_deposit
EXCEPTIONS
invalid_quantity = 1
invalid_container = 2
OTHERS = 3.
cl_abap_unit_assert=>assert_equals( exp = 2 act = sy-subrc ).
ENDMETHOD.
ENDCLASS.