Lines Matching refs:Pickle
9 #include "base/pickle.h"
25 void VerifyResult(const Pickle& pickle) {
29 EXPECT_TRUE(pickle.ReadInt(&iter, &outint));
33 EXPECT_TRUE(pickle.ReadString(&iter, &outstr));
37 EXPECT_TRUE(pickle.ReadWString(&iter, &outwstr));
41 EXPECT_TRUE(pickle.ReadBool(&iter, &outbool));
43 EXPECT_TRUE(pickle.ReadBool(&iter, &outbool));
47 EXPECT_TRUE(pickle.ReadUInt16(&iter, &outuint16));
52 EXPECT_TRUE(pickle.ReadData(&iter, &outdata, &outdatalen));
56 EXPECT_TRUE(pickle.ReadData(&iter, &outdata, &outdatalen));
61 EXPECT_FALSE(pickle.ReadInt(&iter, &outint));
67 Pickle pickle;
69 EXPECT_TRUE(pickle.WriteInt(testint));
70 EXPECT_TRUE(pickle.WriteString(teststr));
71 EXPECT_TRUE(pickle.WriteWString(testwstr));
72 EXPECT_TRUE(pickle.WriteBool(testbool1));
73 EXPECT_TRUE(pickle.WriteBool(testbool2));
74 EXPECT_TRUE(pickle.WriteUInt16(testuint16));
75 EXPECT_TRUE(pickle.WriteData(testdata, testdatalen));
78 char* dest = pickle.BeginWriteData(testdatalen + 100);
82 pickle.TrimWriteData(testdatalen);
84 VerifyResult(pickle);
87 Pickle pickle2(pickle);
91 Pickle pickle3;
92 pickle3 = pickle;
101 Pickle pickle(buffer.get(), 1);
105 EXPECT_FALSE(pickle.ReadInt(&iter, &data));
112 Pickle pickle(reinterpret_cast<char*>(buffer), sizeof(buffer));
116 EXPECT_FALSE(pickle.ReadInt(&iter, &data));
122 Pickle pickle(reinterpret_cast<char*>(buffer), sizeof(buffer));
126 EXPECT_FALSE(pickle.ReadInt(&iter, &data));
130 Pickle pickle;
131 EXPECT_TRUE(pickle.WriteString(""));
135 EXPECT_TRUE(pickle.ReadString(&iter, &outstr));
140 Pickle pickle;
141 EXPECT_TRUE(pickle.WriteWString(L""));
145 EXPECT_TRUE(pickle.ReadString(&iter, &outstr));
150 Pickle pickle;
151 EXPECT_TRUE(pickle.WriteInt(-2));
155 EXPECT_FALSE(pickle.ReadString(&iter, &outstr));
159 Pickle pickle;
160 EXPECT_TRUE(pickle.WriteInt(-1));
164 EXPECT_FALSE(pickle.ReadWString(&iter, &woutstr));
168 Pickle pickle;
169 EXPECT_TRUE(pickle.WriteInt(1));
170 EXPECT_TRUE(pickle.WriteString("Domo"));
172 const char* start = reinterpret_cast<const char*>(pickle.data());
173 const char* end = start + pickle.size();
175 EXPECT_TRUE(end == Pickle::FindNext(pickle.header_size_, start, end));
176 EXPECT_TRUE(NULL == Pickle::FindNext(pickle.header_size_, start, end - 1));
177 EXPECT_TRUE(end == Pickle::FindNext(pickle.header_size_, start, end + 1));
181 size_t header_size = sizeof(Pickle::Header);
188 EXPECT_TRUE(NULL == Pickle::FindNext(header_size, start, end));
192 Pickle pickle;
193 EXPECT_TRUE(pickle.WriteInt(1));
194 EXPECT_TRUE(pickle.WriteInt(2));
197 EXPECT_FALSE(pickle.IteratorHasRoomFor(iter, 1));
198 iter = pickle.payload();
199 EXPECT_TRUE(pickle.IteratorHasRoomFor(iter, 0));
200 EXPECT_TRUE(pickle.IteratorHasRoomFor(iter, 1));
201 EXPECT_FALSE(pickle.IteratorHasRoomFor(iter, -1));
202 EXPECT_TRUE(pickle.IteratorHasRoomFor(iter, sizeof(int) * 2));
203 EXPECT_FALSE(pickle.IteratorHasRoomFor(iter, (sizeof(int) * 2) + 1));
207 size_t unit = Pickle::kPayloadUnit;
216 Pickle pickle;
217 pickle.WriteData(data_ptr,
222 EXPECT_EQ(unit, pickle.capacity());
223 EXPECT_EQ(pickle.payload_size(), payload_size_after_header);
226 pickle.WriteData(data_ptr, static_cast<int>(unit - sizeof(uint32)));
228 EXPECT_EQ(unit * 2, pickle.capacity());
229 EXPECT_EQ(cur_payload, pickle.payload_size());
232 pickle.WriteData(data_ptr, 1);
234 EXPECT_EQ(unit * 4, pickle.capacity());
235 EXPECT_EQ(cur_payload, pickle.payload_size());
240 struct CustomHeader : Pickle::Header {
249 Pickle pickle(sizeof(CustomHeader));
250 pickle.WriteInt(kMagic);
253 pickle.headerT<CustomHeader>()->blah = 10;
257 ASSERT_TRUE(pickle.ReadInt(&iter, &result));
263 Pickle source;
266 Pickle copy_refs_source_buffer(static_cast<const char*>(source.data()),
268 Pickle copy;
274 Pickle source;
285 Pickle str16_pickle;
292 Pickle big_len;
301 Pickle pickle;
302 EXPECT_TRUE(pickle.WriteData(NULL, 0));
307 EXPECT_TRUE(pickle.ReadData(&iter, &outdata, &outdatalen));
314 Pickle pickle;
316 EXPECT_TRUE(pickle.WriteBytes(&data, sizeof(data)));
320 EXPECT_TRUE(pickle.ReadBytes(&iter, &outdata_char, sizeof(data)));