Skip to content

CTB-11111 test commit (#20)#21

Open
Sukanya673 wants to merge 1 commit intodevelopfrom
feature/RDKCOM-1035
Open

CTB-11111 test commit (#20)#21
Sukanya673 wants to merge 1 commit intodevelopfrom
feature/RDKCOM-1035

Conversation

@Sukanya673
Copy link
Copy Markdown
Contributor

Working on understanding process workflow
Please do not merge,

Copilot AI review requested due to automatic review settings March 4, 2026 14:50
@Sukanya673 Sukanya673 requested review from a team as code owners March 4, 2026 14:50
str[end] = temp;
start++;
end--;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a print here

Copy link
Copy Markdown

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 appears to be a workflow/learning “test commit” and introduces a small standalone C program under the test directory that reads a string from stdin and reverses it in place.

Changes:

  • Added source/test/testing_purpose.c, a simple interactive C program that reverses a string.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1 to +2
#include <stdio.h>
#include <string.h>
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new C file is missing the standard Apache 2.0 license/header block that appears at the top of other source/test files in this repo. Please add the project’s usual header to keep licensing consistent.

Copilot uses AI. Check for mistakes.
Comment on lines +5 to +6
int start = 0;
int end = strlen(str) - 1;
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

int end = strlen(str) - 1; can underflow when the input string is empty (strlen==0) and also truncates size_t into int, which is implementation-defined for long strings. Consider using size_t len = strlen(str); and returning early when len < 2, then index with size_t/ptrdiff_t safely.

Suggested change
int start = 0;
int end = strlen(str) - 1;
if (str == NULL) {
return;
}
size_t len = strlen(str);
if (len < 2) {
return;
}
size_t start = 0;
size_t end = len - 1;

Copilot uses AI. Check for mistakes.
Comment on lines +21 to +26
printf("Enter a string: ");
fgets(str, sizeof(str), stdin);

// Remove newline if present
str[strcspn(str, "\n")] = 0;

Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return value of fgets isn’t checked. If stdin is closed/EOF, fgets returns NULL and str remains uninitialized, leading to undefined behavior in strcspn and reverseString. Please handle the NULL case (e.g., print an error and exit).

Copilot uses AI. Check for mistakes.
Comment on lines +18 to +33
int main() {
char str[100];

printf("Enter a string: ");
fgets(str, sizeof(str), stdin);

// Remove newline if present
str[strcspn(str, "\n")] = 0;

reverseString(str);
printf("Reversed string: %s\n", str);

return 0;
}


Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This adds an interactive main() program under source/test/, but the test suite here is built as a single gtest binary (see source/test/Makefile.am and gtest_main.cpp). If this file is only for workflow experimentation, it should be removed before merging; if it’s meant to test string reversal, consider converting it into a gtest unit test instead of prompting on stdin.

Suggested change
int main() {
char str[100];
printf("Enter a string: ");
fgets(str, sizeof(str), stdin);
// Remove newline if present
str[strcspn(str, "\n")] = 0;
reverseString(str);
printf("Reversed string: %s\n", str);
return 0;
}

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,33 @@
#include <stdio.h>
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR description says "Please do not merge". To avoid accidental merges, consider marking this PR as a Draft or closing it until it’s ready to land.

Copilot uses AI. Check for mistakes.
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.

3 participants