-
Notifications
You must be signed in to change notification settings - Fork 32
#68 - Added a ctor to SimpleHex that resolves ambiguity #70
Conversation
…ed relevant tests. Fixed dependencies that were using the old Data ctor that allowed ambiguous hex string.
… compact big endian value and fixes that. Added relevant tests
Job #70 is now in scope, role is |
This pull request #70 is assigned to @driver733/z, here is why. The budget is 15 minutes, see §4. Please, read §27 and when you decide to accept the changes, inform @Biboran/z (the architect) right in this ticket. If you decide that this PR should not be accepted ever, also inform the architect.We should be aware that driver733 is on vacation! This ticket may be delayed. |
If `hexValue` is ambiguous a `DescribedError` is thrown | ||
*/ | ||
init(hexValue: String) throws { | ||
guard hexValue.count.isEven() else { throw AmbiguousHexStringError(hexValue: hexValue) } |
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.
@Biboran There must be no code in constructors, including validations.
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.
It is ok. This object should not be created with invalid data
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.
@rockfridrich Please read 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.
@rockfridrich I agree with @driver733. I'll change the design. I think i'll just dump alpha-design
into a separate branch and work on refactoring.
@@ -62,5 +62,89 @@ class HexTests: XCTestCase { | |||
) | |||
|
|||
} | |||
|
|||
func testCorrectlyAlignedHexFor1() { | |||
expect{ |
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.
@Biboran Please limit your tests to only one expect. In other words, test only one thing in your tests, such as one method.
You test should have one expect, but it can have nested expects. This is only permissible if you need them to test one thing. You can not use this technique to test different class methods.
`DescribedError` if something goes wrong | ||
*/ | ||
convenience init(bigEndianCompactValue: String) throws { | ||
if bigEndianCompactValue.count.isEven() { |
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.
There must be no code in constructors.
This was an incorrect design. I'll add refactoring issues. |
Order was finished, quality was "acceptable": +15 points just awarded to @driver733/z |
The job #70 is now out of scope |
To resolve #68 I added a ctor to
SimpleHex
that resolves a length ambiguity by assuming the value of the hex string that is passed is a big endian compact (without any leading zeroes) value. I added relevant tests.