simplify get_null() + git branch list: add unit test (#4886)

add unit test which parses the response from hex, ie. containing a real null value

simplify get_null() method, it only returns 1 character, but 2 characters are calculated
This commit is contained in:
Lars Hvam 2021-08-03 06:47:16 +02:00 committed by GitHub
parent 9d1e14a90d
commit 2bde0ce55a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 6 deletions

View File

@ -17,6 +17,7 @@ CLASS ltcl_parse DEFINITION FOR TESTING
parse_ok_without_first_lf FOR TESTING RAISING zcx_abapgit_exception,
parse_works FOR TESTING RAISING zcx_abapgit_exception,
captcha_response_is_caught FOR TESTING RAISING zcx_abapgit_exception,
parse_raw FOR TESTING RAISING cx_static_check,
use_refs_if_head_is_missing FOR TESTING RAISING cx_static_check.
DATA: mt_data TYPE STANDARD TABLE OF string WITH DEFAULT KEY.
@ -113,4 +114,47 @@ CLASS ltcl_parse IMPLEMENTATION.
ENDMETHOD.
METHOD parse_raw.
* this is a real as hex, which contains the null value
DATA lv_xstr TYPE xstring.
DATA lv_data TYPE string.
DATA lv_ref TYPE string.
lv_xstr = '303031652320736572766963653D6769742D7570'
&& '6C6F61642D7061636B0A30303030303135346639'
&& '6563323364366439333561613764633236656531'
&& '3431633762343666656564396434363835652048'
&& '454144006D756C74695F61636B207468696E2D70'
&& '61636B20736964652D62616E6420736964652D62'
&& '616E642D36346B206F66732D64656C7461207368'
&& '616C6C6F772064656570656E2D73696E63652064'
&& '656570656E2D6E6F742064656570656E2D72656C'
&& '6174697665206E6F2D70726F677265737320696E'
&& '636C7564652D746167206D756C74695F61636B5F'
&& '64657461696C656420616C6C6F772D7469702D73'
&& '6861312D696E2D77616E7420616C6C6F772D7265'
&& '61636861626C652D736861312D696E2D77616E74'
&& '206E6F2D646F6E652073796D7265663D48454144'
&& '3A726566732F68656164732F6D61696E2066696C'
&& '746572206F626A6563742D666F726D61743D7368'
&& '6131206167656E743D6769742F6769746875622D'
&& '673964323537636462383634300A303033646639'
&& '6563323364366439333561613764633236656531'
&& '3431633762343666656564396434363835652072'
&& '6566732F68656164732F6D61696E0A30303030'.
lv_data = zcl_abapgit_convert=>xstring_to_string_utf8( lv_xstr ).
zcl_abapgit_git_branch_list=>parse_branch_list(
EXPORTING
iv_data = lv_data
IMPORTING
ev_head_symref = lv_ref ).
cl_abap_unit_assert=>assert_char_cp(
act = lv_ref
exp = 'refs/heads/main' ).
ENDMETHOD.
ENDCLASS.

View File

@ -35,15 +35,11 @@ CLASS ZCL_ABAPGIT_GIT_UTILS IMPLEMENTATION.
METHOD get_null.
DATA: lv_x(4) TYPE x VALUE '00000000',
lv_z(2) TYPE c.
DATA: lv_x TYPE x LENGTH 2 VALUE '0000'.
FIELD-SYMBOLS <lv_y> TYPE c.
ASSIGN lv_x TO <lv_y> CASTING.
lv_z = <lv_y>.
rv_c = lv_z(1).
rv_c = <lv_y>.
ENDMETHOD.