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

Side by Side Diff: components/tracing/core/proto_utils_unittest.cc

Issue 2271653004: Reland of tracing v2: Introduce TraceBufferWriter (https://codereview.chromium.org/2196663002) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix undefined behavior of move ctor that caused revert on Win Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « components/tracing/core/proto_utils.h ('k') | components/tracing/core/proto_zero_message.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « components/tracing/core/proto_utils.h ('k') | components/tracing/core/proto_zero_message.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698