Skip to content

Commit

Permalink
address tqchen comments
Browse files Browse the repository at this point in the history
  • Loading branch information
areusch committed Aug 17, 2020
1 parent 6e3358c commit 7b6c93e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/support/hexdump.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
namespace tvm {
namespace support {

void hexdump(const std::string& s, std::ostream& os) {
void HexDump(const std::string& s, std::ostream& os) {
os << std::hex << std::setfill('0') << std::right;

int addr_width = 4;
Expand Down
11 changes: 8 additions & 3 deletions src/support/hexdump.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,16 @@
namespace tvm {
namespace support {

void hexdump(const std::string& s, std::ostream& os);
/*! \brief generate a hexdump of some binary data.
* \param s Binary data to print.
* \param os stream that receives the hexdump.
*/
void HexDump(const std::string& s, std::ostream& os);

inline std::string hexdump(const std::string& s) {
/*! \brief return a string containing a hexdump of the data in s */
inline std::string HexDump(const std::string& s) {
std::stringstream ss;
hexdump(s, ss);
HexDump(s, ss);
return ss.str();
}

Expand Down
6 changes: 3 additions & 3 deletions tests/cpp/support_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@
namespace tvm {
namespace test {

TEST(HexDumpTests, Empty) { EXPECT_EQ("", ::tvm::support::hexdump("")); }
TEST(HexDumpTests, Empty) { EXPECT_EQ("", ::tvm::support::HexDump("")); }

TEST(HexDumpTests, Aligned) {
EXPECT_EQ(
"0000 01 23 45 67 89 ab cd ef 01 23 45 67 89 ab cd ef .#Eg.....#Eg....\n"
"0010 01 23 45 67 89 ab cd ef 01 23 45 67 89 ab cd ef .#Eg.....#Eg....\n",
::tvm::support::hexdump("\x01\x23\x45\x67\x89\xab\xcd\xef\x01\x23\x45\x67\x89\xab\xcd\xef"
::tvm::support::HexDump("\x01\x23\x45\x67\x89\xab\xcd\xef\x01\x23\x45\x67\x89\xab\xcd\xef"
"\x01\x23\x45\x67\x89\xab\xcd\xef\x01\x23\x45\x67\x89\xab\xcd\xef"));
}

TEST(HexDumpTests, Unaligned) {
EXPECT_EQ(
"0000 01 23 45 67 89 ab cd ef 01 23 45 67 89 ab cd ef .#Eg.....#Eg....\n"
"0010 01 23 45 67 89 ab cd ef 01 .#Eg.....\n",
::tvm::support::hexdump("\x01\x23\x45\x67\x89\xab\xcd\xef\x01\x23\x45\x67\x89\xab\xcd\xef"
::tvm::support::HexDump("\x01\x23\x45\x67\x89\xab\xcd\xef\x01\x23\x45\x67\x89\xab\xcd\xef"
"\x01\x23\x45\x67\x89\xab\xcd\xef\x01"));
}

Expand Down

0 comments on commit 7b6c93e

Please sign in to comment.