Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
70 lines
2.2 KiB
ABAP
70 lines
2.2 KiB
ABAP
CLASS {{p}}t14_test DEFINITION PUBLIC FINAL CREATE PUBLIC
|
|
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
|
PRIVATE SECTION.
|
|
METHODS price_for
|
|
IMPORTING iv_source TYPE string
|
|
iv_target TYPE string
|
|
iv_words TYPE i
|
|
iv_express TYPE abap_bool
|
|
RETURNING VALUE(rv_price) TYPE decfloat34.
|
|
METHODS standard_pair FOR TESTING.
|
|
METHODS express_and_minimum FOR TESTING.
|
|
METHODS zero_words FOR TESTING.
|
|
METHODS negative_words FOR TESTING.
|
|
ENDCLASS.
|
|
|
|
|
|
CLASS {{p}}t14_test IMPLEMENTATION.
|
|
METHOD price_for.
|
|
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 = rv_price
|
|
EXCEPTIONS
|
|
invalid_words = 1
|
|
OTHERS = 2.
|
|
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
|
|
ENDMETHOD.
|
|
|
|
METHOD standard_pair.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = CONV decfloat34( 120 )
|
|
act = price_for( iv_source = `EN` iv_target = `DE` iv_words = 1000 iv_express = abap_false ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD express_and_minimum.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = CONV decfloat34( 150 )
|
|
act = price_for( iv_source = `EN` iv_target = `DE` iv_words = 1000 iv_express = abap_true ) ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = CONV decfloat34( 25 )
|
|
act = price_for( iv_source = `EN` iv_target = `DE` iv_words = 10 iv_express = abap_false ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD zero_words.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = CONV decfloat34( 0 )
|
|
act = price_for( iv_source = `EN` iv_target = `DE` iv_words = 0 iv_express = abap_false ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD negative_words.
|
|
DATA lv_price TYPE decfloat34.
|
|
CALL FUNCTION '{{P}}TRL_PRICE'
|
|
EXPORTING
|
|
iv_source_lang = `EN`
|
|
iv_target_lang = `DE`
|
|
iv_words = -1
|
|
iv_express = abap_false
|
|
IMPORTING
|
|
ev_price = lv_price
|
|
EXCEPTIONS
|
|
invalid_words = 1
|
|
OTHERS = 2.
|
|
cl_abap_unit_assert=>assert_equals( exp = 1 act = sy-subrc ).
|
|
ENDMETHOD.
|
|
ENDCLASS.
|