Skip to content

Commit 1bcbee6

Browse files
author
Razvan Becheriu
committed
[#2844] addressed comments
1 parent 95d3092 commit 1bcbee6

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

src/lib/dhcp/option.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,11 @@ std::string Option::toText(int indent) const {
236236
output << setfill('0') << setw(2) << hex
237237
<< static_cast<unsigned short>(data_[i]);
238238
}
239-
if (!data_.size()) {
240-
output << "(no data)";
239+
if (data_.empty()) {
240+
output << "''";
241241
} else if (str::isPrintable(data_)) {
242242
std::string printable(data_.cbegin(), data_.cend());
243-
output << " (" << printable << ")";
243+
output << " '" << printable << "'";
244244
}
245245

246246
// Append suboptions.

src/lib/dhcp/option_custom.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -403,12 +403,12 @@ OptionCustom::dataFieldToText(const OptionDataType data_type,
403403
{
404404
auto data = readBinary(index);
405405
if (data.empty()) {
406-
text << "(no data)";
406+
text << "''";
407407
} else {
408408
text << util::encode::encodeHex(data);
409409
if (str::isPrintable(data)) {
410410
std::string printable(data.cbegin(), data.cend());
411-
text << " (" << printable << ") ";
411+
text << " '" << printable << "'";
412412
}
413413
}
414414
break;

src/lib/dhcp/tests/pkt4_unittest.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -1301,10 +1301,10 @@ TEST_F(Pkt4Test, toText) {
13011301
" type=087, len=011: \"lorem ipsum\" (string)\n"
13021302
" type=123, len=004: 192.0.2.3\n"
13031303
" type=156, len=004: 123456 (uint32)\n"
1304-
" type=231, len=021: 61:62:63:64:65:66 (abcdef),\n"
1304+
" type=231, len=020: 61:62:63:64:65:66 'abcdef',\n"
13051305
"options:\n"
1306-
" type=001, len=011: 30:31:32:33:34:35:36:37:38:39 (0123456789)\n"
1307-
" type=002, len=000: (no data)",
1306+
" type=001, len=010: 30:31:32:33:34:35:36:37:38:39 '0123456789'\n"
1307+
" type=002, len=000: ''",
13081308
pkt.toText());
13091309

13101310
// Now remove all options, including Message Type and check if the

src/lib/dhcp/tests/pkt6_unittest.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -1297,12 +1297,12 @@ TEST_F(Pkt6Test, toText) {
12971297
"2 relay(s):\n"
12981298
"relay[0]: msg-type=12(RELAY_FORWARD), hop-count=1,\n"
12991299
"link-address=2001:888:db8:1::, peer-address=fe80::200:21ff:fe5c:18a9, 2 option(s)\n"
1300-
"type=00018, len=00028: 49:53:41:4d:31:34:34:7c:32:39:39:7c:69:70:76:36:7c:6e:74:3a:76:70:3a:31:3a:31:31:30 (ISAM144|299|ipv6|nt:vp:1:110)\n"
1300+
"type=00018, len=00028: 49:53:41:4d:31:34:34:7c:32:39:39:7c:69:70:76:36:7c:6e:74:3a:76:70:3a:31:3a:31:31:30 'ISAM144|299|ipv6|nt:vp:1:110'\n"
13011301
"type=00037, len=00018: 6527 (uint32) 0001000118B033410000215C18A9 (binary)\n"
13021302
"relay[1]: msg-type=12(RELAY_FORWARD), hop-count=0,\n"
13031303
"link-address=::, peer-address=fe80::200:21ff:fe5c:18a9, 2 option(s)\n"
1304-
"type=00018, len=00021: 49:53:41:4d:31:34:34:20:65:74:68:20:31:2f:31:2f:30:35:2f:30:31 (ISAM144 eth 1/1/05/01)\n"
1305-
"type=00037, len=00004: 3561 (uint32) (no data) (binary)\n";
1304+
"type=00018, len=00021: 49:53:41:4d:31:34:34:20:65:74:68:20:31:2f:31:2f:30:35:2f:30:31 'ISAM144 eth 1/1/05/01'\n"
1305+
"type=00037, len=00004: 3561 (uint32) '' (binary)\n";
13061306

13071307
EXPECT_EQ(expected, msg->toText());
13081308
}

0 commit comments

Comments
 (0)