-
Notifications
You must be signed in to change notification settings - Fork 8
CTB-11111 test commit (#20) #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,33 @@ | ||||||||||||||||||||||||||||||
| #include <stdio.h> | ||||||||||||||||||||||||||||||
| #include <string.h> | ||||||||||||||||||||||||||||||
|
Comment on lines
+1
to
+2
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| void reverseString(char *str) { | ||||||||||||||||||||||||||||||
| int start = 0; | ||||||||||||||||||||||||||||||
| int end = strlen(str) - 1; | ||||||||||||||||||||||||||||||
|
Comment on lines
+5
to
+6
|
||||||||||||||||||||||||||||||
| 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; |
There was a problem hiding this comment.
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
Copilot
AI
Mar 4, 2026
There was a problem hiding this comment.
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
AI
Mar 4, 2026
There was a problem hiding this comment.
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.
| 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; | |
| } |
There was a problem hiding this comment.
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.