Project

General

Profile

Actions

Feature #2225

closed

Print Block in a readable format

Added by Yingdi Yu over 9 years ago. Updated almost 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Base
Target version:
Start date:
Due date:
% Done:

100%

Estimated time:
3.00 h

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.

Actions #1

Updated by Junxiao Shi about 9 years ago

  • 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
Actions #2

Updated by Chengyu Fan about 9 years ago

  • Assignee set to Chengyu Fan
Actions #3

Updated by Junxiao Shi about 6 years ago

  • 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.

Actions #4

Updated by Junxiao Shi about 6 years ago

  • Status changed from In Progress to Code review
  • % Done changed from 0 to 100
Actions #5

Updated by Junxiao Shi about 6 years ago

  • Assignee changed from Chengyu Fan to Junxiao Shi
Actions #6

Updated by Junxiao Shi about 6 years ago

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.

Actions #7

Updated by Junxiao Shi almost 6 years ago

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.

Actions #8

Updated by Davide Pesavento almost 6 years ago

  • 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
Actions

Also available in: Atom PDF