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

optimized stack array implementation #658

Merged

Conversation

11-aryan
Copy link
Contributor

  • Optimized the push operation by appending to the last element of the array instead of copying the whole array
  • Removed the global variable stackArray and created a struct StackArray for it
  • Modified stack_test.go file to reflect these changes

@11-aryan
Copy link
Contributor Author

Hi,
I've made the changes as mentioned. Will this be considered this as a part of the Hacktoberfest if accepted?

@11-aryan
Copy link
Contributor Author

11-aryan commented Oct 1, 2023

Can the code style tests that failed be resolved by running gofmt -s -w stackarray.go ?

@raklaptudirm
Copy link
Member

Yes they can be fixed that way.

Copy link
Member

@raklaptudirm raklaptudirm left a comment

Choose a reason for hiding this comment

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

Please export all the methods and convert the tests into black box ones.

@11-aryan
Copy link
Contributor Author

11-aryan commented Oct 3, 2023

Could you please elaborate what exactly should be black boxed and in what way ?

@raklaptudirm
Copy link
Member

In go, you can write tests either in the packagename package or the packagename_test package. Tests are written under the packagename package when you want to test internal functionality of a package, and under the packagename_test package when you want to test the public API of a package. In your case you are testing the public API (which is why I asked you to export all the methods) and therefore should be tested under the packagename_test package, also known as black box testing.

@11-aryan
Copy link
Contributor Author

11-aryan commented Oct 4, 2023

Oh, got it! Thanks for the explanation

structure/stack/stack_test.go Outdated Show resolved Hide resolved
structure/stack/stackarray.go Outdated Show resolved Hide resolved
structure/stack/stackarray.go Outdated Show resolved Hide resolved
@raklaptudirm raklaptudirm merged commit 85451af into TheAlgorithms:master Oct 10, 2023
3 checks passed
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