Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

json, add testcase #818

Merged
merged 3 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/json/#ui2#cl_json.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ CLASS /ui2/cl_json IMPLEMENTATION.
ENDLOOP.
lo_struct = cl_abap_structdescr=>create( lt_components ).
CREATE DATA data TYPE HANDLE lo_struct.
ELSEIF lines( lt_members ) > 0 AND lv_type = 'array'.
ELSEIF lv_type = 'array'.
lo_table = cl_abap_tabledescr=>create( cl_abap_refdescr=>get_ref_to_data( ) ).
CREATE DATA data TYPE HANDLE lo_table.
ELSE.
Expand Down
30 changes: 30 additions & 0 deletions src/json/#ui2#cl_json.clas.testclasses.abap
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ CLASS ltcl_deserialize DEFINITION FOR TESTING RISK LEVEL HARMLESS DURATION SHORT
METHODS more_array FOR TESTING RAISING cx_static_check.
METHODS deserialize_float_to_ref FOR TESTING RAISING cx_static_check.
METHODS deserialize_packed_empty FOR TESTING RAISING cx_static_check.
METHODS refs_something FOR TESTING RAISING cx_static_check.

ENDCLASS.

Expand Down Expand Up @@ -593,6 +594,35 @@ CLASS ltcl_deserialize IMPLEMENTATION.

ENDMETHOD.

METHOD refs_something.

DATA lv_json TYPE string.
DATA lr_data TYPE REF TO data.

FIELD-SYMBOLS <any> TYPE any.
FIELD-SYMBOLS <table> TYPE ANY TABLE.


lv_json = `{"oScroll": []}`.

/ui2/cl_json=>deserialize(
EXPORTING
json = lv_json
CHANGING
data = lr_data ).

cl_abap_unit_assert=>assert_not_initial( lr_data ).
ASSIGN lr_data->* TO <any>.
cl_abap_unit_assert=>assert_subrc( ).
ASSIGN COMPONENT 'OSCROLL' OF STRUCTURE <any> TO <any>.
cl_abap_unit_assert=>assert_subrc( ).
ASSIGN <any>->* TO <table>.
cl_abap_unit_assert=>assert_equals(
exp = 0
act = lines( <table> ) ).

ENDMETHOD.

ENDCLASS.

*****************************************************************************************
Expand Down