-
Notifications
You must be signed in to change notification settings - Fork 11
Conversation
igorpeshansky
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.
Thanks. Please try to apply each comment everywhere it makes sense.
src/base64.h
Outdated
| std::string Encode(const std::string &source); | ||
|
|
||
| std::string Decode(const std::string &source); | ||
| //std::string Decode(const std::string &source); |
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 did you decide to comment this out?
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.
The definition is commented out, so I thought I would reflect that in the header file. It seemed wrong to have a declaration with no definition anywhere.
I don't feel tied to this - happy to change it back.
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.
Let's uncomment this. To be honest, I've also uncommented the implementation and tested it in my private clone, and it works fine, so we might as well make it available, even if we don't yet use it.
Want me to push the commit that does that?
test/Makefile
Outdated
| TEST_OBJS=$(TEST_SOURCES:$(TEST_DIR)/%.cc=%.o) | ||
| TESTS=\ | ||
| format_unittest | ||
| format_unittest\ |
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.
Let's add a space before the \.
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.
Done.
test/base64_unittest.cc
Outdated
| namespace { | ||
|
|
||
| TEST(EncodeTest, EmptyEncode) { | ||
| const std::string empty_str(""); |
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.
May not be worth naming the constants... How about just inlining them into the EXPECT_EQ? I.e.,
TEST (EncodeTest, EmptyEncode) {
EXPECT_EQ("", base64::Encode(""));
}?
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.
Agreed - done.
test/base64_unittest.cc
Outdated
| ); | ||
| } | ||
|
|
||
| TEST(EncodeTest, NoPaddingEncode) { |
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.
Do you want to add a comment explaining the "no padding" bit? E.g., // 5 bytes should produce 7 characters.
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.
Yep, done.
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've been trying to come up with a good name for the "padding" tests... The best I got so far is "phantom" (as in "phantom characters at the end"). So this test would have been named "OnePhantom", and the double padding one below would become "TwoPhantoms". WDYT? Happy to hear suggestions for better names. Ultimately, I think we ought to explain what we're testing in a comment if the test name isn't sufficiently expressive.
Your comment explains "no padding", but not the difference between the single and double pad characters.
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.
Phantom sounds good to me. Hopefully the new comment is more clear.
test/base64_unittest.cc
Outdated
| ); | ||
| } | ||
|
|
||
| TEST(EncodeTest, NoDoublePaddingEncode) { |
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 "double padding"? Can you please elaborate?
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.
Sure: Typically this would have "==" as padding, hence the "double" as opposed to the above which would have "=" (single). I guess its kind of a trivial case, happy to remove it.
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 it's an important corner case and needs to be tested, but see my other note about test naming.
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.
Addressed above.
src/base64.h
Outdated
| std::string Encode(const std::string &source); | ||
|
|
||
| std::string Decode(const std::string &source); | ||
| //std::string Decode(const std::string &source); |
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.
Let's uncomment this. To be honest, I've also uncommented the implementation and tested it in my private clone, and it works fine, so we might as well make it available, even if we don't yet use it.
Want me to push the commit that does that?
test/base64_unittest.cc
Outdated
| namespace { | ||
|
|
||
| TEST(EncodeTest, EmptyEncode) { | ||
| EXPECT_EQ( |
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.
Let's save some vertical space and put this whole EXPECT_EQ on a single line. Ditto below.
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.
Agreed, fixed.
test/base64_unittest.cc
Outdated
| ); | ||
| } | ||
|
|
||
| //Base64 encodings typically pad messages to ensure output length % 4 == 0, our |
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.
Nit: missing space after comment marker.
test/base64_unittest.cc
Outdated
| } | ||
|
|
||
| //Base64 encodings typically pad messages to ensure output length % 4 == 0, our | ||
| //implementation does not |
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.
Nit: missing trailing ".".
test/base64_unittest.cc
Outdated
| ); | ||
| } | ||
|
|
||
| TEST(EncodeTest, NoPaddingEncode) { |
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've been trying to come up with a good name for the "padding" tests... The best I got so far is "phantom" (as in "phantom characters at the end"). So this test would have been named "OnePhantom", and the double padding one below would become "TwoPhantoms". WDYT? Happy to hear suggestions for better names. Ultimately, I think we ought to explain what we're testing in a comment if the test name isn't sufficiently expressive.
Your comment explains "no padding", but not the difference between the single and double pad characters.
test/base64_unittest.cc
Outdated
| ); | ||
| } | ||
|
|
||
| TEST(EncodeTest, NoDoublePaddingEncode) { |
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 it's an important corner case and needs to be tested, but see my other note about test naming.
test/base64_unittest.cc
Outdated
| } | ||
|
|
||
| // Base64 encoders typically pad messages to ensure output length % 4 == 0. To | ||
| // acheive this, encoders will pad messages with either one or two "=". Our |
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.
Let's stick to one space after "." (throughout).
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.
Fixed.
igorpeshansky
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.
LGTM ![]()
supriyagarg
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.
A very minor comment., otherwise LGTM.
test/base64_unittest.cc
Outdated
| } | ||
|
|
||
| // Base64 encoders typically pad messages to ensure output length % 4 == 0. To | ||
| // acheive this, encoders will pad messages with either one or two "=". Our |
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.
acheive -> achieve
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.
Fixed.
igorpeshansky
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.
LGTM
again.
Also fix bug in alternate base64::Encode implementation and enable base64::Decode.
Add testing for base64 encoding. Remove base64 decoding from header file to reflect its commented out implementation.