-
Notifications
You must be signed in to change notification settings - Fork 16
created a function for inserting a substring into a string by index #19
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: main
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 |
|---|---|---|
|
|
@@ -483,6 +483,18 @@ void test_stringToDouble() { | |
| printGreen("stringToDouble\n"); | ||
| } | ||
|
|
||
| void test_stringInsert(){ | ||
| TString s1 = stringInitWithCharArr("abcdef"); | ||
| TString s2 = stringInitWithCharArr("123"); | ||
|
Comment on lines
+487
to
+488
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add more test cases |
||
| stringInsert(&s1, 2, s2); | ||
|
|
||
| TString s1expected = stringInitWithCharArr("ab123cdef"); | ||
|
|
||
| assertEq(strncmp(s1.data, s1expected.data, stringLen(s1expected)), 0); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use stringCompare from this library
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Generally good job) |
||
|
|
||
| printGreen("stringInsert\n"); | ||
| } | ||
|
|
||
| int main() { | ||
| test_stringStartWith(); | ||
| test_stringEndWith(); | ||
|
|
@@ -511,5 +523,6 @@ int main() { | |
| test_stringIsPalindrome(); | ||
| test_stringPad(); | ||
| test_stringRemove(); | ||
| test_stringInsert(); | ||
| 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.
And what about
s->capacity???