Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
127 lines
3.9 KiB
ABAP
127 lines
3.9 KiB
ABAP
CLASS {{p}}t14_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
|
|
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
|
PRIVATE SECTION.
|
|
METHODS deposit_for
|
|
IMPORTING iv_code TYPE c
|
|
iv_quantity TYPE i
|
|
iv_damaged TYPE abap_bool DEFAULT abap_false
|
|
RETURNING VALUE(rv_deposit) TYPE decfloat34.
|
|
METHODS crate_a_full FOR TESTING.
|
|
METHODS crate_b_full FOR TESTING.
|
|
METHODS glass_full FOR TESTING.
|
|
METHODS pet_full FOR TESTING.
|
|
METHODS damaged_crate FOR TESTING.
|
|
METHODS damaged_rounds_up FOR TESTING.
|
|
METHODS damaged_glass_total FOR TESTING.
|
|
METHODS zero_quantity FOR TESTING.
|
|
METHODS negative_quantity FOR TESTING.
|
|
METHODS unknown_code FOR TESTING.
|
|
ENDCLASS.
|
|
|
|
|
|
CLASS {{p}}t14_hidden IMPLEMENTATION.
|
|
METHOD deposit_for.
|
|
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 crate_a_full.
|
|
DATA lv_exp TYPE decfloat34 VALUE '3.00'.
|
|
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = deposit_for( iv_code = 'A' iv_quantity = 2 ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD crate_b_full.
|
|
DATA lv_exp TYPE decfloat34 VALUE '3.00'.
|
|
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = deposit_for( iv_code = 'B' iv_quantity = 1 ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD glass_full.
|
|
DATA lv_exp TYPE decfloat34 VALUE '0.80'.
|
|
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = deposit_for( iv_code = 'G' iv_quantity = 10 ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD pet_full.
|
|
DATA lv_exp TYPE decfloat34 VALUE '1.00'.
|
|
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = deposit_for( iv_code = 'P' iv_quantity = 4 ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD damaged_crate.
|
|
DATA lv_exp TYPE decfloat34 VALUE '3.00'.
|
|
DATA lv_act TYPE decfloat34.
|
|
lv_act = deposit_for( iv_code = 'B' iv_quantity = 2 iv_damaged = abap_true ).
|
|
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = lv_act ).
|
|
ENDMETHOD.
|
|
|
|
METHOD damaged_rounds_up.
|
|
DATA lv_exp TYPE decfloat34 VALUE '0.39'.
|
|
DATA lv_act TYPE decfloat34.
|
|
lv_act = deposit_for( iv_code = 'P' iv_quantity = 3 iv_damaged = abap_true ).
|
|
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = lv_act ).
|
|
ENDMETHOD.
|
|
|
|
METHOD damaged_glass_total.
|
|
DATA lv_exp TYPE decfloat34 VALUE '0.12'.
|
|
DATA lv_act TYPE decfloat34.
|
|
lv_act = deposit_for( iv_code = 'G' iv_quantity = 3 iv_damaged = abap_true ).
|
|
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = lv_act ).
|
|
ENDMETHOD.
|
|
|
|
METHOD zero_quantity.
|
|
DATA lv_deposit TYPE decfloat34.
|
|
CALL FUNCTION '{{P}}DEP_CALC'
|
|
EXPORTING
|
|
iv_code = 'A'
|
|
iv_quantity = 0
|
|
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 = 1 act = sy-subrc ).
|
|
ENDMETHOD.
|
|
|
|
METHOD negative_quantity.
|
|
DATA lv_deposit TYPE decfloat34.
|
|
CALL FUNCTION '{{P}}DEP_CALC'
|
|
EXPORTING
|
|
iv_code = 'G'
|
|
iv_quantity = -3
|
|
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 = 1 act = sy-subrc ).
|
|
ENDMETHOD.
|
|
|
|
METHOD unknown_code.
|
|
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.
|