-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
Description
Both test-reader-parser.cpp and test-buffer-parser.cpp contain nearly identical test helper functions and data structures that should be refactored into a common/shared test utility module.
Duplicated Code
Shared Data Structures
Both files define:
CapturePositionsstructExpectedTokenstructExpectedEventstruct
Shared Helper Functions
Both files implement:
parse_and_validate()- validates parsed events against expected tokens and captures (with parser-specific differences)serialize_id_symbol_map()- serializes the id-to-symbol map (identical implementation)
Proposed Refactoring
- Create a common test utilities header/source file (e.g.,
tests/common/test-parser-helpers.hpp). - Move the shared data structures to the common utility.
- Extract the common validation logic from
parse_and_validate()into reusable helper functions. - Use templates or function overloading to handle parser-specific differences (BufferParser vs ReaderParser).
- Move
serialize_id_symbol_map()to the common utility.
Benefits
- Reduces code duplication
- Easier maintenance when validation logic needs to be updated
- Promotes consistency across test files
- Simplifies adding new parser test files in the future
References
Metadata
Metadata
Assignees
Labels
No labels