Skip to content

fix: handle incorrect inputs in StackPostfixNotation #4261

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

Merged
merged 7 commits into from
Jul 26, 2023

Conversation

vil02
Copy link
Member

@vil02 vil02 commented Jul 25, 2023

The current implementation of StackPostfixNotation.postfixEvaluate:

  • crashed for empty input (i.e. ""),
  • returns 3 for the input "3 3 3".

This PR:

  • adds missing tests,
  • does some basic linting,
  • and fixes the above issues.

I did not update the doc string, since I believe this class needs some refactoring anyway (e.g. the method postfixEvaluate is way too long). I am also concerned with the current formatting: this line seems way too long. In my opinion both of these are out of scope for this PR.

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized it.
  • All filenames are in PascalCase.
  • All functions and variable names follow Java naming conventions.
  • All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.

@vil02 vil02 changed the title tests: add StackPostfixNotationTest fix: handle incorrect inputs in StackPostfixNotationTest.postfixEvaluate Jul 25, 2023
@vil02 vil02 changed the title fix: handle incorrect inputs in StackPostfixNotationTest.postfixEvaluate fix: handle incorrect inputs in StackPostfixNotationTest Jul 25, 2023
@vil02 vil02 changed the title fix: handle incorrect inputs in StackPostfixNotationTest fix: handle incorrect inputs in StackPostfixNotation Jul 25, 2023
@vil02 vil02 marked this pull request as ready for review July 25, 2023 19:24
Copy link
Member

@siriak siriak left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

@siriak siriak enabled auto-merge (squash) July 26, 2023 06:19
@siriak siriak merged commit 44dcebb into TheAlgorithms:master Jul 26, 2023
@vil02 vil02 deleted the add_tests_stack_postfix_evaluation branch July 26, 2023 07:49
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.

2 participants