[PATCH] D50025: Don't ignore byte_order in Stream::PutMaxHex64
Raphael Isemann via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 1 10:13:24 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL338591: Don't ignore byte_order in Stream::PutMaxHex64 (authored by teemperor, committed by ).
Herald added a subscriber: llvm-commits.
Changed prior to commit:
https://reviews.llvm.org/D50025?vs=158563&id=158564#toc
Repository:
rL LLVM
https://reviews.llvm.org/D50025
Files:
lldb/trunk/source/Utility/Stream.cpp
lldb/trunk/unittests/Utility/StreamTest.cpp
Index: lldb/trunk/unittests/Utility/StreamTest.cpp
===================================================================
--- lldb/trunk/unittests/Utility/StreamTest.cpp
+++ lldb/trunk/unittests/Utility/StreamTest.cpp
@@ -187,6 +187,32 @@
EXPECT_EQ("0000000000000000", TakeValue());
}
+TEST_F(StreamTest, PutMaxHex64ByteOrderBig) {
+ std::size_t bytes;
+ bytes = s.PutMaxHex64(0x12U, 1, lldb::eByteOrderBig);
+ EXPECT_EQ(2U, bytes);
+ bytes = s.PutMaxHex64(0x1234U, 2, lldb::eByteOrderBig);
+ EXPECT_EQ(4U, bytes);
+ bytes = s.PutMaxHex64(0x12345678U, 4, lldb::eByteOrderBig);
+ EXPECT_EQ(8U, bytes);
+ bytes = s.PutMaxHex64(0x1234567890ABCDEFU, 8, lldb::eByteOrderBig);
+ EXPECT_EQ(16U, bytes);
+ EXPECT_EQ("121234123456781234567890abcdef", TakeValue());
+}
+
+TEST_F(StreamTest, PutMaxHex64ByteOrderLittle) {
+ std::size_t bytes;
+ bytes = s.PutMaxHex64(0x12U, 1, lldb::eByteOrderLittle);
+ EXPECT_EQ(2U, bytes);
+ bytes = s.PutMaxHex64(0x1234U, 2, lldb::eByteOrderLittle);
+ EXPECT_EQ(4U, bytes);
+ bytes = s.PutMaxHex64(0x12345678U, 4, lldb::eByteOrderLittle);
+ EXPECT_EQ(8U, bytes);
+ bytes = s.PutMaxHex64(0x1234567890ABCDEFU, 8, lldb::eByteOrderLittle);
+ EXPECT_EQ(16U, bytes);
+ EXPECT_EQ("12341278563412efcdab9078563412", TakeValue());
+}
+
//------------------------------------------------------------------------------
// Shift operator tests.
//------------------------------------------------------------------------------
Index: lldb/trunk/source/Utility/Stream.cpp
===================================================================
--- lldb/trunk/source/Utility/Stream.cpp
+++ lldb/trunk/source/Utility/Stream.cpp
@@ -427,11 +427,11 @@
case 1:
return PutHex8((uint8_t)uvalue);
case 2:
- return PutHex16((uint16_t)uvalue);
+ return PutHex16((uint16_t)uvalue, byte_order);
case 4:
- return PutHex32((uint32_t)uvalue);
+ return PutHex32((uint32_t)uvalue, byte_order);
case 8:
- return PutHex64(uvalue);
+ return PutHex64(uvalue, byte_order);
}
return 0;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50025.158564.patch
Type: text/x-patch
Size: 2040 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180801/94493a2a/attachment.bin>
More information about the llvm-commits
mailing list