Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Unified Diff: components/rappor/byte_vector_utils_unittest.cc

Issue 1112003002: Use 64 bit shift when convert uint64_t to ByteVector (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/rappor/byte_vector_utils_unittest.cc
diff --git a/components/rappor/byte_vector_utils_unittest.cc b/components/rappor/byte_vector_utils_unittest.cc
index 672fa8d6626a5b0b8d001a3a98337b47da6e6af6..851cc159e72e555f7a3bcea2d9849fdb138468ee 100644
--- a/components/rappor/byte_vector_utils_unittest.cc
+++ b/components/rappor/byte_vector_utils_unittest.cc
@@ -26,6 +26,21 @@ std::string HexToString(const char* hex) {
} // namespace
+TEST(ByteVectorTest, Uint64ToByteVectorSmall) {
+ ByteVector bytes(1);
+ Uint64ToByteVector(0x10, 1, &bytes);
+ EXPECT_EQ(1u, bytes.size());
+ EXPECT_EQ(0x10, bytes[0]);
+}
+
+TEST(ByteVectorTest, Uint64ToByteVectorLarge) {
+ ByteVector bytes(8);
+ Uint64ToByteVector(0xfedcba9876543210, 8, &bytes);
+ EXPECT_EQ(8u, bytes.size());
+ EXPECT_EQ(0x10, bytes[0]);
+ EXPECT_EQ(0xfe, bytes[7]);
+}
+
TEST(ByteVectorTest, ByteVectorAnd) {
ByteVector lhs(2);
lhs[1] = 0x12;

Powered by Google App Engine
This is Rietveld 408576698