-
Notifications
You must be signed in to change notification settings - Fork 325
Convert evmc::hex library into single hex.hpp header #643
Conversation
9e9932c to
1fa70ca
Compare
Codecov Report
@@ Coverage Diff @@
## master #643 +/- ##
=======================================
Coverage 92.86% 92.86%
=======================================
Files 24 23 -1
Lines 3574 3546 -28
Branches 367 375 +8
=======================================
- Hits 3319 3293 -26
+ Misses 146 144 -2
Partials 109 109 |
329e36d to
1366a05
Compare
| int b = empty_byte_mark; | ||
| for (const auto h : hex) | ||
| { | ||
| if (isspace(h)) |
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.
Why allow space here? Why not allow space in the prefix?
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.
This is practical as a separator for readability or when loading from files (where usually there is the trailing new line character).
Not sure what you mean "in the prefix". Like 0 x 01?
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.
Yes.
test/unittests/hex_test.cpp
Outdated
| EXPECT_EQ(ec2.category(), hex_category()); | ||
| for (int i = int{std::numeric_limits<char>::min()}; i <= std::numeric_limits<char>::max(); ++i) | ||
| { | ||
| switch (const auto c = static_cast<char>(i); c) |
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.
Maybe add std::isspace(c) == evmc::internal_hex::isspace(c) too? Probably not needed.
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.
Ah, that's actually much better idea than my test.
f09a7da to
a476d6e
Compare
| case '\n': | ||
| case '\r': | ||
| case '\t': | ||
| case '\v': |
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 actually wonder if isspace should be used in the hex parser or just checking for space would be enough?
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 need at least , \r, \n.
axic
left a comment
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.
Looks good to me otherwise.
This replaces std::error_code and exceptions with std::optional<bytes> to inform about invalid hex input.
No description provided.