From 39c1ad1b08877ef642b75af3aef4d0cdad76c891 Mon Sep 17 00:00:00 2001 From: AtomKrieg Date: Sat, 29 Dec 2018 15:41:49 +0300 Subject: [PATCH] extract unit test methods from zcl_excel_common (#568) It is necessary to isolate the functionality for unit tests to another class according to the SRP principle. --- src/zcl_excel_aunit.clas.abap | 120 ++++++++++ src/zcl_excel_aunit.clas.xml | 18 ++ src/zcl_excel_common.clas.abap | 153 ------------- src/zcl_excel_common.clas.testclasses.abap | 210 +++++++++--------- src/zcl_excel_common.clas.xml | 36 --- src/zcl_excel_worksheet.clas.testclasses.abap | 32 +-- 6 files changed, 259 insertions(+), 310 deletions(-) create mode 100644 src/zcl_excel_aunit.clas.abap create mode 100644 src/zcl_excel_aunit.clas.xml diff --git a/src/zcl_excel_aunit.clas.abap b/src/zcl_excel_aunit.clas.abap new file mode 100644 index 0000000..d407775 --- /dev/null +++ b/src/zcl_excel_aunit.clas.abap @@ -0,0 +1,120 @@ +class zcl_excel_aunit definition + public + final + create private. + + public section. + + class-methods class_constructor. + + class-methods assert_differs + importing + !exp type simple + !act type simple + !msg type csequence optional + !level type aunit_level default if_aunit_constants=>critical + !tol type f optional + !quit type aunit_flowctrl default if_aunit_constants=>method + returning + value(assertion_failed) type abap_bool. + + class-methods assert_equals + importing + !exp type any + !act type any + !msg type csequence optional + !level type aunit_level default if_aunit_constants=>critical + !tol type f optional + !quit type aunit_flowctrl default if_aunit_constants=>method + !ignore_hash_sequence type abap_bool default abap_false + returning + value(assertion_failed) type abap_bool. + + class-methods fail + importing + msg type csequence optional + level type aunit_level default if_aunit_constants=>critical + quit type aunit_flowctrl default if_aunit_constants=>method + detail type csequence optional. + + protected section. + private section. + types tv_clsname type seoclass-clsname. + + constants: + begin of en_clsname, + new type tv_clsname value 'CL_ABAP_UNIT_ASSERT', + old type tv_clsname value 'CL_AUNIT_ASSERT', + none type tv_clsname value '', + end of en_clsname. + + class-data clsname type tv_clsname. +endclass. + + + +class zcl_excel_aunit implementation. + + method class_constructor. + " Let see >=7.02 + select single clsname into clsname + from seoclass + where clsname = en_clsname-new. + + check sy-subrc <> 0. + + " Let see >=7.00 or even lower + select single clsname into clsname + from seoclass + where clsname = en_clsname-old. + + check sy-subrc <> 0. + + " We do nothing for now not supported + + endmethod. + + method assert_differs. + check clsname = en_clsname-new or clsname = en_clsname-old. + + call method (clsname)=>assert_differs + exporting + exp = exp + act = act + msg = msg + level = level + tol = tol + quit = quit + receiving + assertion_failed = assertion_failed. + + endmethod. + + method assert_equals. + check clsname = en_clsname-new or clsname = en_clsname-old. + + call method (clsname)=>assert_equals + exporting + exp = exp + act = act + msg = msg + level = level + tol = tol + quit = quit + ignore_hash_sequence = ignore_hash_sequence + receiving + assertion_failed = assertion_failed. + endmethod. + + method fail. + check clsname = en_clsname-new or clsname = en_clsname-old. + + call method (clsname)=>fail + exporting + msg = msg + level = level + quit = quit + detail = detail. + + endmethod. +endclass. diff --git a/src/zcl_excel_aunit.clas.xml b/src/zcl_excel_aunit.clas.xml new file mode 100644 index 0000000..51bd902 --- /dev/null +++ b/src/zcl_excel_aunit.clas.xml @@ -0,0 +1,18 @@ + + + + + + ZCL_EXCEL_AUNIT + 1 + E + Unit test helper + 1 + X + X + X + X + + + + diff --git a/src/zcl_excel_common.clas.abap b/src/zcl_excel_common.clas.abap index 0d97c4e..ff2be66 100644 --- a/src/zcl_excel_common.clas.abap +++ b/src/zcl_excel_common.clas.abap @@ -126,33 +126,6 @@ public section. returning value(EP_VALUE) type ZEXCEL_CELL_VALUE . type-pools ABAP . - class-methods ASSERT_EQUALS - importing - !EXP type ANY - !ACT type ANY - !MSG type CSEQUENCE optional - !LEVEL type AUNIT_LEVEL default IF_AUNIT_CONSTANTS=>CRITICAL - !TOL type F optional - !QUIT type AUNIT_FLOWCTRL default IF_AUNIT_CONSTANTS=>METHOD - !IGNORE_HASH_SEQUENCE type ABAP_BOOL default ABAP_FALSE - returning - value(ASSERTION_FAILED) type ABAP_BOOL . - class-methods FAIL - importing - !MSG type CSEQUENCE optional - !LEVEL type AUNIT_LEVEL default IF_AUNIT_CONSTANTS=>CRITICAL - !QUIT type AUNIT_FLOWCTRL default IF_AUNIT_CONSTANTS=>METHOD - !DETAIL type CSEQUENCE optional . - class-methods ASSERT_DIFFERS - importing - !EXP type SIMPLE - !ACT type SIMPLE - !MSG type CSEQUENCE optional - !LEVEL type AUNIT_LEVEL default IF_AUNIT_CONSTANTS=>CRITICAL - !TOL type F optional - !QUIT type AUNIT_FLOWCTRL default IF_AUNIT_CONSTANTS=>METHOD - returning - value(ASSERTION_FAILED) type ABAP_BOOL . class-methods SPLIT_FILE importing !IP_FILE type TEXT255 @@ -236,95 +209,6 @@ ENDCLASS. CLASS ZCL_EXCEL_COMMON IMPLEMENTATION. - -method ASSERT_DIFFERS. - DATA: ls_seoclass TYPE seoclass. - -" Let see >=7.02 - SELECT SINGLE * INTO ls_seoclass - FROM seoclass - WHERE clsname = 'CL_ABAP_UNIT_ASSERT'. - - IF sy-subrc = 0. - CALL METHOD (ls_seoclass-clsname)=>assert_differs - EXPORTING - exp = exp - act = act - msg = msg - level = level - tol = tol - quit = quit - RECEIVING - assertion_failed = assertion_failed. - ELSE. -" Let see >=7.00 or even lower - SELECT SINGLE * INTO ls_seoclass - FROM seoclass - WHERE clsname = 'CL_AUNIT_ASSERT'. - - IF sy-subrc = 0. - CALL METHOD (ls_seoclass-clsname)=>assert_differs - EXPORTING - exp = exp - act = act - msg = msg - level = level - tol = tol - quit = quit - RECEIVING - assertion_failed = assertion_failed. - ELSE. -* We do nothing for now not supported - ENDIF. - ENDIF. -endmethod. - - -METHOD assert_equals. - DATA: ls_seoclass TYPE seoclass. - - " Let see >=7.02 - SELECT SINGLE * INTO ls_seoclass - FROM seoclass - WHERE clsname = 'CL_ABAP_UNIT_ASSERT'. - - IF sy-subrc = 0. - CALL METHOD (ls_seoclass-clsname)=>assert_equals - EXPORTING - exp = exp - act = act - msg = msg - level = level - tol = tol - quit = quit - ignore_hash_sequence = ignore_hash_sequence - RECEIVING - assertion_failed = assertion_failed. - ELSE. - " Let see >=7.00 or even lower - SELECT SINGLE * INTO ls_seoclass - FROM seoclass - WHERE clsname = 'CL_AUNIT_ASSERT'. - - IF sy-subrc = 0. - CALL METHOD (ls_seoclass-clsname)=>assert_equals - EXPORTING - exp = exp - act = act - msg = msg - level = level - tol = tol - quit = quit - ignore_hash_sequence = ignore_hash_sequence - RECEIVING - assertion_failed = assertion_failed. - ELSE. -* We do nothing for now not supported - ENDIF. - ENDIF. -ENDMETHOD. - - METHOD calculate_cell_distance. DATA: lv_reference_row TYPE i, @@ -916,43 +800,6 @@ method EXCEL_STRING_TO_TIME. ENDTRY. endmethod. - -method FAIL. - DATA: ls_seoclass TYPE seoclass. - - " Let see >=7.02 - SELECT SINGLE * INTO ls_seoclass - FROM seoclass - WHERE clsname = 'CL_ABAP_UNIT_ASSERT'. - - IF sy-subrc = 0. - CALL METHOD (ls_seoclass-clsname)=>fail - EXPORTING - msg = msg - level = level - quit = quit - detail = detail. - ELSE. - " Let see >=7.00 or even lower - SELECT SINGLE * INTO ls_seoclass - FROM seoclass - WHERE clsname = 'CL_AUNIT_ASSERT'. - - IF sy-subrc = 0. - CALL METHOD (ls_seoclass-clsname)=>fail - EXPORTING - msg = msg - level = level - quit = quit - detail = detail. - ELSE. -* We do nothing for now not supported - ENDIF. - ENDIF. - -endmethod. - - METHOD get_fieldcatalog. DATA: lr_dref_tab TYPE REF TO data, lo_salv_table TYPE REF TO cl_salv_table, diff --git a/src/zcl_excel_common.clas.testclasses.abap b/src/zcl_excel_common.clas.testclasses.abap index 2aef200..68554da 100644 --- a/src/zcl_excel_common.clas.testclasses.abap +++ b/src/zcl_excel_common.clas.testclasses.abap @@ -103,14 +103,14 @@ CLASS lcl_excel_common_test IMPLEMENTATION. TRY. ep_column = zcl_excel_common=>convert_column2alpha( 1 ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = ep_column exp = 'A' msg = 'Wrong column conversion' level = if_aunit_constants=>critical ). CATCH zcx_excel INTO lx_excel. - zcl_excel_common=>fail( + zcl_excel_aunit=>fail( msg = 'unexpected exception' level = if_aunit_constants=>critical " Error Severity ). @@ -120,14 +120,14 @@ CLASS lcl_excel_common_test IMPLEMENTATION. TRY. ep_column = zcl_excel_common=>convert_column2alpha( 16384 ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = ep_column exp = 'XFD' msg = 'Wrong column conversion' level = if_aunit_constants=>critical ). CATCH zcx_excel INTO lx_excel. - zcl_excel_common=>fail( + zcl_excel_aunit=>fail( msg = 'unexpected exception' level = if_aunit_constants=>critical " Error Severity ). @@ -137,12 +137,12 @@ CLASS lcl_excel_common_test IMPLEMENTATION. TRY. ep_column = zcl_excel_common=>convert_column2alpha( 0 ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = ep_column exp = 'A' ). CATCH zcx_excel INTO lx_excel. - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = lx_excel->error exp = 'Index out of bounds' msg = 'Colum index 0 is out of bounds, min column index is 1' @@ -154,14 +154,14 @@ CLASS lcl_excel_common_test IMPLEMENTATION. TRY. ep_column = zcl_excel_common=>convert_column2alpha( 16385 ). - zcl_excel_common=>assert_differs( + zcl_excel_aunit=>assert_differs( act = ep_column exp = 'XFE' msg = 'Colum index 16385 is out of bounds, max column index is 16384' level = if_aunit_constants=>fatal ). CATCH zcx_excel INTO lx_excel. - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = lx_excel->error exp = 'Index out of bounds' msg = 'Wrong exception is thrown' @@ -179,14 +179,14 @@ CLASS lcl_excel_common_test IMPLEMENTATION. TRY. ep_column = zcl_excel_common=>convert_column2int( 'A' ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = ep_column exp = 1 msg = 'Wrong column conversion' level = if_aunit_constants=>critical ). CATCH zcx_excel INTO lx_excel. - zcl_excel_common=>fail( + zcl_excel_aunit=>fail( msg = 'unexpected exception' level = if_aunit_constants=>critical " Error Severity ). @@ -196,14 +196,14 @@ CLASS lcl_excel_common_test IMPLEMENTATION. TRY. ep_column = zcl_excel_common=>convert_column2int( 'XFD' ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = ep_column exp = 16384 msg = 'Wrong column conversion' level = if_aunit_constants=>critical ). CATCH zcx_excel INTO lx_excel. - zcl_excel_common=>fail( + zcl_excel_aunit=>fail( msg = 'unexpected exception' level = if_aunit_constants=>critical " Error Severity ). @@ -213,7 +213,7 @@ CLASS lcl_excel_common_test IMPLEMENTATION. TRY. ep_column = zcl_excel_common=>convert_column2int( '' ). - zcl_excel_common=>assert_differs( act = ep_column + zcl_excel_aunit=>assert_differs( act = ep_column exp = '0' msg = 'Wrong column conversion' level = if_aunit_constants=>critical ). @@ -224,7 +224,7 @@ CLASS lcl_excel_common_test IMPLEMENTATION. ls_symsg_exp-msgno = '800'. ls_symsg_act-msgid = lx_excel->syst_at_raise-msgid. ls_symsg_act-msgno = lx_excel->syst_at_raise-msgno. - zcl_excel_common=>assert_equals( act = ls_symsg_act + zcl_excel_aunit=>assert_equals( act = ls_symsg_act exp = ls_symsg_exp msg = 'Colum name should be a valid string' level = if_aunit_constants=>fatal ). @@ -234,12 +234,12 @@ CLASS lcl_excel_common_test IMPLEMENTATION. TRY. ep_column = zcl_excel_common=>convert_column2int( 'XFE' ). - zcl_excel_common=>assert_differs( act = ep_column + zcl_excel_aunit=>assert_differs( act = ep_column exp = 16385 msg = 'Wrong column conversion' level = if_aunit_constants=>critical ). CATCH zcx_excel INTO lx_excel. - zcl_excel_common=>assert_equals( act = lx_excel->error + zcl_excel_aunit=>assert_equals( act = lx_excel->error exp = 'Index out of bounds' msg = 'Colum XFE is out of range' level = if_aunit_constants=>fatal ). @@ -255,14 +255,14 @@ CLASS lcl_excel_common_test IMPLEMENTATION. TRY. ep_value = zcl_excel_common=>date_to_excel_string( '19000101' ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = ep_value exp = 1 msg = 'Wrong date conversion' level = if_aunit_constants=>critical ). CATCH zcx_excel INTO lx_excel. - zcl_excel_common=>fail( + zcl_excel_aunit=>fail( msg = 'unexpected exception' level = if_aunit_constants=>critical " Error Severity ). @@ -271,14 +271,14 @@ CLASS lcl_excel_common_test IMPLEMENTATION. TRY. ep_value = zcl_excel_common=>date_to_excel_string( '19000228' ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = ep_value exp = 59 msg = 'Wrong date conversion' level = if_aunit_constants=>critical ). CATCH zcx_excel INTO lx_excel. - zcl_excel_common=>fail( + zcl_excel_aunit=>fail( msg = 'unexpected exception' level = if_aunit_constants=>critical " Error Severity ). @@ -286,14 +286,14 @@ CLASS lcl_excel_common_test IMPLEMENTATION. TRY. ep_value = zcl_excel_common=>date_to_excel_string( '19000301' ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = ep_value exp = 61 msg = 'Wrong date conversion' level = if_aunit_constants=>critical ). CATCH zcx_excel INTO lx_excel. - zcl_excel_common=>fail( + zcl_excel_aunit=>fail( msg = 'unexpected exception' level = if_aunit_constants=>critical " Error Severity ). @@ -304,14 +304,14 @@ CLASS lcl_excel_common_test IMPLEMENTATION. TRY. ep_value = zcl_excel_common=>date_to_excel_string( '99991212' ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = ep_value exp = 2958446 msg = 'Wrong date conversion' level = if_aunit_constants=>critical ). CATCH zcx_excel INTO lx_excel. - zcl_excel_common=>fail( + zcl_excel_aunit=>fail( msg = 'unexpected exception' level = if_aunit_constants=>critical " Error Severity ). @@ -322,14 +322,14 @@ CLASS lcl_excel_common_test IMPLEMENTATION. DATA: lv_date TYPE d. ep_value = zcl_excel_common=>date_to_excel_string( lv_date ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = ep_value exp = '' msg = 'Wrong date conversion' level = if_aunit_constants=>critical ). CATCH zcx_excel INTO lx_excel. - zcl_excel_common=>fail( + zcl_excel_aunit=>fail( msg = 'unexpected exception' level = if_aunit_constants=>critical " Error Severity ). @@ -340,14 +340,14 @@ CLASS lcl_excel_common_test IMPLEMENTATION. DATA exp_value TYPE zexcel_cell_value VALUE 0. ep_value = zcl_excel_common=>date_to_excel_string( '18991231' ). - zcl_excel_common=>assert_differs( + zcl_excel_aunit=>assert_differs( act = ep_value exp = exp_value msg = 'Wrong date conversion' level = if_aunit_constants=>critical ). CATCH zcx_excel INTO lx_excel. - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = lx_excel->error exp = 'Index out of bounds' msg = 'Dates prior of 1900 are not available in excel' @@ -365,14 +365,14 @@ CLASS lcl_excel_common_test IMPLEMENTATION. TRY. lv_encrypted_pwd = zcl_excel_common=>encrypt_password( 'test' ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = lv_encrypted_pwd exp = 'CBEB' msg = 'Wrong password encryption' level = if_aunit_constants=>critical ). CATCH zcx_excel INTO lx_excel. - zcl_excel_common=>fail( + zcl_excel_aunit=>fail( msg = 'unexpected exception' level = if_aunit_constants=>critical " Error Severity ). @@ -389,14 +389,14 @@ CLASS lcl_excel_common_test IMPLEMENTATION. TRY. ep_value = zcl_excel_common=>excel_string_to_date( '0' ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = ep_value exp = '18991231' msg = 'Wrong date conversion' level = if_aunit_constants=>tolerable ). CATCH zcx_excel INTO lx_excel. - zcl_excel_common=>fail( + zcl_excel_aunit=>fail( msg = 'unexpected exception' level = if_aunit_constants=>critical " Error Severity ). @@ -405,14 +405,14 @@ CLASS lcl_excel_common_test IMPLEMENTATION. TRY. ep_value = zcl_excel_common=>excel_string_to_date( '59' ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = ep_value exp = '19000228' msg = 'Wrong date conversion' level = if_aunit_constants=>critical ). CATCH zcx_excel INTO lx_excel. - zcl_excel_common=>fail( + zcl_excel_aunit=>fail( msg = 'unexpected exception' level = if_aunit_constants=>critical " Error Severity ). @@ -420,14 +420,14 @@ CLASS lcl_excel_common_test IMPLEMENTATION. TRY. ep_value = zcl_excel_common=>excel_string_to_date( '61' ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = ep_value exp = '19000301' msg = 'Wrong date conversion' level = if_aunit_constants=>critical ). CATCH zcx_excel INTO lx_excel. - zcl_excel_common=>fail( + zcl_excel_aunit=>fail( msg = 'unexpected exception' level = if_aunit_constants=>critical " Error Severity ). @@ -437,14 +437,14 @@ CLASS lcl_excel_common_test IMPLEMENTATION. TRY. ep_value = zcl_excel_common=>excel_string_to_date( '1' ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = ep_value exp = '19000101' msg = 'Wrong date conversion' level = if_aunit_constants=>critical ). CATCH zcx_excel INTO lx_excel. - zcl_excel_common=>fail( + zcl_excel_aunit=>fail( msg = 'unexpected exception' level = if_aunit_constants=>critical " Error Severity ). @@ -454,14 +454,14 @@ CLASS lcl_excel_common_test IMPLEMENTATION. TRY. ep_value = zcl_excel_common=>excel_string_to_date( '2958446' ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = ep_value exp = '99991212' msg = 'Wrong date conversion' level = if_aunit_constants=>critical ). CATCH zcx_excel INTO lx_excel. - zcl_excel_common=>fail( + zcl_excel_aunit=>fail( msg = 'unexpected exception' level = if_aunit_constants=>critical " Error Severity ). @@ -471,14 +471,14 @@ CLASS lcl_excel_common_test IMPLEMENTATION. TRY. ep_value = zcl_excel_common=>excel_string_to_date( '2958447' ). - zcl_excel_common=>assert_differs( + zcl_excel_aunit=>assert_differs( act = ep_value exp = '99991212' msg = 'Wrong date conversion' level = if_aunit_constants=>fatal ). - zcl_excel_common=>assert_differs( + zcl_excel_aunit=>assert_differs( act = ep_value exp = '00000000' msg = 'Wrong date conversion' @@ -486,7 +486,7 @@ CLASS lcl_excel_common_test IMPLEMENTATION. ). CATCH zcx_excel INTO lx_excel. - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = lx_excel->error exp = 'Index out of bounds' msg = 'Wrong exception is thrown' @@ -504,14 +504,14 @@ CLASS lcl_excel_common_test IMPLEMENTATION. TRY. ep_value = zcl_excel_common=>excel_string_to_time( '0' ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = ep_value exp = '000000' msg = 'Wrong date conversion' level = if_aunit_constants=>tolerable ). CATCH zcx_excel INTO lx_excel. - zcl_excel_common=>fail( + zcl_excel_aunit=>fail( msg = 'unexpected exception' level = if_aunit_constants=>critical " Error Severity ). @@ -521,14 +521,14 @@ CLASS lcl_excel_common_test IMPLEMENTATION. TRY. ep_value = zcl_excel_common=>excel_string_to_time( '1' ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = ep_value exp = '000000' msg = 'Wrong date conversion' level = if_aunit_constants=>critical ). CATCH zcx_excel INTO lx_excel. - zcl_excel_common=>fail( + zcl_excel_aunit=>fail( msg = 'unexpected exception' level = if_aunit_constants=>critical " Error Severity ). @@ -538,14 +538,14 @@ CLASS lcl_excel_common_test IMPLEMENTATION. TRY. ep_value = zcl_excel_common=>excel_string_to_time( '0.99999' ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = ep_value exp = '235959' msg = 'Wrong date conversion' level = if_aunit_constants=>critical ). CATCH zcx_excel INTO lx_excel. - zcl_excel_common=>fail( + zcl_excel_aunit=>fail( msg = 'unexpected exception' level = if_aunit_constants=>critical " Error Severity ). @@ -555,14 +555,14 @@ CLASS lcl_excel_common_test IMPLEMENTATION. TRY. ep_value = zcl_excel_common=>excel_string_to_time( '4.1' ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = ep_value exp = '022400' msg = 'Wrong date conversion' level = if_aunit_constants=>critical ). CATCH zcx_excel INTO lx_excel. - zcl_excel_common=>fail( + zcl_excel_aunit=>fail( msg = 'unexpected exception' level = if_aunit_constants=>critical " Error Severity ). @@ -572,14 +572,14 @@ CLASS lcl_excel_common_test IMPLEMENTATION. TRY. ep_value = zcl_excel_common=>excel_string_to_time( 'NaN' ). - zcl_excel_common=>assert_differs( + zcl_excel_aunit=>assert_differs( act = ep_value exp = '000000' msg = 'Wrong date conversion' level = if_aunit_constants=>critical ). CATCH zcx_excel INTO lx_excel. - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = lx_excel->error exp = 'Unable to interpret time' msg = 'Time should be a valid string' @@ -597,14 +597,14 @@ CLASS lcl_excel_common_test IMPLEMENTATION. TRY. ep_value = zcl_excel_common=>time_to_excel_string( '000001' ). " A test directly in Excel returns the value 0.0000115740740740741000 - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = ep_value exp = '0.0000115740740741' msg = 'Wrong date conversion' level = if_aunit_constants=>critical ). CATCH zcx_excel INTO lx_excel. - zcl_excel_common=>fail( + zcl_excel_aunit=>fail( msg = 'unexpected exception' level = if_aunit_constants=>critical " Error Severity ). @@ -614,14 +614,14 @@ CLASS lcl_excel_common_test IMPLEMENTATION. TRY. ep_value = zcl_excel_common=>time_to_excel_string( '235959' ). " A test directly in Excel returns the value 0.9999884259259260000000 - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = ep_value exp = '0.9999884259259260' msg = 'Wrong date conversion' level = if_aunit_constants=>critical ). CATCH zcx_excel INTO lx_excel. - zcl_excel_common=>fail( + zcl_excel_aunit=>fail( msg = 'unexpected exception' level = if_aunit_constants=>critical " Error Severity ). @@ -631,14 +631,14 @@ CLASS lcl_excel_common_test IMPLEMENTATION. TRY. ep_value = zcl_excel_common=>time_to_excel_string( '000000' ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = ep_value exp = '0' msg = 'Wrong date conversion' level = if_aunit_constants=>critical ). CATCH zcx_excel INTO lx_excel. - zcl_excel_common=>fail( + zcl_excel_aunit=>fail( msg = 'unexpected exception' level = if_aunit_constants=>critical " Error Severity ). @@ -648,14 +648,14 @@ CLASS lcl_excel_common_test IMPLEMENTATION. TRY. ep_value = zcl_excel_common=>time_to_excel_string( '022400' ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = ep_value exp = '0.1000000000000000' msg = 'Wrong date conversion' level = if_aunit_constants=>critical ). CATCH zcx_excel INTO lx_excel. - zcl_excel_common=>fail( + zcl_excel_aunit=>fail( msg = 'unexpected exception' level = if_aunit_constants=>critical " Error Severity ). @@ -677,19 +677,19 @@ CLASS lcl_excel_common_test IMPLEMENTATION. ep_extension = ep_extension ep_dotextension = ep_dotextension ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = ep_file exp = 'filename' msg = 'Split filename failed' level = if_aunit_constants=>critical ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = ep_extension exp = 'xml' msg = 'Split extension failed' level = if_aunit_constants=>critical ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = ep_dotextension exp = '.xml' msg = 'Split extension failed' @@ -701,19 +701,19 @@ CLASS lcl_excel_common_test IMPLEMENTATION. ep_extension = ep_extension ep_dotextension = ep_dotextension ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = ep_file exp = 'filename' msg = 'Split filename failed' level = if_aunit_constants=>critical ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = ep_extension exp = '' msg = 'Split extension failed' level = if_aunit_constants=>critical ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = ep_dotextension exp = '' msg = 'Split extension failed' @@ -741,27 +741,27 @@ CLASS lcl_excel_common_test IMPLEMENTATION. e_sheet = lv_sheet " Title ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = lv_column_start exp = '' msg = 'Conversion of range failed' level = if_aunit_constants=>critical ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = lv_column_end exp = '' msg = 'Conversion of range failed' level = if_aunit_constants=>critical ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = lv_row_start exp = '' msg = 'Conversion of range failed' level = if_aunit_constants=>critical ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = lv_row_end exp = '' msg = 'Conversion of range failed' level = if_aunit_constants=>critical ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = lv_sheet exp = '' msg = 'Conversion of range failed' @@ -779,27 +779,27 @@ CLASS lcl_excel_common_test IMPLEMENTATION. e_sheet = lv_sheet " Title ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = lv_column_start exp = 'B' msg = 'Conversion of range failed' level = if_aunit_constants=>critical ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = lv_column_end exp = 'D' msg = 'Conversion of range failed' level = if_aunit_constants=>critical ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = lv_row_start exp = '6' msg = 'Conversion of range failed' level = if_aunit_constants=>critical ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = lv_row_end exp = '13' msg = 'Conversion of range failed' level = if_aunit_constants=>critical ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = lv_sheet exp = 'Sheet 1' msg = 'Conversion of range failed' @@ -817,27 +817,27 @@ CLASS lcl_excel_common_test IMPLEMENTATION. e_sheet = lv_sheet " Title ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = lv_column_start exp = 'B' msg = 'Conversion of range failed' level = if_aunit_constants=>critical ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = lv_column_end exp = 'D' msg = 'Conversion of range failed' level = if_aunit_constants=>critical ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = lv_row_start exp = '6' msg = 'Conversion of range failed' level = if_aunit_constants=>critical ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = lv_row_end exp = '13' msg = 'Conversion of range failed' level = if_aunit_constants=>critical ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = lv_sheet exp = 'Sheet1' msg = 'Conversion of range failed' @@ -855,27 +855,27 @@ CLASS lcl_excel_common_test IMPLEMENTATION. e_sheet = lv_sheet " Title ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = lv_column_start exp = 'B' msg = 'Conversion of range failed' level = if_aunit_constants=>critical ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = lv_column_end exp = 'D' msg = 'Conversion of range failed' level = if_aunit_constants=>critical ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = lv_row_start exp = '6' msg = 'Conversion of range failed' level = if_aunit_constants=>critical ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = lv_row_end exp = '13' msg = 'Conversion of range failed' level = if_aunit_constants=>critical ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = lv_sheet exp = '' msg = 'Conversion of range failed' @@ -893,7 +893,7 @@ CLASS lcl_excel_common_test IMPLEMENTATION. lo_structdescr ?= cl_abap_structdescr=>describe_by_data( p_data = ls_test ). lt_structure = zcl_excel_common=>describe_structure( io_struct = lo_structdescr ). READ TABLE lt_structure ASSIGNING INDEX 1. - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = -fieldname exp = 'MANDT' msg = 'Describe structure failed' @@ -911,7 +911,7 @@ CLASS lcl_excel_common_test IMPLEMENTATION. lo_structdescr ?= cl_abap_structdescr=>describe_by_data( p_data = ls_ttest ). lt_structure = zcl_excel_common=>describe_structure( io_struct = lo_structdescr ). READ TABLE lt_structure ASSIGNING INDEX 1. - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = -fieldname exp = 'CARRID' msg = 'Describe structure failed' @@ -936,7 +936,7 @@ CLASS lcl_excel_common_test IMPLEMENTATION. '->' &2 into lv_message separated by space. - zcl_excel_common=>assert_equals( act = lv_offset_cols + zcl_excel_aunit=>assert_equals( act = lv_offset_cols exp = &3 msg = lv_message quit = 0 " continue tests @@ -947,7 +947,7 @@ CLASS lcl_excel_common_test IMPLEMENTATION. '->' &2 into lv_message separated by space. - zcl_excel_common=>assert_equals( act = lv_offset_rows + zcl_excel_aunit=>assert_equals( act = lv_offset_rows exp = &4 msg = lv_message quit = 0 " continue tests @@ -986,7 +986,7 @@ CLASS lcl_excel_common_test IMPLEMENTATION. 'shifting formula ' &1 into lv_message separated by space. - zcl_excel_common=>assert_equals( act = lv_resulting_formula + zcl_excel_aunit=>assert_equals( act = lv_resulting_formula exp = &4 msg = lv_message quit = 0 " continue tests @@ -997,7 +997,7 @@ CLASS lcl_excel_common_test IMPLEMENTATION. 'shifting formula ' &1 into lv_message separated by space. - zcl_excel_common=>assert_equals( act = lv_resulting_formula + zcl_excel_aunit=>assert_equals( act = lv_resulting_formula exp = &4 msg = lv_message quit = 0 " continue tests @@ -1037,13 +1037,13 @@ CLASS lcl_excel_common_test IMPLEMENTATION. ip_row = 2 ip_range = 'B2:D4' ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = ep_cell_in_range exp = abap_true msg = 'Check cell in range failed' level = if_aunit_constants=>critical ). CATCH zcx_excel. - zcl_excel_common=>fail( + zcl_excel_aunit=>fail( msg = 'Unexpected exception' level = if_aunit_constants=>critical ). ENDTRY. @@ -1055,13 +1055,13 @@ CLASS lcl_excel_common_test IMPLEMENTATION. ip_row = 4 ip_range = 'B2:D4' ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = ep_cell_in_range exp = abap_true msg = 'Check cell in range failed' level = if_aunit_constants=>critical ). CATCH zcx_excel. - zcl_excel_common=>fail( + zcl_excel_aunit=>fail( msg = 'Unexpected exception' level = if_aunit_constants=>critical ). ENDTRY. @@ -1073,13 +1073,13 @@ CLASS lcl_excel_common_test IMPLEMENTATION. ip_row = 3 ip_range = 'B2:D4' ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = ep_cell_in_range exp = abap_false msg = 'Check cell in range failed' level = if_aunit_constants=>critical ). CATCH zcx_excel. - zcl_excel_common=>fail( + zcl_excel_aunit=>fail( msg = 'Unexpected exception' level = if_aunit_constants=>critical ). ENDTRY. @@ -1091,13 +1091,13 @@ CLASS lcl_excel_common_test IMPLEMENTATION. ip_row = 1 ip_range = 'B2:D4' ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = ep_cell_in_range exp = abap_false msg = 'Check cell in range failed' level = if_aunit_constants=>critical ). CATCH zcx_excel. - zcl_excel_common=>fail( + zcl_excel_aunit=>fail( msg = 'Unexpected exception' level = if_aunit_constants=>critical ). ENDTRY. @@ -1109,13 +1109,13 @@ CLASS lcl_excel_common_test IMPLEMENTATION. ip_row = 3 ip_range = 'B2:D4' ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = ep_cell_in_range exp = abap_false msg = 'Check cell in range failed' level = if_aunit_constants=>critical ). CATCH zcx_excel. - zcl_excel_common=>fail( + zcl_excel_aunit=>fail( msg = 'Unexpected exception' level = if_aunit_constants=>critical ). ENDTRY. @@ -1127,13 +1127,13 @@ CLASS lcl_excel_common_test IMPLEMENTATION. ip_row = 5 ip_range = 'B2:D4' ). - zcl_excel_common=>assert_equals( + zcl_excel_aunit=>assert_equals( act = ep_cell_in_range exp = abap_false msg = 'Check cell in range failed' level = if_aunit_constants=>critical ). CATCH zcx_excel. - zcl_excel_common=>fail( + zcl_excel_aunit=>fail( msg = 'Unexpected exception' level = if_aunit_constants=>critical ). ENDTRY. diff --git a/src/zcl_excel_common.clas.xml b/src/zcl_excel_common.clas.xml index 4bdf70e..444714b 100644 --- a/src/zcl_excel_common.clas.xml +++ b/src/zcl_excel_common.clas.xml @@ -48,30 +48,6 @@ - - ZCL_EXCEL_COMMON - ASSERT_DIFFERS - E - Ensure Difference Between 2 (Elementary) data Objects - - - ZCL_EXCEL_COMMON - ASSERT_DIFFERS - I - Ensure Difference Between 2 (Elementary) data Objects - - - ZCL_EXCEL_COMMON - ASSERT_EQUALS - E - Ensure Equality of Two Data Objects - - - ZCL_EXCEL_COMMON - ASSERT_EQUALS - I - Ensure Equality of Two Data Objects - ZCL_EXCEL_COMMON CALCULATE_CELL_DISTANCE @@ -348,18 +324,6 @@ I Convert time from Excel format to SAP - - ZCL_EXCEL_COMMON - FAIL - E - Report Unconditional Error - - - ZCL_EXCEL_COMMON - FAIL - I - Report Unconditional Error - ZCL_EXCEL_COMMON GET_FIELDCATALOG diff --git a/src/zcl_excel_worksheet.clas.testclasses.abap b/src/zcl_excel_worksheet.clas.testclasses.abap index 355cc02..e1efea2 100644 --- a/src/zcl_excel_worksheet.clas.testclasses.abap +++ b/src/zcl_excel_worksheet.clas.testclasses.abap @@ -88,7 +88,7 @@ CLASS LCL_EXCEL_WORKSHEET_TEST IMPLEMENTATION. LT_MERGE = F_CUT->GET_MERGE( ). LV_SIZE = LINES( LT_MERGE ). - ZCL_EXCEL_COMMON=>ASSERT_EQUALS( + ZCL_EXCEL_AUNIT=>ASSERT_EQUALS( ACT = LV_SIZE EXP = 0 MSG = 'Initial state of merge table is not empty' @@ -108,7 +108,7 @@ CLASS LCL_EXCEL_WORKSHEET_TEST IMPLEMENTATION. LT_MERGE = F_CUT->GET_MERGE( ). LV_SIZE_NEXT = LINES( LT_MERGE ). - ZCL_EXCEL_COMMON=>ASSERT_EQUALS( + ZCL_EXCEL_AUNIT=>ASSERT_EQUALS( ACT = LV_SIZE_NEXT - LV_SIZE EXP = 1 MSG = 'Expect add 1 table line when 1 merge added' @@ -132,7 +132,7 @@ CLASS LCL_EXCEL_WORKSHEET_TEST IMPLEMENTATION. LT_MERGE = F_CUT->GET_MERGE( ). LV_SIZE_NEXT = LINES( LT_MERGE ). - ZCL_EXCEL_COMMON=>ASSERT_EQUALS( + ZCL_EXCEL_AUNIT=>ASSERT_EQUALS( ACT = LV_SIZE_NEXT - LV_SIZE EXP = 0 MSG = 'Expect no change when add same merge' @@ -153,7 +153,7 @@ CLASS LCL_EXCEL_WORKSHEET_TEST IMPLEMENTATION. LT_MERGE = F_CUT->GET_MERGE( ). LV_SIZE_NEXT = LINES( LT_MERGE ). - ZCL_EXCEL_COMMON=>ASSERT_EQUALS( + ZCL_EXCEL_AUNIT=>ASSERT_EQUALS( ACT = LV_SIZE_NEXT - LV_SIZE EXP = 1 MSG = 'Expect 1 change when add different merge' @@ -174,7 +174,7 @@ CLASS LCL_EXCEL_WORKSHEET_TEST IMPLEMENTATION. LT_MERGE = F_CUT->GET_MERGE( ). READ TABLE LT_MERGE INTO LV_MERGE INDEX 1. - ZCL_EXCEL_COMMON=>ASSERT_EQUALS( + ZCL_EXCEL_AUNIT=>ASSERT_EQUALS( ACT = LV_MERGE EXP = 'B2:C3' MSG = 'Expect B2:C3' @@ -195,7 +195,7 @@ CLASS LCL_EXCEL_WORKSHEET_TEST IMPLEMENTATION. LT_MERGE = F_CUT->GET_MERGE( ). READ TABLE LT_MERGE INTO LV_MERGE INDEX 1. - ZCL_EXCEL_COMMON=>ASSERT_EQUALS( + ZCL_EXCEL_AUNIT=>ASSERT_EQUALS( ACT = LV_MERGE EXP = 'D4:E5' MSG = 'Expect D4:E5' @@ -224,7 +224,7 @@ CLASS LCL_EXCEL_WORKSHEET_TEST IMPLEMENTATION. LT_MERGE = F_CUT->GET_MERGE( ). LV_SIZE = LINES( LT_MERGE ). - ZCL_EXCEL_COMMON=>ASSERT_EQUALS( + ZCL_EXCEL_AUNIT=>ASSERT_EQUALS( ACT = LV_SIZE EXP = 0 MSG = 'Expect merge table with 1 line fully cleared' @@ -246,7 +246,7 @@ CLASS LCL_EXCEL_WORKSHEET_TEST IMPLEMENTATION. LT_MERGE = F_CUT->GET_MERGE( ). LV_SIZE = LINES( LT_MERGE ). - ZCL_EXCEL_COMMON=>ASSERT_EQUALS( + ZCL_EXCEL_AUNIT=>ASSERT_EQUALS( ACT = LV_SIZE EXP = 0 MSG = 'Expect merge table with few lines fully cleared' @@ -277,7 +277,7 @@ CLASS LCL_EXCEL_WORKSHEET_TEST IMPLEMENTATION. LT_MERGE = F_CUT->GET_MERGE( ). LV_SIZE = LINES( LT_MERGE ). - ZCL_EXCEL_COMMON=>ASSERT_EQUALS( + ZCL_EXCEL_AUNIT=>ASSERT_EQUALS( ACT = LV_SIZE EXP = 0 MSG = 'Expect merge table with 1 line fully cleared' @@ -309,7 +309,7 @@ CLASS LCL_EXCEL_WORKSHEET_TEST IMPLEMENTATION. LT_MERGE = F_CUT->GET_MERGE( ). LV_SIZE = LINES( LT_MERGE ). - ZCL_EXCEL_COMMON=>ASSERT_EQUALS( + ZCL_EXCEL_AUNIT=>ASSERT_EQUALS( ACT = LV_SIZE EXP = 1 MSG = 'Expect no merge were deleted' @@ -338,7 +338,7 @@ CLASS LCL_EXCEL_WORKSHEET_TEST IMPLEMENTATION. LT_MERGE = F_CUT->GET_MERGE( ). LV_SIZE = LINES( LT_MERGE ). - ZCL_EXCEL_COMMON=>ASSERT_EQUALS( + ZCL_EXCEL_AUNIT=>ASSERT_EQUALS( ACT = LV_SIZE EXP = 1 MSG = 'Expect we have the one merge' @@ -347,7 +347,7 @@ CLASS LCL_EXCEL_WORKSHEET_TEST IMPLEMENTATION. READ TABLE LT_MERGE INTO LV_MERGE INDEX 1. - ZCL_EXCEL_COMMON=>ASSERT_EQUALS( + ZCL_EXCEL_AUNIT=>ASSERT_EQUALS( ACT = LV_MERGE EXP = 'D4:E5' MSG = 'Expect delete B2:C3 merge' @@ -375,7 +375,7 @@ CLASS LCL_EXCEL_WORKSHEET_TEST IMPLEMENTATION. LT_MERGE = F_CUT->GET_MERGE( ). LV_SIZE = LINES( LT_MERGE ). - ZCL_EXCEL_COMMON=>ASSERT_EQUALS( + ZCL_EXCEL_AUNIT=>ASSERT_EQUALS( ACT = LV_SIZE EXP = 1 MSG = 'Expect we have the one merge' @@ -384,7 +384,7 @@ CLASS LCL_EXCEL_WORKSHEET_TEST IMPLEMENTATION. READ TABLE LT_MERGE INTO LV_MERGE INDEX 1. - ZCL_EXCEL_COMMON=>ASSERT_EQUALS( + ZCL_EXCEL_AUNIT=>ASSERT_EQUALS( ACT = LV_MERGE EXP = 'B2:C3' MSG = 'Expect delete D4:E5 merge' @@ -394,7 +394,7 @@ CLASS LCL_EXCEL_WORKSHEET_TEST IMPLEMENTATION. ENDMETHOD. "delete_Merge METHOD GET_DIMENSION_RANGE. - ZCL_EXCEL_COMMON=>ASSERT_EQUALS( + ZCL_EXCEL_AUNIT=>ASSERT_EQUALS( ACT = F_CUT->GET_DIMENSION_RANGE( ) EXP = 'A1' MSG = 'get_dimension_range inital value' @@ -413,7 +413,7 @@ CLASS LCL_EXCEL_WORKSHEET_TEST IMPLEMENTATION. IP_VALUE = 'Dummy' ). - ZCL_EXCEL_COMMON=>ASSERT_EQUALS( + ZCL_EXCEL_AUNIT=>ASSERT_EQUALS( ACT = F_CUT->GET_DIMENSION_RANGE( ) EXP = 'C2:F5' MSG = 'get_dimension_range'