Skip to content

Conversation

@NestorDP
Copy link
Owner

Summary

  • Improve unit tests

Changes

  • API changes
  • Behavior changes
  • Docs updated
  • Tests added/updated

Details

  • Briefly list the key changes and files touched

How to test

  • Commands and steps to validate locally
  • Include any environment requirements (Linux only, kernel version, etc.)

Screenshots/Logs (optional)

  • Paste relevant output/logs if helpful

Checklist

  • Builds locally (Release + Debug)
  • All tests pass (if applicable)
  • Lint/format pass: make cppcheck / make cpplint / make uncrustify
  • Example(s) tested (if touched)
  • Documentation updated (README/docs)

Risks and rollbacks

  • Potential impact areas, and how to revert if needed

@codecov
Copy link

codecov bot commented Oct 25, 2025

Codecov Report

❌ Patch coverage is 97.95918% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
test/test_serial_pty.cpp 97.50% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@NestorDP NestorDP self-assigned this Oct 25, 2025
@NestorDP NestorDP requested a review from Copilot October 25, 2025 16:03
Copy link

Copilot AI left a 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 kMaxSafeReadSize from a static constant to a configurable member variable max_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.

* 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
Copy link

Copilot AI Oct 25, 2025

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.

Copilot uses AI. Check for mistakes.
*
* 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).
Copy link

Copilot AI Oct 25, 2025

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'.

Suggested change
* default is 2048 bytes (2KB).
* Default is 2048 bytes (2KB).

Copilot uses AI. Check for mistakes.
@NestorDP NestorDP merged commit a63505b into main Oct 25, 2025
3 of 4 checks passed
@NestorDP NestorDP deleted the feat-improve-read-tests branch October 25, 2025 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants