Commit 9045fd9d authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[master] Merge branch 'trac3959'

parents bc9b37ad 1fd41f5e
......@@ -262,7 +262,20 @@ public:
std::string data_type = OptionDataTypeUtil::getDataTypeName(OptionDataTypeTraits<T>::type);
for (typename std::vector<T>::const_iterator value = values_.begin();
value != values_.end(); ++value) {
output << " " << *value << "(" << data_type << ")";
output << " ";
// For 1 byte long data types we need to cast to the integer
// because they are usually implemented as "char" types, in
// which case the character rather than number would be printed.
if (OptionDataTypeTraits<T>::len == 1) {
output << static_cast<int>(*value);
} else {
output << *value;
}
// Append data type.
output << "(" << data_type << ")";
}
return (output.str());
......
......@@ -476,4 +476,18 @@ TEST_F(OptionIntArrayTest, toText) {
option.toText());
}
// This test checks that the option holding multiple uint8 values
// is correctly converted to the textual format.
TEST_F(OptionIntArrayTest, toTextUint8) {
OptionUint8Array option(Option::V4, 128);
option.addValue(1);
option.addValue(7);
option.addValue(15);
EXPECT_EQ("type=128, len=003: 1(uint8) 7(uint8) 15(uint8)",
option.toText());
}
} // anonymous namespace
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment