Files
abap-llm/tasks_gen/train/G1095/reference/t14_test.clas.abap
2026-10-05 18:02:52 +02:00

86 lines
3.1 KiB
ABAP

CLASS {{p}}t14_test DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
METHODS call_fee
IMPORTING
iv_tour_type TYPE string
iv_passengers TYPE i
iv_minutes TYPE i
iv_member TYPE abap_bool DEFAULT abap_false
iv_fee TYPE decfloat34 DEFAULT 7
EXPORTING
ev_fee TYPE decfloat34
ev_skip TYPE abap_bool
ev_subrc TYPE sysubrc.
METHODS scenic_price FOR TESTING.
METHODS member_price FOR TESTING.
METHODS training_price FOR TESTING.
METHODS charter_price FOR TESTING.
METHODS invalid_input FOR TESTING.
ENDCLASS.
CLASS {{p}}t14_test IMPLEMENTATION.
METHOD call_fee.
ev_fee = iv_fee.
CALL FUNCTION '{{P}}HELI_FEE'
EXPORTING
iv_tour_type = iv_tour_type
iv_passengers = iv_passengers
iv_minutes = iv_minutes
iv_member = iv_member
IMPORTING
ev_skip = ev_skip
CHANGING
cv_fee = ev_fee
EXCEPTIONS
invalid_passengers = 1
invalid_minutes = 2
OTHERS = 3.
ev_subrc = sy-subrc.
ENDMETHOD.
METHOD scenic_price.
call_fee( EXPORTING iv_tour_type = `SC` iv_passengers = 2 iv_minutes = 10
IMPORTING ev_fee = DATA(lv_fee) ev_skip = DATA(lv_skip) 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( 110 ) act = lv_fee ).
cl_abap_unit_assert=>assert_false( lv_skip ).
ENDMETHOD.
METHOD member_price.
call_fee( EXPORTING iv_tour_type = `SC` iv_passengers = 3 iv_minutes = 7 iv_member = abap_true
IMPORTING ev_fee = DATA(lv_fee) 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( '88.38' ) act = lv_fee ).
ENDMETHOD.
METHOD training_price.
call_fee( EXPORTING iv_tour_type = `TR` iv_passengers = 2 iv_minutes = 10
IMPORTING ev_fee = DATA(lv_fee) 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( 120 ) act = lv_fee ).
ENDMETHOD.
METHOD charter_price.
call_fee( EXPORTING iv_tour_type = `CH` iv_passengers = 2 iv_minutes = 10 iv_fee = 7
IMPORTING ev_fee = DATA(lv_fee) ev_skip = DATA(lv_skip) ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
cl_abap_unit_assert=>assert_true( lv_skip ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 7 ) act = lv_fee ).
ENDMETHOD.
METHOD invalid_input.
call_fee( EXPORTING iv_tour_type = `SC` iv_passengers = 0 iv_minutes = 10
IMPORTING ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_rc ).
call_fee( EXPORTING iv_tour_type = `TR` iv_passengers = 2 iv_minutes = 4
IMPORTING ev_subrc = DATA(lv_rc_minutes) ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = lv_rc_minutes ).
ENDMETHOD.
ENDCLASS.