Skip to content
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: string.h: add cmp functions tests #199

Merged
merged 2 commits into from
Jul 31, 2023
Merged

Conversation

maska989
Copy link
Contributor

Description

Added

  • memcmp(),
  • strcmp(),
  • strncmp(),
  • strcoll()

function tests.

Motivation and Context

JIRA: CI-231

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

How Has This Been Tested?

  • Already covered by automatic testing.
  • New test added: (add PR link here).
  • Tested by hand on: (list targets here).

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing linter checks and tests passed.
  • My changes generate no new compilation warnings for any of the targets.

Special treatment

  • This PR needs additional PRs to work (list the PRs, preferably in merge-order).
  • I will merge this PR by myself when appropriate.

@maska989 maska989 force-pushed the Maska989/testCmp branch 2 times, most recently from 17631ea to d5a5ffe Compare April 28, 2023 13:24
@maska989 maska989 requested a review from damianloew May 4, 2023 09:09
libc/string_cmp.c Outdated Show resolved Hide resolved
libc/string_cmp.c Outdated Show resolved Hide resolved
libc/string_cmp.c Outdated Show resolved Hide resolved
libc/string_cmp.c Outdated Show resolved Hide resolved
libc/string_cmp.c Outdated Show resolved Hide resolved
libc/string_cmp.c Outdated Show resolved Hide resolved
libc/string_cmp.c Outdated Show resolved Hide resolved
libc/string_cmp.c Outdated Show resolved Hide resolved
libc/string_cmp.c Outdated Show resolved Hide resolved
@maska989 maska989 force-pushed the Maska989/testCmp branch 3 times, most recently from 2b198ec to a6857a5 Compare May 29, 2023 12:37
@maska989 maska989 marked this pull request as ready for review May 30, 2023 12:57
@maska989 maska989 force-pushed the Maska989/testCmp branch 2 times, most recently from 5aef5a0 to f820b62 Compare June 6, 2023 10:39
libc/string_cmp.c Outdated Show resolved Hide resolved
libc/string_cmp.c Outdated Show resolved Hide resolved
libc/string_cmp.c Outdated Show resolved Hide resolved
libc/string_cmp.c Outdated Show resolved Hide resolved
libc/string_cmp.c Outdated Show resolved Hide resolved
libc/string_cmp.c Outdated Show resolved Hide resolved
@maska989 maska989 force-pushed the Maska989/testCmp branch 5 times, most recently from 96eff61 to 67b8816 Compare June 12, 2023 06:25
Copy link
Contributor

@damianloew damianloew left a comment

Choose a reason for hiding this comment

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

Thanks for correcting the test to this version, it looks clear, but let's improve it a little bit.

libc/string_cmp.c Outdated Show resolved Hide resolved
libc/string_cmp.c Outdated Show resolved Hide resolved
libc/string_cmp.c Outdated Show resolved Hide resolved
libc/string_cmp.c Outdated Show resolved Hide resolved
libc/string_cmp.c Outdated Show resolved Hide resolved
libc/string_cmp.c Outdated Show resolved Hide resolved
libc/string_cmp.c Outdated Show resolved Hide resolved
libc/string_cmp.c Outdated Show resolved Hide resolved
libc/string_cmp.c Outdated Show resolved Hide resolved
libc/string_cmp.c Outdated Show resolved Hide resolved
@maska989 maska989 force-pushed the Maska989/testCmp branch 2 times, most recently from 3d33532 to 601ca2c Compare July 6, 2023 11:13
@maska989 maska989 requested a review from damianloew July 13, 2023 07:48
libc/string/string_cmp.c Outdated Show resolved Hide resolved
libc/string/string_cmp.c Outdated Show resolved Hide resolved
libc/string/string_cmp.c Outdated Show resolved Hide resolved
libc/string/string_cmp.c Outdated Show resolved Hide resolved
libc/string/string_cmp.c Outdated Show resolved Hide resolved
libc/string/string_cmp.c Outdated Show resolved Hide resolved
libc/string/string_cmp.c Show resolved Hide resolved
libc/string/string_cmp.c Outdated Show resolved Hide resolved


/* Loop which changes the size of compared space to place where asciSet ends */
for (i = 1; i < sizeof(asciiSet); i++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It was not applied, I've suggested sth similar, but with the ascii data and with checking two sizes in one iteration.

libc/string/string_cmp.c Show resolved Hide resolved
libc/string/string_cmp.c Outdated Show resolved Hide resolved
libc/string/string_cmp.c Outdated Show resolved Hide resolved
libc/string/string_cmp.c Outdated Show resolved Hide resolved
libc/string/string_cmp.c Outdated Show resolved Hide resolved
libc/string/string_cmp.c Outdated Show resolved Hide resolved
libc/string/string_cmp.c Outdated Show resolved Hide resolved
libc/string/string_cmp.c Outdated Show resolved Hide resolved
libc/string/string_cmp.c Outdated Show resolved Hide resolved
libc/string/string_cmp.c Outdated Show resolved Hide resolved
libc/string/string_cmp.c Outdated Show resolved Hide resolved
Copy link
Contributor

@damianloew damianloew left a comment

Choose a reason for hiding this comment

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

Please also add a cases offsets to the rest of tested functions. I know it wasn't planned initially, but I think it will be worth as the implementation of strcmp for example is very close to the memcmp one. You would have to replace all of zeros with 1 for example when preparing test data for those functions and set NUL term (the rest of functions test strings).

libc/string/string_cmp.c Outdated Show resolved Hide resolved
libc/string/string_cmp.c Outdated Show resolved Hide resolved
libc/string/string_cmp.c Outdated Show resolved Hide resolved
Copy link
Contributor

@damianloew damianloew left a comment

Choose a reason for hiding this comment

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

Small thing, but I think we should be consistent and start with a lowercase letter after suffix in commit message, so testdata: extend description for createCharStr

libc/string/string_cmp.c Outdated Show resolved Hide resolved
libc/string/string_cmp.c Outdated Show resolved Hide resolved
Copy link
Contributor

@damianloew damianloew left a comment

Choose a reason for hiding this comment

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

LGTM, Let's wait with merge for #230

@maska989 maska989 requested a review from damianloew July 31, 2023 10:20
@damianloew damianloew merged commit ab3ce19 into master Jul 31, 2023
25 checks passed
@damianloew damianloew deleted the Maska989/testCmp branch July 31, 2023 12:05
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