Copilot commented on code in PR #12582:
URL: https://github.com/apache/trafficserver/pull/12582#discussion_r2443640514
##########
src/api/InkAPITest.cc:
##########
@@ -5216,11 +5224,8 @@ REGRESSION_TEST(SDK_API_TSMimeHdrField)(RegressionTest
*test, int /* atype ATS_U
lengthField1Value4 == static_cast<int>(strlen(field1Value4))) &&
((strncmp(field1Value5Get, field1Value5, lengthField1Value5) == 0) &&
lengthField1Value5 == static_cast<int>(strlen(field1Value5))) &&
- (strstr(field1ValueAllGet, field1Value1Get) == field1Value1Get) &&
- (strstr(field1ValueAllGet, field1Value2Get) == field1Value2Get) &&
- (strstr(field1ValueAllGet, field1Value3Get) == field1Value3Get) &&
- (strstr(field1ValueAllGet, field1Value4Get) == field1Value4Get) &&
- (strstr(field1ValueAllGet, field1Value5Get) == field1Value5Get)) {
+ (svall.find(sv1) != svall.npos) && (svall.find(sv2) != svall.npos)
&& (svall.find(sv3) != svall.npos) &&
+ (svall.find(sv4) != svall.npos) && (svall.find(sv5) != svall.npos)) {
Review Comment:
The original code checked if each substring appeared at the start of the
full string using pointer equality (`strstr(field1ValueAllGet, field1Value1Get)
== field1Value1Get`). The new code only checks if substrings exist anywhere in
the string using `find() != npos`, which changes the test semantics. To
preserve the original behavior, use `svall.starts_with(sv1)` or check if
`svall.find(sv1) == 0`.
```suggestion
(svall.find(sv1) == 0) && (svall.find(sv2) == 0) &&
(svall.find(sv3) == 0) &&
(svall.find(sv4) == 0) && (svall.find(sv5) == 0)) {
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]