Feature #2225
closed
Print Block in a readable format
Added by Yingdi Yu almost 10 years ago.
Updated over 6 years ago.
Description
In some cases, developers using ndn-cxx may want to print out ndn-tlv block in a readable format to check encoding errors.
It would be desired to have a helper method provided by ndn-cxx library, so that developers do not have to write their own printing code.
- Subject changed from A helper method to print ndn-tlv block raw data in a readable format to print Block in a readable format
- Category set to Utils
- Start date deleted (
11/25/2014)
- Estimated time set to 3.00 h
- Assignee set to Chengyu Fan
- Status changed from New to In Progress
- Target version set to v0.7
I'll work on a simple hexadecimal format so that BOOST_CHECK_EQUAL
can be used in unit tests.
- Status changed from In Progress to Code review
- % Done changed from 0 to 100
- Assignee changed from Chengyu Fan to Junxiao Shi
4682,2 adopts the following representation.
- Default-constructed block is printed as:
[invalid]
.
- Zero-length block is printed as:
TT[empty]
, where TT is TLV-TYPE in decimal.
- Non-zero-length block on which @p decode is not called is printed as:
TT[LL]=VVVV
, where LL is TLV-LENGTH in decimal, and VVVV is TLV-VALUE is hexadecimal.
- Block on which @p decode has been called in printed as:
TT[LL]={SUB,SUB}
, where SUB is a sub-element printed using this format.
There has been an argument about TT[empty]
vs TT[0]
.
I chose TT[empty]
to because zero-length block is special. An existing example in stdlib is: printf("%p", NULL)
prints (nil)
instead of 0x0
.
There has been an argument about TT[empty]
vs TT[0]
.
20180418 NFD call confirms that the assignee is free to choose either format.
Change 4682,3 updates all test cases to use BOOST_CHECK_EQUAL
and BOOST_CHECK_NE
on types with == != <<
operators. Most of them are Block
, but there are also Name KeyLocator AdditionalDescription
. I tried ValidityPeriod
but it doesn't work. The remaining usage of BOOST_CHECK(.. == ..)
includes Buffer
type that still doesn't have a <<
operator, but they occur infrequently.
- Subject changed from print Block in a readable format to Print Block in a readable format
- Description updated (diff)
- Category changed from Utils to Base
- Status changed from Code review to Closed
Also available in: Atom
PDF