Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds functional-test coverage and corresponding test interface/implementation methods for handling optional std::vector<uint8_t> parameters, aligning with the stated goal of fixing optional vector input handling in StubGen/COMRPC functional tests.
Changes:
- Added new COMRPC functional tests for optional vector output and in-place vector mutation.
- Extended
ITestOptionalswith new optional vector methods. - Implemented the new optional vector methods in
TestOptionalsImpl.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tests/FunctionalTests/comrpc/tests/TestOptionals.cpp | Adds functional tests for optional vector and inline optional vector processing. |
| tests/FunctionalTests/common/interfaces/ITestOptionals.h | Introduces interface methods for optional vector input/output and in-place processing. |
| tests/FunctionalTests/common/implementations/TestOptionalsImpl.cpp | Implements the new optional vector interface methods. |
Suppressed comments (2)
tests/FunctionalTests/comrpc/tests/TestOptionals.cpp:215
- This test calls ProcessOptionalVector(data) but the interface defines ProcessOptionalInlineVector for in-place updates. The loop also uses sizeof(input) where 'input' is not in scope, so this will not compile.
ASSERT_EQ(_proxy->ProcessOptionalVector(data), Core::ERROR_NONE);
for (uint8_t i = 0; i < sizeof(input); i++) {
EXPECT_EQ(data[i], copy[i]*2);
tests/FunctionalTests/common/implementations/TestOptionalsImpl.cpp:139
- ProcessOptionalInlineVector uses an unqualified OptionalType and calls begin()/end() directly on the optional wrapper. To match the rest of the file and avoid compilation issues, it should use Core::OptionalType and operate on data.Value() only when the optional is set.
Core::hresult ProcessOptionalInlineVector(
OptionalType<std::vector<uint8_t>>& data) override
{
std::for_each(data.begin(), data.end(), [](int &num) {
num *= 2;
});
return Core::ERROR_NONE;
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
Suppressed comments (2)
tests/FunctionalTests/comrpc/tests/TestOptionals.cpp:231
- Same issue here:
uint8_tas an index can wrap for vectors larger than 255 elements. Usesize_t(orauto) for the index.
for (uint8_t i = 0; i < copy.size(); i++) {
tests/FunctionalTests/comrpc/tests/TestOptionals.cpp:210
- The loop counter is
uint8_tbut you compare it toinput.size()(size_t). If the test vector grows beyond 255 elements,iwill wrap and the loop can become incorrect or infinite. Usesize_t(orauto) for the index and pre-increment.
This issue also appears on line 231 of the same file.
for (uint8_t i = 0; i < input.size(); i++) {
LuaGenerator ResultsNo changes detected. |
LuaGenerator ResultsNo changes detected. |
ProxyStubGenerator ResultsChanges detected. |
JsonGenerator ResultsNo changes detected. |
LuaGenerator ResultsNo changes detected. |
LuaGenerator ResultsNo changes detected. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
Suppressed comments (1)
tests/FunctionalTests/common/implementations/TestOptionalsImpl.cpp:169
cp.datais empty here, butstd::transform(..., cp.data.begin(), ...)writes throughcp.data.begin()without resizing the destination first. This is undefined behavior and can crash or corrupt memory.
std::transform(input.Value().data.begin(), input.Value().data.end(), cp.data.begin(), [](uint8_t x) {
return static_cast<uint8_t>(x * 2);
No description provided.