-
-
Notifications
You must be signed in to change notification settings - Fork 519
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
change: Regenerate Tests #871
Conversation
Update generator to use the standard error indicator. Update solution to pass updated tests.
@@ -45,16 +45,22 @@ def test_no_coins_make_0_change | |||
|
|||
def test_error_testing_for_change_smaller_than_the_smallest_of_coins | |||
skip | |||
assert_equal -1, Change.generate([5, 10], 3) | |||
assert_raises(ArgumentError) do | |||
Change.generate([5, 10], 3) |
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.
ArgumentError
is probably OK here, but what about returning a subclass which is more descriptive?
end | ||
|
||
def test_error_if_no_combination_can_add_up_to_target | ||
skip | ||
assert_equal -1, Change.generate([5, 10], 94) | ||
assert_raises(ArgumentError) do | ||
Change.generate([5, 10], 94) |
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.
ArgumentError
is probably not appropriate here.
Maybe nil
or a custom error?
end | ||
|
||
def test_cannot_find_negative_change_values | ||
skip | ||
assert_equal -1, Change.generate([1, 2, 5], -5) | ||
assert_raises(ArgumentError) do | ||
Change.generate([1, 2, 5], -5) |
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.
ArgumentError
is reasonable here. 👍
(I don't think invalid input like this is something we should be testing for, but that's an unrelated issue. (and very much a matter of opinion.))
Hello @iHiD! Thank you for your review. Wanted us to deal with #870 before this one, that's why I took so long to answer. I understand and agree with your points, but I have a question: Given how all 3 of these "error cases" are specified on the canonical data as |
I assume you meant @Insti there :) Yeah you'll need to do something like that. Either check the test name or error text I guess. |
Ah! I was confused :) |
@Insti I just pushed some tentative changes. I didn't follow your suggestions to the letter, but wanted to get your opinion regardless. Please let me know what you think. I also appreciate suggestions for better error names 👍 |
cb7ff87
to
6c023f5
Compare
@@ -1,18 +1,23 @@ | |||
class Change | |||
attr_reader :coins, :target | |||
|
|||
class NegativeTargetError < ArgumentError; end | |||
class ImpossibleCombinationError < StandardError; end |
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 really like these two 👍
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 think this looks good and does everything it needs to do now.
Do you think this is ready to merge now @pgaspar ? |
I think so @Insti! Thank you 👍 |
Thanks for all your work on these @pgaspar ❤️ |
Update
change
tests to:1.3.0 258c807
Update generator to use the standard error indicator.
Update solution to pass updated tests.