Skip to content

Commit f4e5f98

Browse files
add unit tests for empty string/object (sbcgua#212)
* add unit tests for empty string/object * Update src/core/zcl_ajson.clas.testclasses.abap Co-authored-by: abaplint[bot] <24845621+abaplint[bot]@users.noreply.github.com> --------- Co-authored-by: abaplint[bot] <24845621+abaplint[bot]@users.noreply.github.com>
1 parent a77bc16 commit f4e5f98

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/core/zcl_ajson.clas.testclasses.abap

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ class ltcl_parser_test definition final
9595
methods special_characters_in_path for testing raising zcx_ajson_error.
9696
methods special_characters_in_value for testing raising zcx_ajson_error.
9797
methods unicode_characters for testing raising zcx_ajson_error.
98+
methods parse_empty_object for testing raising zcx_ajson_error.
99+
methods parse_empty_string for testing raising zcx_ajson_error.
98100

99101
endclass.
100102

@@ -632,6 +634,35 @@ class ltcl_parser_test implementation.
632634

633635
endmethod.
634636

637+
method parse_empty_object.
638+
639+
data lo_cut type ref to lcl_json_parser.
640+
data lt_act type zif_ajson_types=>ty_nodes_tt.
641+
642+
mo_nodes->add( ' | |object | | |0' ).
643+
644+
create object lo_cut.
645+
lt_act = lo_cut->parse( `{}` ).
646+
cl_abap_unit_assert=>assert_equals(
647+
act = lt_act
648+
exp = mo_nodes->mt_nodes ).
649+
650+
endmethod.
651+
652+
method parse_empty_string.
653+
654+
data lo_cut type ref to lcl_json_parser.
655+
656+
create object lo_cut.
657+
658+
try.
659+
lo_cut->parse( `` ).
660+
cl_abap_unit_assert=>fail( `empty string should raise an exception` ).
661+
catch zcx_ajson_error.
662+
endtry.
663+
664+
endmethod.
665+
635666
endclass.
636667

637668
**********************************************************************

0 commit comments

Comments
 (0)