Skip to content

Commit

Permalink
minor tweaks to setx
Browse files Browse the repository at this point in the history
  • Loading branch information
sbcgua committed Jan 2, 2023
1 parent 2e25269 commit 1614d12
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/zcl_ajson.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,7 @@ CLASS ZCL_AJSON IMPLEMENTATION.
data lv_last type i.

if iv_param is initial.
ri_json = me.
return.
endif.

Expand All @@ -683,6 +684,7 @@ CLASS ZCL_AJSON IMPLEMENTATION.
condense lv_val.

if lv_val is initial.
ri_json = me.
return. " Hmm ? or empty string ? or null ?
endif.

Expand Down
18 changes: 14 additions & 4 deletions src/zcl_ajson.clas.testclasses.abap
Original file line number Diff line number Diff line change
Expand Up @@ -3124,13 +3124,23 @@ class ltcl_writer_test implementation.

cl_abap_unit_assert=>assert_equals(
act = zcl_ajson=>new( )->setx( '/:1' )->stringify( )
exp = '1' ). " Hmmm ?
exp = '1' ). " Because set( path = '/' ) would write root node

cl_abap_unit_assert=>assert_equals(
act = zcl_ajson=>new( )->setx( ':1' )->stringify( )
exp = '1' ). " Hmmm ?
exp = '1' ). " Because set( path = '' ) would write root node

" TODO some negative tests like "/a:", ""
* cl_abap_unit_assert=>assert_equals(
* act = zcl_ajson=>new( )->setx( '' )->stringify( )
* exp = '{}' ). " problem is that root node not set so it is not an object

* cl_abap_unit_assert=>assert_equals(
* act = zcl_ajson=>new( )->setx( '/a:' )->stringify( )
* exp = '{}' ). " should setx ignore empty values or set an empty string ? Or null ?

cl_abap_unit_assert=>assert_equals(
act = zcl_ajson=>new( )->setx( '/a:""' )->stringify( )
exp = '{"a":""}' ).

endmethod.

Expand All @@ -3142,7 +3152,7 @@ class ltcl_writer_test implementation.

cl_abap_unit_assert=>assert_equals(
act = zcl_ajson=>new( )->setx( '/a:00.123' )->stringify( )
exp = '{"a":"00.123"}' ). " hmmm
exp = '{"a":"00.123"}' ). " not a number

cl_abap_unit_assert=>assert_equals(
act = zcl_ajson=>new( )->setx( '/a:.123' )->stringify( )
Expand Down

0 comments on commit 1614d12

Please sign in to comment.