Skip to content

Commit

Permalink
Add test for quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
jonassobotta committed Aug 6, 2024
1 parent 5e8c362 commit e321a6a
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/zcl_aff_abap_doc_parser.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ CLASS zcl_aff_abap_doc_parser IMPLEMENTATION.

DATA(string_to_parse) = abap_doc_string.

FIND ALL OCCURRENCES OF PCRE `\$pattern[\s]*(:[\s]*)?'([^']*)'` IN string_to_parse RESULTS DATA(result_table).
FIND ALL OCCURRENCES OF PCRE `\$pattern[\s]*(:[\s]*)?'(\S*)'` IN string_to_parse RESULTS DATA(result_table).

IF lines( result_table ) = 0.
DATA(msg) = parser_log->get_message_text( msgno = 109 msgv1 = CONV #( abap_doc_annotation-pattern ) ).
Expand Down
10 changes: 10 additions & 0 deletions src/zcl_aff_test_types.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ CLASS zcl_aff_test_types DEFINITION
string_pattern TYPE string,
END OF string_pattern_escape_sequence.

TYPES:
"! <p class="shorttext">Structure With Pattern Annotation</p>
"! Structure with pattern annotation
BEGIN OF string_pattern_quotes,
"! <p class="shorttext">String with pattern</p>
"! description
"! $pattern '"\"''
string_pattern TYPE string,
END OF string_pattern_quotes.

TYPES:
"! in ST val(I()) only allow integers
"! $values {@link zcl_aff_test_types.data:co_enum}
Expand Down
29 changes: 28 additions & 1 deletion src/zcl_aff_writer_json_schema.clas.testclasses.abap
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,8 @@ CLASS ltcl_json_writer_abap_doc DEFINITION FINAL FOR TESTING
encoding_type_next_level FOR TESTING RAISING cx_static_check,
pattern_simple FOR TESTING RAISING cx_static_check,
pattern_complex FOR TESTING RAISING cx_static_check,
pattern_escape_sequence FOR TESTING RAISING cx_static_check.
pattern_escape_sequence FOR TESTING RAISING cx_static_check,
pattern_with_quotes FOR TESTING RAISING cx_static_check.

ENDCLASS.

Expand Down Expand Up @@ -2870,4 +2871,30 @@ CLASS ltcl_json_writer_abap_doc IMPLEMENTATION.
zcl_aff_tools_unit_test_helper=>assert_log_has_no_message( log = log message_severity_threshold = zif_aff_log=>c_message_type-info ).
ENDMETHOD.

METHOD pattern_with_quotes.
DATA(act_schema) = test_generator->generate_type( VALUE zcl_aff_test_types=>string_pattern_quotes( ) ).
DATA(exp_schema) = VALUE string_table(
( ` { ` )
( | "$comment": "This file is autogenerated, do not edit manually, see { zcl_aff_writer_json_schema=>c_link_to_repository } for more information.", | )
( | "$schema": "{ zcl_aff_writer_json_schema=>c_schema_specification }",| )
( | "$id": "{ schema_id }",| )
( ` "title": "Structure With Pattern Annotation", ` )
( ` "description": "Structure with pattern annotation", ` )
( ` "type": "object", ` )
( ` "properties": { ` )
( ` "stringPattern": { ` )
( ` "title": "String with pattern",` )
( ` "description": "description",` )
( ` "type": "string", ` )
( ` "pattern": "\"\\\"'" ` )
( ` } ` )
( ` }, ` )
( ` "additionalProperties": false ` )
( ` } ` )
( ) ).
zcl_aff_tools_unit_test_helper=>assert_equals_ignore_spaces( act_data = act_schema exp_data = exp_schema ).
log = cut->zif_aff_writer~get_log( ).
zcl_aff_tools_unit_test_helper=>assert_log_has_no_message( log = log message_severity_threshold = zif_aff_log=>c_message_type-info ).
ENDMETHOD.

ENDCLASS.

0 comments on commit e321a6a

Please sign in to comment.