Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Added APIs isalnum() and isnumeric() in string object #2572

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

Closed
wants to merge 4 commits into from

Conversation

Kishan-Ved
Copy link
Contributor

@Kishan-Ved Kishan-Ved commented Mar 3, 2024

Towards: #2356

APIs added:

  • isalnum()
  • isnumeric()

These have been tested extensively, for both compile time and run time tests.

@Kishan-Ved Kishan-Ved changed the title Added API isalnum() in string object Added APIs isalnum() and isnumeric() in string object Mar 3, 2024
@Kishan-Ved
Copy link
Contributor Author

I'll resolve all the conflicts here (if any) once the review is done.

Comment on lines 348 to 352
/// Verify that str consists of letters or numbers only
inline bool isalnum(const std::string &str) {
return std::all_of(str.begin(), str.end(), [](char c) { return std::isalnum(c, std::locale()); });
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need this implementation? Where is it being used?

Copy link
Contributor Author

@Kishan-Ved Kishan-Ved Mar 6, 2024

Choose a reason for hiding this comment

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

Yes, it works without this being present too. I had put it here as isalpha() was present here, but I think that is for some other reason. I have removed this now.

Copy link
Collaborator

@ubaidsk ubaidsk left a comment

Choose a reason for hiding this comment

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

I shared a query above. The rest seems good to me. Conflicts need to be resolved. I will review again after conflicts are resolved.

@Kishan-Ved
Copy link
Contributor Author

I shared a query above. The rest seems good to me. Conflicts need to be resolved. I will review again after conflicts are resolved.

Please let me know a fast way to resolve such conflicts. These have appeared as I had changed references in this PR: #2574, which has now been merged. I had made both these PRs by branching from the main branch that existed before I made that PR.

@ubaidsk
Copy link
Collaborator

ubaidsk commented Mar 6, 2024

Please let me know a fast way to resolve such conflicts.

I always commit updation of reference tests in a separate commit (with the fixed message "TEST: Update reference tests"). That way if there are conflicts between the reference test updates of my branch and the main branch, I can just drop my commit "TEST: Update reference tests" and then rebase over the main branch. After rebase, I simply rebuild the project, update the reference tests and add a new commit with the updated reference tests (with the same commit message "TEST: Update reference tests").

@ubaidsk
Copy link
Collaborator

ubaidsk commented Mar 6, 2024

Please let me know a fast way to resolve such conflicts.

For now, maybe try this (make a separate branch before trying so that you can always recover your changes).

git rebase --strategy-option ours main
git clean -dfx
./build.sh
./run_tests.sh -u
git add tests
git commit -m "TEST: Update reference tests"

@ubaidsk
Copy link
Collaborator

ubaidsk commented Mar 6, 2024

For now, maybe try this (make a separate branch before trying so that you can always recover your changes).

If this does not work, a simple option could be to create a new branch from main and manually add the changes in this PR to it. Finally update and commit the reference tests in a separate commit.

There can also be another option in which you rebase and edit your commit Implemented isnumeric() to only include changes related to source code and exclude changes related to reference tests. Next you drop your commits related to changes in reference tests (using git rebase again) and finally rebase over main. Now you can update tests and commit them without any conflicts.

@Thirumalai-Shaktivel
Copy link
Collaborator

Please mark this PR ready for review once it is ready.

@Thirumalai-Shaktivel Thirumalai-Shaktivel marked this pull request as draft March 7, 2024 06:45
@Kishan-Ved
Copy link
Contributor Author

As there were too many conflicts, I have created a new PR: #2582

@Kishan-Ved
Copy link
Contributor Author

Finished and merged: #2582

@Kishan-Ved Kishan-Ved closed this Mar 7, 2024
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