Skip to content

Testing purpose#22

Open
pradeeptakdas wants to merge 2 commits intordkcentral:feature/RDKCOM-1035from
pradeeptakdas:testing-purpose
Open

Testing purpose#22
pradeeptakdas wants to merge 2 commits intordkcentral:feature/RDKCOM-1035from
pradeeptakdas:testing-purpose

Conversation

@pradeeptakdas
Copy link
Copy Markdown

No description provided.

@pradeeptakdas pradeeptakdas requested a review from a team as a code owner March 4, 2026 14:59
Copilot AI review requested due to automatic review settings March 4, 2026 14:59
@pradeeptakdas pradeeptakdas requested a review from a team as a code owner March 4, 2026 14:59
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

Adds a new C source file under the unit test tree that implements an interactive string-reversal program.

Changes:

  • Introduces source/test/testing_purpose.c with a reverseString() helper and an interactive main() that reads from stdin and prints results.

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

Comment on lines +19 to +34
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 file adds an interactive standalone main() program under source/test, but it is not referenced by source/test/Makefile.am (the unit test build enumerates sources explicitly). If this is intended as a unit test, convert it into a gtest test and add it to PsmSsp_gtest_bin_SOURCES; otherwise consider removing it or relocating it outside the test tree to avoid dead/accidental test artifacts in the repo.

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.
start++;
end--;
}
printf("string reversed : %s\n",str);
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.

reverseString performs I/O (printf) in addition to reversing the buffer, and main() prints the reversed string again. Consider keeping reverseString focused on mutation only and letting the caller decide whether/how to print, to avoid duplicated output and make the function reusable in unit tests.

Suggested change
printf("string reversed : %s\n",str);

Copilot uses AI. Check for mistakes.
char str[100];

printf("Enter a string: ");
fgets(str, sizeof(str), stdin);
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.

fgets return value is not checked. If stdin is closed or an error occurs, str contents are undefined and strcspn/reverseString will operate on uninitialized data. Handle a NULL return from fgets (e.g., print an error and return non-zero) before using str.

Suggested change
fgets(str, sizeof(str), stdin);
if (fgets(str, sizeof(str), stdin) == NULL) {
fprintf(stderr, "Error reading input.\n");
return 1;
}

Copilot uses AI. Check for mistakes.
#include <stdio.h>
#include <string.h>

void reverseString(char *str) {
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.

reverseString has external linkage but appears intended for use only within this file. Mark it static to avoid exporting an unnecessary symbol from the test binary (and potential link conflicts if another test adds the same helper name).

Suggested change
void reverseString(char *str) {
static void reverseString(char *str) {

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.

2 participants