| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/tracing/core/proto_utils.h" | 5 #include "components/tracing/core/proto_utils.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 0x100000000000000); | 107 0x100000000000000); |
| 108 EXPECT_VARINT64_EQ("\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x7F", 9, | 108 EXPECT_VARINT64_EQ("\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x7F", 9, |
| 109 0x7FFFFFFFFFFFFFFF); | 109 0x7FFFFFFFFFFFFFFF); |
| 110 EXPECT_VARINT64_EQ("\x80\x80\x80\x80\x80\x80\x80\x80\x80\x01", 10, | 110 EXPECT_VARINT64_EQ("\x80\x80\x80\x80\x80\x80\x80\x80\x80\x01", 10, |
| 111 0x8000000000000000); | 111 0x8000000000000000); |
| 112 EXPECT_VARINT64_EQ("\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x01", 10, | 112 EXPECT_VARINT64_EQ("\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x01", 10, |
| 113 0xFFFFFFFFFFFFFFFF); | 113 0xFFFFFFFFFFFFFFFF); |
| 114 | 114 |
| 115 uint8_t buf[kMessageLengthFieldSize]; | 115 uint8_t buf[kMessageLengthFieldSize]; |
| 116 | 116 |
| 117 WriteRedundantLength(0, buf); | 117 WriteRedundantVarInt(0, buf); |
| 118 EXPECT_EQ(0, memcmp("\x80\x80\x80\x00", buf, sizeof(buf))); | 118 EXPECT_EQ(0, memcmp("\x80\x80\x80\x00", buf, sizeof(buf))); |
| 119 | 119 |
| 120 WriteRedundantLength(1, buf); | 120 WriteRedundantVarInt(1, buf); |
| 121 EXPECT_EQ(0, memcmp("\x81\x80\x80\x00", buf, sizeof(buf))); | 121 EXPECT_EQ(0, memcmp("\x81\x80\x80\x00", buf, sizeof(buf))); |
| 122 | 122 |
| 123 WriteRedundantLength(0x80, buf); | 123 WriteRedundantVarInt(0x80, buf); |
| 124 EXPECT_EQ(0, memcmp("\x80\x81\x80\x00", buf, sizeof(buf))); | 124 EXPECT_EQ(0, memcmp("\x80\x81\x80\x00", buf, sizeof(buf))); |
| 125 | 125 |
| 126 WriteRedundantLength(0x332211, buf); | 126 WriteRedundantVarInt(0x332211, buf); |
| 127 EXPECT_EQ(0, memcmp("\x91\xC4\xCC\x01", buf, sizeof(buf))); | 127 EXPECT_EQ(0, memcmp("\x91\xC4\xCC\x01", buf, sizeof(buf))); |
| 128 | 128 |
| 129 // Largest allowed length. | 129 // Largest allowed length. |
| 130 WriteRedundantLength(0x0FFFFFFF, buf); | 130 WriteRedundantVarInt(0x0FFFFFFF, buf); |
| 131 EXPECT_EQ(0, memcmp("\xFF\xFF\xFF\x7F", buf, sizeof(buf))); | 131 EXPECT_EQ(0, memcmp("\xFF\xFF\xFF\x7F", buf, sizeof(buf))); |
| 132 } | 132 } |
| 133 | 133 |
| 134 } // namespace | 134 } // namespace |
| 135 } // namespace proto | 135 } // namespace proto |
| 136 } // namespace v2 | 136 } // namespace v2 |
| 137 } // namespace tracing | 137 } // namespace tracing |
| OLD | NEW |