-
-
Notifications
You must be signed in to change notification settings - Fork 698
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
all-your-base: add to track #189
Conversation
No love for the octal literal?!? :) |
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.
Another quality add, @stkent. Thank you, sir.
|
||
public final class BaseConverterTest { | ||
|
||
/* |
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.
👍 for the comment.
@Test | ||
public void testLeadingZeros() { | ||
expectedException.expect(IllegalArgumentException.class); | ||
expectedException.expectMessage("Digits may not contain leading zeros."); |
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.
😢 ... 😉
public void testSecondBaseIsOne() { | ||
final BaseConverter baseConverter = new BaseConverter(2, new int[]{1, 0, 1, 0, 1, 0}); | ||
|
||
expectedException.expect(IllegalArgumentException.class); |
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.
All this time, I had anchor bias and put my ExpectedException
rules at the top of the method (prior to the rule, we had the annotation parameter). But you are putting it immediately before the method that should emit the exception... I ❤️ this.
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.
Thanks!
Note that per exercism/problem-specifications#279, the other base conversion exercises are considered deprecated. Let's keep that in mind with #142 and this exercise. |
@jtigger rebased! |
Canonical data here.
The test
both bases are negative
was skipped as it is redundant given the structure of this implementation.The canonical data also poses some questions for implementors, which I answered as follows:
[0]
[0]
No.
By throwing an exception with an appropriate message.