-
Notifications
You must be signed in to change notification settings - Fork 652
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
Making ByteBuffer's description more useful #2864
Changes from 1 commit
de74571
961b455
df18d08
792c96a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1909,6 +1909,11 @@ class ByteBufferTest: XCTestCase { | |
let buf = ByteBuffer(string: "Hello") | ||
XCTAssertEqual("48656c6c6f", buf.hexDump(format: .compact)) | ||
} | ||
|
||
func testHexDumpCompactReadableBytesLessThenMaxBytes() { | ||
let buf = ByteBuffer(string: "hello world") | ||
XCTAssertEqual("68656c6c6f20776f726c64", buf.hexDump(format: .compact(maxBytes: 100))) | ||
} | ||
|
||
func testHexDumpCompactEmptyBuffer() { | ||
let buf = ByteBuffer(string: "") | ||
|
@@ -3602,5 +3607,12 @@ extension ByteBufferTest { | |
XCTAssertEqual(error as? Base64Error, .invalidCharacter) | ||
} | ||
} | ||
|
||
|
||
func testByteBufferDescription() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. think it would be nice to add two other test cases:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, added! |
||
let buffer = ByteBuffer(string: "hello world") | ||
|
||
XCTAssertEqual(buffer.description, "[68656c6c6f20776f726c64](11 bytes)") | ||
|
||
XCTAssertEqual(buffer.description, buffer.debugDescription) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ class NIOAnyDebugTest: XCTestCase { | |
let bb = ByteBuffer(string: "byte buffer string") | ||
XCTAssertTrue( | ||
wrappedInNIOAnyBlock(bb).contains( | ||
"NIOAny { ByteBuffer { readerIndex: 0, writerIndex: 18, readableBytes: 18, capacity: 32, storageCapacity: 32, slice: _ByteBufferSlice { 0..<32 }, storage: " | ||
"NIOAny { [627974652062756666657220737472696e67](18 bytes) }" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: I almost think with this change we should change NIOAny's There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking at |
||
) | ||
) | ||
XCTAssertTrue(wrappedInNIOAnyBlock(bb).hasSuffix(" }")) | ||
|
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: The first line in the doc comments is special, it's the summary. That summary gets displayed by itself in many scenarios so we should aim for it to make sense without the rest of the doc comment.