-
Notifications
You must be signed in to change notification settings - Fork 0
Feat improve read tests #16
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
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances the unit test coverage for serial port read operations and refactors the maximum safe read size from a compile-time constant to a runtime-configurable parameter.
Key changes:
- Added tests for error handling in
readBytes,readUntil, and buffer overflow scenarios - Converted
kMaxSafeReadSizefrom a static constant to a configurable member variablemax_safe_read_size_ - Added getter/setter methods (
setMaxSafeReadSize/getMaxSafeReadSize) for the maximum safe read size
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| test/test_serial_pty.cpp | Added three new test cases: ReadBytesWithReadFail, ReadUntilWithNullBuffer, and ReadUntilWithOverflowBuffer to improve test coverage |
| src/serial.cpp | Replaced static constant kMaxSafeReadSize with configurable max_safe_read_size_ member variable and updated all references; also unified read function calls to use read_ |
| include/libserial/serial.hpp | Added public getter/setter methods for max safe read size, improved test helper documentation, and converted constant to member variable |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
include/libserial/serial.hpp
Outdated
| * in a single read operation to prevent excessive memory usage. | ||
| * | ||
| * @param size The desired maximum safe read size in bytes | ||
| * @throws SerialException if size cannot be set |
Copilot
AI
Oct 25, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The setMaxSafeReadSize function does not throw any exceptions or validate the size parameter. Either remove this @throws documentation or add appropriate validation and exception handling in the implementation.
include/libserial/serial.hpp
Outdated
| * | ||
| * Defines the maximum number of bytes that can be read | ||
| * in a single read operation to prevent excessive memory usage. | ||
| * default is 2048 bytes (2KB). |
Copilot
AI
Oct 25, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected capitalization of 'default' to 'Default'.
| * default is 2048 bytes (2KB). | |
| * Default is 2048 bytes (2KB). |
Summary
Changes
Details
How to test
Screenshots/Logs (optional)
Checklist
make cppcheck/make cpplint/make uncrustifyExample(s) tested (if touched)Risks and rollbacks