Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
105 lines
4.1 KiB
ABAP
105 lines
4.1 KiB
ABAP
CLASS {{p}}t14_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
|
|
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
|
PRIVATE SECTION.
|
|
METHODS call
|
|
IMPORTING iv_source TYPE string
|
|
iv_target TYPE string
|
|
iv_words TYPE i
|
|
iv_express TYPE abap_bool
|
|
iv_price TYPE decfloat34 DEFAULT 7
|
|
EXPORTING ev_price TYPE decfloat34
|
|
ev_subrc TYPE sysubrc.
|
|
METHODS base_rate_en_de FOR TESTING.
|
|
METHODS base_rate_de_en FOR TESTING.
|
|
METHODS base_rate_en_fr FOR TESTING.
|
|
METHODS other_pair_rate FOR TESTING.
|
|
METHODS express_surcharge FOR TESTING.
|
|
METHODS minimum_price FOR TESTING.
|
|
METHODS minimum_with_express FOR TESTING.
|
|
METHODS zero_words_is_free FOR TESTING.
|
|
METHODS rounding_half_up FOR TESTING.
|
|
METHODS negative_words_raises FOR TESTING.
|
|
ENDCLASS.
|
|
|
|
|
|
CLASS {{p}}t14_hidden IMPLEMENTATION.
|
|
METHOD call.
|
|
ev_price = iv_price.
|
|
CALL FUNCTION '{{P}}TRL_PRICE'
|
|
EXPORTING
|
|
iv_source_lang = iv_source
|
|
iv_target_lang = iv_target
|
|
iv_words = iv_words
|
|
iv_express = iv_express
|
|
IMPORTING
|
|
ev_price = ev_price
|
|
EXCEPTIONS
|
|
invalid_words = 1
|
|
OTHERS = 2.
|
|
ev_subrc = sy-subrc.
|
|
ENDMETHOD.
|
|
|
|
METHOD base_rate_en_de.
|
|
call( EXPORTING iv_source = `EN` iv_target = `DE` iv_words = 1000 iv_express = abap_false
|
|
IMPORTING ev_price = DATA(lv_price) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 120 ) act = lv_price ).
|
|
ENDMETHOD.
|
|
|
|
METHOD base_rate_de_en.
|
|
call( EXPORTING iv_source = `DE` iv_target = `EN` iv_words = 1000 iv_express = abap_false
|
|
IMPORTING ev_price = DATA(lv_price) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 120 ) act = lv_price ).
|
|
ENDMETHOD.
|
|
|
|
METHOD base_rate_en_fr.
|
|
call( EXPORTING iv_source = `EN` iv_target = `FR` iv_words = 1000 iv_express = abap_false
|
|
IMPORTING ev_price = DATA(lv_price) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 150 ) act = lv_price ).
|
|
ENDMETHOD.
|
|
|
|
METHOD other_pair_rate.
|
|
call( EXPORTING iv_source = `ES` iv_target = `IT` iv_words = 1000 iv_express = abap_false
|
|
IMPORTING ev_price = DATA(lv_price) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 200 ) act = lv_price ).
|
|
ENDMETHOD.
|
|
|
|
METHOD express_surcharge.
|
|
call( EXPORTING iv_source = `EN` iv_target = `DE` iv_words = 1000 iv_express = abap_true
|
|
IMPORTING ev_price = DATA(lv_price) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 150 ) act = lv_price ).
|
|
ENDMETHOD.
|
|
|
|
METHOD minimum_price.
|
|
call( EXPORTING iv_source = `EN` iv_target = `DE` iv_words = 100 iv_express = abap_false
|
|
IMPORTING ev_price = DATA(lv_price) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 25 ) act = lv_price ).
|
|
ENDMETHOD.
|
|
|
|
METHOD minimum_with_express.
|
|
call( EXPORTING iv_source = `EN` iv_target = `DE` iv_words = 100 iv_express = abap_true
|
|
IMPORTING ev_price = DATA(lv_price) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 25 ) act = lv_price ).
|
|
ENDMETHOD.
|
|
|
|
METHOD zero_words_is_free.
|
|
call( EXPORTING iv_source = `EN` iv_target = `DE` iv_words = 0 iv_express = abap_false
|
|
IMPORTING ev_price = DATA(lv_price) ev_subrc = DATA(lv_rc) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 0 ) act = lv_price ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
|
|
ENDMETHOD.
|
|
|
|
METHOD rounding_half_up.
|
|
call( EXPORTING iv_source = `EN` iv_target = `FR` iv_words = 333 iv_express = abap_true
|
|
IMPORTING ev_price = DATA(lv_price) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '62.44' ) act = lv_price ).
|
|
ENDMETHOD.
|
|
|
|
METHOD negative_words_raises.
|
|
call( EXPORTING iv_source = `EN` iv_target = `DE` iv_words = -1 iv_express = abap_false
|
|
iv_price = CONV decfloat34( 7 )
|
|
IMPORTING ev_price = DATA(lv_price) ev_subrc = DATA(lv_rc) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_rc ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 7 ) act = lv_price ).
|
|
ENDMETHOD.
|
|
ENDCLASS.
|