-
Notifications
You must be signed in to change notification settings - Fork 18
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
libc: strchr tests: add test group for ASCII compare #195
Conversation
d948c1a
to
d35ee39
Compare
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.
Thanks for this tests. I've pointed out some small nitpicks.
Also I would consider renaming the commit to more closely match the changes, and change beginning of the file:
* TESTED:
* - strlen()
* - strnlen()
* - strcspn()
* - strspn()
* - strchr()
* - strrchr()
* - memchr()
EDIT: You can also tidy up included files.
Aren't these all you need in this test ?:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <unity_fixture.h>
d35ee39
to
d23a3ca
Compare
3aa890b
to
2d941b2
Compare
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.
LGTM, don't forget to organize your commits before merge, also i would wait for @damianloew to approve
2d941b2
to
06d381f
Compare
06d381f
to
83665d6
Compare
c622379
to
5ed43b9
Compare
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.
@mateusz-bloch thanks for previous reviews and @maska989 for much cleaner code, a few things more to add/change.
73a7370
to
a1d3464
Compare
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.
A few things more to improve, please look at the suggestions above.
209c8ba
to
4621fe5
Compare
4621fe5
to
c3c6573
Compare
79ef939
to
060cdd7
Compare
libc/string/string_lenchr.c
Outdated
TEST(string_spn, empty_output) | ||
{ | ||
TEST_ASSERT_EQUAL_INT(0, strcspn("", "abc")); | ||
TEST_ASSERT_EQUAL_INT(0, strspn("", "abc")); | ||
|
||
TEST_ASSERT_EQUAL_INT(0, strcspn("", "")); | ||
TEST_ASSERT_EQUAL_INT(0, strspn("", "")); | ||
} |
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.
When naming it empty_output
do you mean that 0 should be returned? If yes you can also add there strspn("abc", "")
and strcspn("abc", "bc")
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.
Eventually it could be the case where empty arguments are checked, and then strcspn("abc", "")
and strcspn("", "abc")
should be tested.
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.
strcspn("", "abc")
This element is present on commented lines.
d1d091b
to
98fea8a
Compare
98fea8a
to
db9890b
Compare
char *reversStr, | ||
*testStr; | ||
|
||
testStr = testdata_createCharStr(BUFF_SIZE); |
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.
I don't know what was the intention, but if you want to have all ascii chars you have to set size to 129.
Please edit the description of this function in testdata.h
:
/*
* for (size >= ALL_CHARS_STRING_SIZE) returns string filled with all possible chars.
* for (size < ALL_CHARS_STRING_SIZE) returns string with the following content: {1,1,2,...(size-2),0}.
* The returned pointer has to be freed after use!
*/
extern char *testdata_createCharStr(int size);
Would it be more readable?
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.
It is done in #199
db9890b
to
afc1141
Compare
JIRA: CI-232
afc1141
to
4843b64
Compare
Description
Added strcspn and strspn test cases
Motivation and Context
JIRA: CI-232
Types of changes
How Has This Been Tested?
Checklist:
Special treatment