mirror of
https://github.com/abap2xlsx/abap2xlsx.git
synced 2025-05-05 11:06:15 +08:00
zcl_excel_common: unit tests cleanup (#806)
* common: unit tests cleanup * refactor macro to method * refactor macro to method * delete old commented lines (method definitions char2hex and number_to_excel_string) Co-authored-by: sandraros <34005250+sandraros@users.noreply.github.com> Co-authored-by: sandraros <sandra.rossi@gmail.com>
This commit is contained in:
parent
10b8df9b2f
commit
24ae5ecef2
|
@ -9,55 +9,45 @@ CLASS zcl_excel_common DEFINITION LOCAL FRIENDS lcl_excel_common_test.
|
||||||
CLASS lcl_excel_common_test DEFINITION FOR TESTING
|
CLASS lcl_excel_common_test DEFINITION FOR TESTING
|
||||||
RISK LEVEL HARMLESS
|
RISK LEVEL HARMLESS
|
||||||
DURATION SHORT.
|
DURATION SHORT.
|
||||||
*?<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
|
||||||
*?<asx:values>
|
|
||||||
*?<TESTCLASS_OPTIONS>
|
|
||||||
*?<TEST_CLASS>lcl_Excel_Common_Test
|
|
||||||
*?</TEST_CLASS>
|
|
||||||
*?<TEST_MEMBER>f_Cut
|
|
||||||
*?</TEST_MEMBER>
|
|
||||||
*?<OBJECT_UNDER_TEST>ZCL_EXCEL_COMMON
|
|
||||||
*?</OBJECT_UNDER_TEST>
|
|
||||||
*?<OBJECT_IS_LOCAL/>
|
|
||||||
*?<GENERATE_FIXTURE>X
|
|
||||||
*?</GENERATE_FIXTURE>
|
|
||||||
*?<GENERATE_CLASS_FIXTURE>X
|
|
||||||
*?</GENERATE_CLASS_FIXTURE>
|
|
||||||
*?<GENERATE_INVOCATION>X
|
|
||||||
*?</GENERATE_INVOCATION>
|
|
||||||
*?<GENERATE_ASSERT_EQUAL>X
|
|
||||||
*?</GENERATE_ASSERT_EQUAL>
|
|
||||||
*?</TESTCLASS_OPTIONS>
|
|
||||||
*?</asx:values>
|
|
||||||
*?</asx:abap>
|
|
||||||
PRIVATE SECTION.
|
PRIVATE SECTION.
|
||||||
* ================
|
* ================
|
||||||
DATA:
|
DATA:
|
||||||
lx_excel TYPE REF TO zcx_excel,
|
lx_excel TYPE REF TO zcx_excel,
|
||||||
ls_symsg_act TYPE symsg, " actual messageinformation of exception
|
ls_symsg_act TYPE symsg, " actual messageinformation of exception
|
||||||
ls_symsg_exp TYPE symsg, " expected messageinformation of exception
|
ls_symsg_exp TYPE symsg, " expected messageinformation of exception
|
||||||
f_cut TYPE REF TO zcl_excel_common. "class under test
|
f_cut TYPE REF TO zcl_excel_common. "class under test
|
||||||
|
|
||||||
CLASS-METHODS: class_setup.
|
|
||||||
CLASS-METHODS: class_teardown.
|
|
||||||
METHODS: setup.
|
METHODS: setup.
|
||||||
METHODS: teardown.
|
|
||||||
* METHODS: char2hex FOR TESTING.
|
|
||||||
METHODS: convert_column2alpha FOR TESTING.
|
METHODS: convert_column2alpha FOR TESTING.
|
||||||
METHODS: convert_column2int FOR TESTING.
|
METHODS: convert_column2int FOR TESTING.
|
||||||
METHODS: date_to_excel_string FOR TESTING.
|
METHODS: date_to_excel_string FOR TESTING.
|
||||||
METHODS: encrypt_password FOR TESTING.
|
METHODS: encrypt_password FOR TESTING.
|
||||||
METHODS: excel_string_to_date FOR TESTING.
|
METHODS: excel_string_to_date FOR TESTING.
|
||||||
METHODS: excel_string_to_time FOR TESTING.
|
METHODS: excel_string_to_time FOR TESTING.
|
||||||
* METHODS: number_to_excel_string FOR TESTING.
|
|
||||||
METHODS: time_to_excel_string FOR TESTING.
|
METHODS: time_to_excel_string FOR TESTING.
|
||||||
METHODS: split_file FOR TESTING.
|
METHODS: split_file FOR TESTING.
|
||||||
METHODS: convert_range2column_a_row FOR TESTING.
|
METHODS: convert_range2column_a_row FOR TESTING RAISING cx_static_check.
|
||||||
METHODS: describe_structure FOR TESTING.
|
METHODS: describe_structure FOR TESTING.
|
||||||
METHODS: calculate_cell_distance FOR TESTING.
|
METHODS macro_calculate_cell_distance
|
||||||
|
IMPORTING
|
||||||
|
iv_reference_cell TYPE clike
|
||||||
|
iv_current_cell TYPE clike
|
||||||
|
iv_expected_column TYPE i
|
||||||
|
iv_expected_row TYPE i
|
||||||
|
RAISING
|
||||||
|
cx_static_check.
|
||||||
|
METHODS: calculate_cell_distance FOR TESTING RAISING cx_static_check.
|
||||||
|
|
||||||
|
METHODS macro_shift_formula
|
||||||
|
IMPORTING
|
||||||
|
iv_reference_formula TYPE clike
|
||||||
|
iv_shift_cols TYPE i
|
||||||
|
iv_shift_rows TYPE i
|
||||||
|
iv_expected TYPE string.
|
||||||
METHODS: shift_formula FOR TESTING.
|
METHODS: shift_formula FOR TESTING.
|
||||||
METHODS: is_cell_in_range FOR TESTING.
|
METHODS: is_cell_in_range FOR TESTING.
|
||||||
ENDCLASS. "lcl_Excel_Common_Test
|
ENDCLASS.
|
||||||
|
|
||||||
|
|
||||||
*----------------------------------------------------------------------*
|
*----------------------------------------------------------------------*
|
||||||
|
@ -68,20 +58,6 @@ ENDCLASS. "lcl_Excel_Common_Test
|
||||||
CLASS lcl_excel_common_test IMPLEMENTATION.
|
CLASS lcl_excel_common_test IMPLEMENTATION.
|
||||||
* ===========================================
|
* ===========================================
|
||||||
|
|
||||||
METHOD class_setup.
|
|
||||||
* ===================
|
|
||||||
|
|
||||||
|
|
||||||
ENDMETHOD. "class_Setup
|
|
||||||
|
|
||||||
|
|
||||||
METHOD class_teardown.
|
|
||||||
* ======================
|
|
||||||
|
|
||||||
|
|
||||||
ENDMETHOD. "class_Teardown
|
|
||||||
|
|
||||||
|
|
||||||
METHOD setup.
|
METHOD setup.
|
||||||
* =============
|
* =============
|
||||||
|
|
||||||
|
@ -89,13 +65,6 @@ CLASS lcl_excel_common_test IMPLEMENTATION.
|
||||||
ENDMETHOD. "setup
|
ENDMETHOD. "setup
|
||||||
|
|
||||||
|
|
||||||
METHOD teardown.
|
|
||||||
* ================
|
|
||||||
|
|
||||||
|
|
||||||
ENDMETHOD. "teardown
|
|
||||||
|
|
||||||
|
|
||||||
METHOD convert_column2alpha.
|
METHOD convert_column2alpha.
|
||||||
* ============================
|
* ============================
|
||||||
DATA ep_column TYPE zexcel_cell_column_alpha.
|
DATA ep_column TYPE zexcel_cell_column_alpha.
|
||||||
|
@ -706,9 +675,9 @@ CLASS lcl_excel_common_test IMPLEMENTATION.
|
||||||
METHOD split_file.
|
METHOD split_file.
|
||||||
* ============================
|
* ============================
|
||||||
|
|
||||||
DATA: ep_file TYPE text255,
|
DATA: ep_file TYPE text255,
|
||||||
ep_extension TYPE char10,
|
ep_extension TYPE char10,
|
||||||
ep_dotextension TYPE char10.
|
ep_dotextension TYPE char10.
|
||||||
|
|
||||||
|
|
||||||
* Test 1. Basic conversion
|
* Test 1. Basic conversion
|
||||||
|
@ -959,130 +928,284 @@ CLASS lcl_excel_common_test IMPLEMENTATION.
|
||||||
|
|
||||||
ENDMETHOD. "describe_structure
|
ENDMETHOD. "describe_structure
|
||||||
|
|
||||||
|
METHOD macro_calculate_cell_distance.
|
||||||
|
|
||||||
|
DATA: lv_offset_rows TYPE i,
|
||||||
|
lv_offset_cols TYPE i,
|
||||||
|
lv_message TYPE string.
|
||||||
|
|
||||||
|
zcl_excel_common=>calculate_cell_distance( EXPORTING iv_reference_cell = iv_reference_cell
|
||||||
|
iv_current_cell = iv_current_cell
|
||||||
|
IMPORTING ev_row_difference = lv_offset_rows
|
||||||
|
ev_col_difference = lv_offset_cols ).
|
||||||
|
* Check delta columns
|
||||||
|
CONCATENATE 'Error calculating column difference in test:'
|
||||||
|
iv_reference_cell
|
||||||
|
'->'
|
||||||
|
iv_current_cell
|
||||||
|
INTO lv_message SEPARATED BY space.
|
||||||
|
cl_abap_unit_assert=>assert_equals( act = lv_offset_cols
|
||||||
|
exp = iv_expected_column
|
||||||
|
msg = lv_message
|
||||||
|
quit = 0 " continue tests
|
||||||
|
level = if_aunit_constants=>critical ).
|
||||||
|
* Check delta rows
|
||||||
|
CONCATENATE 'Error calculating row difference in test:'
|
||||||
|
iv_reference_cell
|
||||||
|
'->'
|
||||||
|
iv_current_cell
|
||||||
|
INTO lv_message SEPARATED BY space.
|
||||||
|
cl_abap_unit_assert=>assert_equals( act = lv_offset_rows
|
||||||
|
exp = iv_expected_row
|
||||||
|
msg = lv_message
|
||||||
|
quit = 0 " continue tests
|
||||||
|
level = if_aunit_constants=>critical ).
|
||||||
|
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
METHOD calculate_cell_distance.
|
METHOD calculate_cell_distance.
|
||||||
DATA: lv_offset_rows TYPE i,
|
|
||||||
lv_offset_cols TYPE i,
|
|
||||||
lv_message TYPE string.
|
|
||||||
|
|
||||||
DEFINE macro_calculate_cell_distance.
|
" Same cell
|
||||||
zcl_excel_common=>calculate_cell_distance( exporting iv_reference_cell = &1
|
macro_calculate_cell_distance(
|
||||||
iv_current_cell = &2
|
iv_reference_cell = 'C12'
|
||||||
importing ev_row_difference = lv_offset_rows
|
iv_current_cell = 'C12'
|
||||||
ev_col_difference = lv_offset_cols ).
|
iv_expected_column = 0
|
||||||
* Check delta columns
|
iv_expected_row = 0 ).
|
||||||
concatenate 'Error calculating column difference in test:'
|
|
||||||
&1
|
|
||||||
'->'
|
|
||||||
&2
|
|
||||||
into lv_message separated by space.
|
|
||||||
cl_abap_unit_assert=>assert_equals( act = lv_offset_cols
|
|
||||||
exp = &3
|
|
||||||
msg = lv_message
|
|
||||||
quit = 0 " continue tests
|
|
||||||
level = if_aunit_constants=>critical ).
|
|
||||||
* Check delta rows
|
|
||||||
concatenate 'Error calculating row difference in test:'
|
|
||||||
&1
|
|
||||||
'->'
|
|
||||||
&2
|
|
||||||
into lv_message separated by space.
|
|
||||||
cl_abap_unit_assert=>assert_equals( act = lv_offset_rows
|
|
||||||
exp = &4
|
|
||||||
msg = lv_message
|
|
||||||
quit = 0 " continue tests
|
|
||||||
level = if_aunit_constants=>critical ).
|
|
||||||
END-OF-DEFINITION.
|
|
||||||
|
|
||||||
|
" Shift down 1 place
|
||||||
|
macro_calculate_cell_distance(
|
||||||
|
iv_reference_cell = 'C12'
|
||||||
|
iv_current_cell = 'C13'
|
||||||
|
iv_expected_column = 0
|
||||||
|
iv_expected_row = 1 ).
|
||||||
|
|
||||||
macro_calculate_cell_distance:
|
" Shift down some places
|
||||||
'C12' 'C12' 0 0 , " Same cell
|
macro_calculate_cell_distance(
|
||||||
'C12' 'C13' 0 1 , " Shift down 1 place
|
iv_reference_cell = 'C12'
|
||||||
'C12' 'C25' 0 13 , " Shift down some places
|
iv_current_cell = 'C25'
|
||||||
'C12' 'C11' 0 -1 , " Shift up 1 place
|
iv_expected_column = 0
|
||||||
'C12' 'C1' 0 -11 , " Shift up some place
|
iv_expected_row = 13 ).
|
||||||
'C12' 'D12' 1 0 , " Shift right 1 place
|
|
||||||
'C12' 'AA12' 24 0 , " Shift right some places
|
|
||||||
'C12' 'B12' -1 0 , " Shift left 1 place
|
|
||||||
'AA12' 'C12' -24 0 , " Shift left some place
|
|
||||||
'AA121' 'C12' -24 -109 . " The full package.
|
|
||||||
|
|
||||||
ENDMETHOD. "CALCULATE_CELL_DISTANCE
|
" Shift up 1 place
|
||||||
|
macro_calculate_cell_distance(
|
||||||
|
iv_reference_cell = 'C12'
|
||||||
|
iv_current_cell = 'C11'
|
||||||
|
iv_expected_column = 0
|
||||||
|
iv_expected_row = -1 ).
|
||||||
|
|
||||||
|
" Shift up some place
|
||||||
|
macro_calculate_cell_distance(
|
||||||
|
iv_reference_cell = 'C12'
|
||||||
|
iv_current_cell = 'C1'
|
||||||
|
iv_expected_column = 0
|
||||||
|
iv_expected_row = -11 ).
|
||||||
|
|
||||||
|
" Shift right 1 place
|
||||||
|
macro_calculate_cell_distance(
|
||||||
|
iv_reference_cell = 'C12'
|
||||||
|
iv_current_cell = 'D12'
|
||||||
|
iv_expected_column = 1
|
||||||
|
iv_expected_row = 0 ).
|
||||||
|
|
||||||
|
" Shift right some places
|
||||||
|
macro_calculate_cell_distance(
|
||||||
|
iv_reference_cell = 'C12'
|
||||||
|
iv_current_cell = 'AA12'
|
||||||
|
iv_expected_column = 24
|
||||||
|
iv_expected_row = 0 ).
|
||||||
|
|
||||||
|
" Shift left 1 place
|
||||||
|
macro_calculate_cell_distance(
|
||||||
|
iv_reference_cell = 'C12'
|
||||||
|
iv_current_cell = 'B12'
|
||||||
|
iv_expected_column = -1
|
||||||
|
iv_expected_row = 0 ).
|
||||||
|
|
||||||
|
" Shift left some place
|
||||||
|
macro_calculate_cell_distance(
|
||||||
|
iv_reference_cell = 'AA12'
|
||||||
|
iv_current_cell = 'C12'
|
||||||
|
iv_expected_column = -24
|
||||||
|
iv_expected_row = 0 ).
|
||||||
|
|
||||||
|
" The full package.
|
||||||
|
macro_calculate_cell_distance(
|
||||||
|
iv_reference_cell = 'AA121'
|
||||||
|
iv_current_cell = 'C12'
|
||||||
|
iv_expected_column = -24
|
||||||
|
iv_expected_row = -109 ).
|
||||||
|
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD macro_shift_formula.
|
||||||
|
|
||||||
|
DATA: lv_resulting_formula TYPE string,
|
||||||
|
lv_message TYPE string,
|
||||||
|
lv_counter TYPE num8.
|
||||||
|
|
||||||
|
ADD 1 TO lv_counter.
|
||||||
|
CLEAR lv_resulting_formula.
|
||||||
|
TRY.
|
||||||
|
lv_resulting_formula = zcl_excel_common=>shift_formula( iv_reference_formula = iv_reference_formula
|
||||||
|
iv_shift_cols = iv_shift_cols
|
||||||
|
iv_shift_rows = iv_shift_rows ).
|
||||||
|
CONCATENATE 'Wrong result in test'
|
||||||
|
lv_counter
|
||||||
|
'shifting formula '
|
||||||
|
iv_reference_formula
|
||||||
|
INTO lv_message SEPARATED BY space.
|
||||||
|
cl_abap_unit_assert=>assert_equals( act = lv_resulting_formula
|
||||||
|
exp = iv_expected
|
||||||
|
msg = lv_message
|
||||||
|
quit = 0 " continue tests
|
||||||
|
level = if_aunit_constants=>critical ).
|
||||||
|
CATCH zcx_excel.
|
||||||
|
CONCATENATE 'Unexpected exception occurred in test'
|
||||||
|
lv_counter
|
||||||
|
'shifting formula '
|
||||||
|
iv_reference_formula
|
||||||
|
INTO lv_message SEPARATED BY space.
|
||||||
|
cl_abap_unit_assert=>assert_equals( act = lv_resulting_formula
|
||||||
|
exp = iv_expected
|
||||||
|
msg = lv_message
|
||||||
|
quit = 0 " continue tests
|
||||||
|
level = if_aunit_constants=>critical ).
|
||||||
|
ENDTRY.
|
||||||
|
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
METHOD shift_formula.
|
METHOD shift_formula.
|
||||||
DATA: lv_resulting_formula TYPE string,
|
|
||||||
lv_message TYPE string,
|
|
||||||
lv_counter TYPE num8.
|
|
||||||
|
|
||||||
DEFINE macro_shift_formula.
|
" Very basic check
|
||||||
add 1 to lv_counter.
|
macro_shift_formula(
|
||||||
clear lv_resulting_formula.
|
iv_reference_formula = 'C17'
|
||||||
try.
|
iv_shift_cols = 0
|
||||||
lv_resulting_formula = zcl_excel_common=>shift_formula( iv_reference_formula = &1
|
iv_shift_rows = 0
|
||||||
iv_shift_cols = &2
|
iv_expected = 'C17' ).
|
||||||
iv_shift_rows = &3 ).
|
|
||||||
concatenate 'Wrong result in test'
|
|
||||||
lv_counter
|
|
||||||
'shifting formula '
|
|
||||||
&1
|
|
||||||
into lv_message separated by space.
|
|
||||||
cl_abap_unit_assert=>assert_equals( act = lv_resulting_formula
|
|
||||||
exp = &4
|
|
||||||
msg = lv_message
|
|
||||||
quit = 0 " continue tests
|
|
||||||
level = if_aunit_constants=>critical ).
|
|
||||||
catch zcx_excel.
|
|
||||||
concatenate 'Unexpected exception occurred in test'
|
|
||||||
lv_counter
|
|
||||||
'shifting formula '
|
|
||||||
&1
|
|
||||||
into lv_message separated by space.
|
|
||||||
cl_abap_unit_assert=>assert_equals( act = lv_resulting_formula
|
|
||||||
exp = &4
|
|
||||||
msg = lv_message
|
|
||||||
quit = 0 " continue tests
|
|
||||||
level = if_aunit_constants=>critical ).
|
|
||||||
endtry.
|
|
||||||
END-OF-DEFINITION.
|
|
||||||
|
|
||||||
* Test shifts that should result in a valid output
|
" Check shift right and down
|
||||||
macro_shift_formula:
|
macro_shift_formula(
|
||||||
'C17' 0 0 'C17', " Very basic check
|
iv_reference_formula = 'C17'
|
||||||
'C17' 2 3 'E20', " Check shift right and down
|
iv_shift_cols = 2
|
||||||
'C17' -2 -3 'A14', " Check shift left and up
|
iv_shift_rows = 3
|
||||||
'$C$17' 1 1 '$C$17', " Fixed columns/rows
|
iv_expected = 'E20' ).
|
||||||
'SUM($C17:C$23)+C30' 1 11 'SUM($C28:D$23)+D41', " Operators and Ranges, mixed fixed rows or columns
|
|
||||||
'RNGNAME1+C7' -1 -4 'RNGNAME1+B3', " Operators and Rangename
|
" Check shift left and up
|
||||||
'"Date:"&TEXT(B2)' 1 1 '"Date:"&TEXT(C3)', " String literals and string concatenation
|
macro_shift_formula(
|
||||||
'[TEST6.XLSX]SHEET1!A1' 1 11 '[TEST6.XLSX]SHEET1!B12', " External sheet reference
|
iv_reference_formula = 'C17'
|
||||||
`X(B13, "KK" ) ` 1 1 `X(C14,"KK")`, " superflous blanks, multi-argument functions, literals in function, unknown functions
|
iv_shift_cols = -2
|
||||||
* 'SIN((((((B2))))))' 1 1 'SIN((((((C3))))))', " Deep nesting
|
iv_shift_rows = -3
|
||||||
* 'SIN(SIN(SIN(SIN(E22))))' 0 1 'SIN(SIN(SIN(SIN(E23))))', " Different type of deep nesting
|
iv_expected = 'A14' ).
|
||||||
`SIN(SIN(SIN(SIN(E22))))` 0 1 'SIN(SIN(SIN(SIN(E23))))', " same as above - but with string input instead of Char-input
|
|
||||||
'HEUTE()' 2 5 'HEUTE()', " Functions w/o arguments, No cellreferences
|
" Fixed columns/rows
|
||||||
'"B2"' 2 5 '"B2"', " No cellreferences
|
macro_shift_formula(
|
||||||
'' 2 5 '', " Empty
|
iv_reference_formula = '$C$17'
|
||||||
'A1+$A1+A$1+$A$1+B2' -1 0 '#REF!+$A1+#REF!+$A$1+A2', " Referencing error , column only , underflow
|
iv_shift_cols = 1
|
||||||
'A1+$A1+A$1+$A$1+B2' 0 -1 '#REF!+#REF!+A$1+$A$1+B1', " Referencing error , row only , underflow
|
iv_shift_rows = 1
|
||||||
'A1+$A1+A$1+$A$1+B2' -1 -1 '#REF!+#REF!+#REF!+$A$1+A1'. " Referencing error , row and column , underflow
|
iv_expected = '$C$17' ).
|
||||||
ENDMETHOD. "SHIFT_FORMULA
|
|
||||||
|
" Operators and Ranges, mixed fixed rows or columns
|
||||||
|
macro_shift_formula(
|
||||||
|
iv_reference_formula = 'SUM($C17:C$23)+C30'
|
||||||
|
iv_shift_cols = 1
|
||||||
|
iv_shift_rows = 11
|
||||||
|
iv_expected = 'SUM($C28:D$23)+D41' ).
|
||||||
|
|
||||||
|
" Operators and Rangename
|
||||||
|
macro_shift_formula(
|
||||||
|
iv_reference_formula = 'RNGNAME1+C7'
|
||||||
|
iv_shift_cols = -1
|
||||||
|
iv_shift_rows = -4
|
||||||
|
iv_expected = 'RNGNAME1+B3' ).
|
||||||
|
|
||||||
|
" String literals and string concatenation
|
||||||
|
macro_shift_formula(
|
||||||
|
iv_reference_formula = '"Date:"&TEXT(B2)'
|
||||||
|
iv_shift_cols = 1
|
||||||
|
iv_shift_rows = 1
|
||||||
|
iv_expected = '"Date:"&TEXT(C3)' ).
|
||||||
|
|
||||||
|
" External sheet reference
|
||||||
|
macro_shift_formula(
|
||||||
|
iv_reference_formula = '[TEST6.XLSX]SHEET1!A1'
|
||||||
|
iv_shift_cols = 1
|
||||||
|
iv_shift_rows = 11
|
||||||
|
iv_expected = '[TEST6.XLSX]SHEET1!B12' ).
|
||||||
|
|
||||||
|
" superflous blanks, multi-argument functions, literals in function, unknown functions
|
||||||
|
macro_shift_formula(
|
||||||
|
iv_reference_formula = `X(B13, "KK" ) `
|
||||||
|
iv_shift_cols = 1
|
||||||
|
iv_shift_rows = 1
|
||||||
|
iv_expected = `X(C14,"KK")` ).
|
||||||
|
|
||||||
|
" same as above - but with string input instead of Char-input
|
||||||
|
macro_shift_formula(
|
||||||
|
iv_reference_formula = `SIN(SIN(SIN(SIN(E22))))`
|
||||||
|
iv_shift_cols = 0
|
||||||
|
iv_shift_rows = 1
|
||||||
|
iv_expected = 'SIN(SIN(SIN(SIN(E23))))' ).
|
||||||
|
|
||||||
|
" Functions w/o arguments, No cellreferences
|
||||||
|
macro_shift_formula(
|
||||||
|
iv_reference_formula = 'HEUTE()'
|
||||||
|
iv_shift_cols = 2
|
||||||
|
iv_shift_rows = 5
|
||||||
|
iv_expected = 'HEUTE()' ).
|
||||||
|
|
||||||
|
" No cellreferences
|
||||||
|
macro_shift_formula(
|
||||||
|
iv_reference_formula = '"B2"'
|
||||||
|
iv_shift_cols = 2
|
||||||
|
iv_shift_rows = 5
|
||||||
|
iv_expected = '"B2"' ).
|
||||||
|
|
||||||
|
" Empty
|
||||||
|
macro_shift_formula(
|
||||||
|
iv_reference_formula = ''
|
||||||
|
iv_shift_cols = 2
|
||||||
|
iv_shift_rows = 5
|
||||||
|
iv_expected = '' ).
|
||||||
|
|
||||||
|
" Referencing error , column only , underflow
|
||||||
|
macro_shift_formula(
|
||||||
|
iv_reference_formula = 'A1+$A1+A$1+$A$1+B2'
|
||||||
|
iv_shift_cols = -1
|
||||||
|
iv_shift_rows = 0
|
||||||
|
iv_expected = '#REF!+$A1+#REF!+$A$1+A2' ).
|
||||||
|
|
||||||
|
" Referencing error , row only , underflow
|
||||||
|
macro_shift_formula(
|
||||||
|
iv_reference_formula = 'A1+$A1+A$1+$A$1+B2'
|
||||||
|
iv_shift_cols = 0
|
||||||
|
iv_shift_rows = -1
|
||||||
|
iv_expected = '#REF!+#REF!+A$1+$A$1+B1' ).
|
||||||
|
|
||||||
|
" Referencing error , row and column , underflow
|
||||||
|
macro_shift_formula(
|
||||||
|
iv_reference_formula = 'A1+$A1+A$1+$A$1+B2'
|
||||||
|
iv_shift_cols = -1
|
||||||
|
iv_shift_rows = -1
|
||||||
|
iv_expected = '#REF!+#REF!+#REF!+$A$1+A1' ).
|
||||||
|
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
METHOD is_cell_in_range.
|
METHOD is_cell_in_range.
|
||||||
DATA ep_cell_in_range TYPE abap_bool.
|
DATA ep_cell_in_range TYPE abap_bool.
|
||||||
|
|
||||||
* Test 1: upper left corner (in range)
|
* Test 1: upper left corner (in range)
|
||||||
TRY.
|
TRY.
|
||||||
ep_cell_in_range = zcl_excel_common=>is_cell_in_range(
|
ep_cell_in_range = zcl_excel_common=>is_cell_in_range(
|
||||||
ip_column = 'B'
|
ip_column = 'B'
|
||||||
ip_row = 2
|
ip_row = 2
|
||||||
ip_range = 'B2:D4' ).
|
ip_range = 'B2:D4' ).
|
||||||
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
cl_abap_unit_assert=>assert_equals(
|
||||||
act = ep_cell_in_range
|
act = ep_cell_in_range
|
||||||
exp = abap_true
|
exp = abap_true
|
||||||
msg = 'Check cell in range failed'
|
msg = 'Check cell in range failed'
|
||||||
level = if_aunit_constants=>critical ).
|
level = if_aunit_constants=>critical ).
|
||||||
CATCH zcx_excel.
|
CATCH zcx_excel.
|
||||||
cl_abap_unit_assert=>fail(
|
cl_abap_unit_assert=>fail(
|
||||||
msg = 'Unexpected exception'
|
msg = 'Unexpected exception'
|
||||||
level = if_aunit_constants=>critical ).
|
level = if_aunit_constants=>critical ).
|
||||||
|
@ -1090,17 +1213,17 @@ CLASS lcl_excel_common_test IMPLEMENTATION.
|
||||||
|
|
||||||
* Test 2: lower right corner (in range)
|
* Test 2: lower right corner (in range)
|
||||||
TRY.
|
TRY.
|
||||||
ep_cell_in_range = zcl_excel_common=>is_cell_in_range(
|
ep_cell_in_range = zcl_excel_common=>is_cell_in_range(
|
||||||
ip_column = 'D'
|
ip_column = 'D'
|
||||||
ip_row = 4
|
ip_row = 4
|
||||||
ip_range = 'B2:D4' ).
|
ip_range = 'B2:D4' ).
|
||||||
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
cl_abap_unit_assert=>assert_equals(
|
||||||
act = ep_cell_in_range
|
act = ep_cell_in_range
|
||||||
exp = abap_true
|
exp = abap_true
|
||||||
msg = 'Check cell in range failed'
|
msg = 'Check cell in range failed'
|
||||||
level = if_aunit_constants=>critical ).
|
level = if_aunit_constants=>critical ).
|
||||||
CATCH zcx_excel.
|
CATCH zcx_excel.
|
||||||
cl_abap_unit_assert=>fail(
|
cl_abap_unit_assert=>fail(
|
||||||
msg = 'Unexpected exception'
|
msg = 'Unexpected exception'
|
||||||
level = if_aunit_constants=>critical ).
|
level = if_aunit_constants=>critical ).
|
||||||
|
@ -1108,17 +1231,17 @@ CLASS lcl_excel_common_test IMPLEMENTATION.
|
||||||
|
|
||||||
* Test 3: left side (out of range)
|
* Test 3: left side (out of range)
|
||||||
TRY.
|
TRY.
|
||||||
ep_cell_in_range = zcl_excel_common=>is_cell_in_range(
|
ep_cell_in_range = zcl_excel_common=>is_cell_in_range(
|
||||||
ip_column = 'A'
|
ip_column = 'A'
|
||||||
ip_row = 3
|
ip_row = 3
|
||||||
ip_range = 'B2:D4' ).
|
ip_range = 'B2:D4' ).
|
||||||
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
cl_abap_unit_assert=>assert_equals(
|
||||||
act = ep_cell_in_range
|
act = ep_cell_in_range
|
||||||
exp = abap_false
|
exp = abap_false
|
||||||
msg = 'Check cell in range failed'
|
msg = 'Check cell in range failed'
|
||||||
level = if_aunit_constants=>critical ).
|
level = if_aunit_constants=>critical ).
|
||||||
CATCH zcx_excel.
|
CATCH zcx_excel.
|
||||||
cl_abap_unit_assert=>fail(
|
cl_abap_unit_assert=>fail(
|
||||||
msg = 'Unexpected exception'
|
msg = 'Unexpected exception'
|
||||||
level = if_aunit_constants=>critical ).
|
level = if_aunit_constants=>critical ).
|
||||||
|
@ -1126,17 +1249,17 @@ CLASS lcl_excel_common_test IMPLEMENTATION.
|
||||||
|
|
||||||
* Test 4: upper side (out of range)
|
* Test 4: upper side (out of range)
|
||||||
TRY.
|
TRY.
|
||||||
ep_cell_in_range = zcl_excel_common=>is_cell_in_range(
|
ep_cell_in_range = zcl_excel_common=>is_cell_in_range(
|
||||||
ip_column = 'C'
|
ip_column = 'C'
|
||||||
ip_row = 1
|
ip_row = 1
|
||||||
ip_range = 'B2:D4' ).
|
ip_range = 'B2:D4' ).
|
||||||
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
cl_abap_unit_assert=>assert_equals(
|
||||||
act = ep_cell_in_range
|
act = ep_cell_in_range
|
||||||
exp = abap_false
|
exp = abap_false
|
||||||
msg = 'Check cell in range failed'
|
msg = 'Check cell in range failed'
|
||||||
level = if_aunit_constants=>critical ).
|
level = if_aunit_constants=>critical ).
|
||||||
CATCH zcx_excel.
|
CATCH zcx_excel.
|
||||||
cl_abap_unit_assert=>fail(
|
cl_abap_unit_assert=>fail(
|
||||||
msg = 'Unexpected exception'
|
msg = 'Unexpected exception'
|
||||||
level = if_aunit_constants=>critical ).
|
level = if_aunit_constants=>critical ).
|
||||||
|
@ -1144,17 +1267,17 @@ CLASS lcl_excel_common_test IMPLEMENTATION.
|
||||||
|
|
||||||
* Test 5: right side (out of range)
|
* Test 5: right side (out of range)
|
||||||
TRY.
|
TRY.
|
||||||
ep_cell_in_range = zcl_excel_common=>is_cell_in_range(
|
ep_cell_in_range = zcl_excel_common=>is_cell_in_range(
|
||||||
ip_column = 'E'
|
ip_column = 'E'
|
||||||
ip_row = 3
|
ip_row = 3
|
||||||
ip_range = 'B2:D4' ).
|
ip_range = 'B2:D4' ).
|
||||||
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
cl_abap_unit_assert=>assert_equals(
|
||||||
act = ep_cell_in_range
|
act = ep_cell_in_range
|
||||||
exp = abap_false
|
exp = abap_false
|
||||||
msg = 'Check cell in range failed'
|
msg = 'Check cell in range failed'
|
||||||
level = if_aunit_constants=>critical ).
|
level = if_aunit_constants=>critical ).
|
||||||
CATCH zcx_excel.
|
CATCH zcx_excel.
|
||||||
cl_abap_unit_assert=>fail(
|
cl_abap_unit_assert=>fail(
|
||||||
msg = 'Unexpected exception'
|
msg = 'Unexpected exception'
|
||||||
level = if_aunit_constants=>critical ).
|
level = if_aunit_constants=>critical ).
|
||||||
|
@ -1162,21 +1285,21 @@ CLASS lcl_excel_common_test IMPLEMENTATION.
|
||||||
|
|
||||||
* Test 6: lower side (out of range)
|
* Test 6: lower side (out of range)
|
||||||
TRY.
|
TRY.
|
||||||
ep_cell_in_range = zcl_excel_common=>is_cell_in_range(
|
ep_cell_in_range = zcl_excel_common=>is_cell_in_range(
|
||||||
ip_column = 'C'
|
ip_column = 'C'
|
||||||
ip_row = 5
|
ip_row = 5
|
||||||
ip_range = 'B2:D4' ).
|
ip_range = 'B2:D4' ).
|
||||||
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
cl_abap_unit_assert=>assert_equals(
|
||||||
act = ep_cell_in_range
|
act = ep_cell_in_range
|
||||||
exp = abap_false
|
exp = abap_false
|
||||||
msg = 'Check cell in range failed'
|
msg = 'Check cell in range failed'
|
||||||
level = if_aunit_constants=>critical ).
|
level = if_aunit_constants=>critical ).
|
||||||
CATCH zcx_excel.
|
CATCH zcx_excel.
|
||||||
cl_abap_unit_assert=>fail(
|
cl_abap_unit_assert=>fail(
|
||||||
msg = 'Unexpected exception'
|
msg = 'Unexpected exception'
|
||||||
level = if_aunit_constants=>critical ).
|
level = if_aunit_constants=>critical ).
|
||||||
ENDTRY.
|
ENDTRY.
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
ENDCLASS. "lcl_Excel_Common_Test
|
ENDCLASS.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user