Lines Matching refs:Pickle
9 #include "base/pickle.h"
26 void VerifyResult(const Pickle& pickle) {
27 PickleIterator iter(pickle);
30 EXPECT_TRUE(pickle.ReadInt(&iter, &outint));
34 EXPECT_TRUE(pickle.ReadString(&iter, &outstr));
38 EXPECT_TRUE(pickle.ReadWString(&iter, &outwstr));
42 EXPECT_TRUE(pickle.ReadBool(&iter, &outbool));
44 EXPECT_TRUE(pickle.ReadBool(&iter, &outbool));
48 EXPECT_TRUE(pickle.ReadUInt16(&iter, &outuint16));
52 EXPECT_TRUE(pickle.ReadFloat(&iter, &outfloat));
57 EXPECT_TRUE(pickle.ReadData(&iter, &outdata, &outdatalen));
61 EXPECT_TRUE(pickle.ReadData(&iter, &outdata, &outdatalen));
66 EXPECT_FALSE(pickle.ReadInt(&iter, &outint));
72 Pickle pickle;
74 EXPECT_TRUE(pickle.WriteInt(testint));
75 EXPECT_TRUE(pickle.WriteString(teststr));
76 EXPECT_TRUE(pickle.WriteWString(testwstr));
77 EXPECT_TRUE(pickle.WriteBool(testbool1));
78 EXPECT_TRUE(pickle.WriteBool(testbool2));
79 EXPECT_TRUE(pickle.WriteUInt16(testuint16));
80 EXPECT_TRUE(pickle.WriteFloat(testfloat));
81 EXPECT_TRUE(pickle.WriteData(testdata, testdatalen));
84 char* dest = pickle.BeginWriteData(testdatalen + 100);
88 pickle.TrimWriteData(testdatalen);
90 VerifyResult(pickle);
93 Pickle pickle2(pickle);
97 Pickle pickle3;
98 pickle3 = pickle;
107 Pickle pickle(buffer.get(), 1);
109 PickleIterator iter(pickle);
111 EXPECT_FALSE(pickle.ReadInt(&iter, &data));
118 Pickle pickle(reinterpret_cast<char*>(buffer), sizeof(buffer));
120 PickleIterator iter(pickle);
122 EXPECT_FALSE(pickle.ReadInt(&iter, &data));
128 Pickle pickle(reinterpret_cast<char*>(buffer), sizeof(buffer));
130 PickleIterator iter(pickle);
132 EXPECT_FALSE(pickle.ReadInt(&iter, &data));
136 Pickle pickle;
137 EXPECT_TRUE(pickle.WriteString(std::string()));
139 PickleIterator iter(pickle);
141 EXPECT_TRUE(pickle.ReadString(&iter, &outstr));
146 Pickle pickle;
147 EXPECT_TRUE(pickle.WriteWString(std::wstring()));
149 PickleIterator iter(pickle);
151 EXPECT_TRUE(pickle.ReadString(&iter, &outstr));
156 Pickle pickle;
157 EXPECT_TRUE(pickle.WriteInt(-2));
159 PickleIterator iter(pickle);
161 EXPECT_FALSE(pickle.ReadString(&iter, &outstr));
165 Pickle pickle;
166 EXPECT_TRUE(pickle.WriteInt(-1));
168 PickleIterator iter(pickle);
170 EXPECT_FALSE(pickle.ReadWString(&iter, &woutstr));
174 Pickle pickle;
175 EXPECT_TRUE(pickle.WriteInt(1));
176 EXPECT_TRUE(pickle.WriteString("Domo"));
178 const char* start = reinterpret_cast<const char*>(pickle.data());
179 const char* end = start + pickle.size();
181 EXPECT_TRUE(end == Pickle::FindNext(pickle.header_size_, start, end));
182 EXPECT_TRUE(NULL == Pickle::FindNext(pickle.header_size_, start, end - 1));
183 EXPECT_TRUE(end == Pickle::FindNext(pickle.header_size_, start, end + 1));
187 size_t header_size = sizeof(Pickle::Header);
194 EXPECT_TRUE(NULL == Pickle::FindNext(header_size, start, end));
198 Pickle pickle;
200 PickleIterator iter(pickle);
203 EXPECT_TRUE(pickle.WriteInt(1));
204 EXPECT_TRUE(pickle.WriteInt(2));
207 EXPECT_TRUE(PickleIterator(pickle).GetReadPointerAndAdvance(0));
208 EXPECT_TRUE(PickleIterator(pickle).GetReadPointerAndAdvance(1));
209 EXPECT_FALSE(PickleIterator(pickle).GetReadPointerAndAdvance(-1));
210 EXPECT_TRUE(PickleIterator(pickle).GetReadPointerAndAdvance(bytes));
211 EXPECT_FALSE(PickleIterator(pickle).GetReadPointerAndAdvance(bytes + 1));
212 EXPECT_FALSE(PickleIterator(pickle).GetReadPointerAndAdvance(INT_MAX));
213 EXPECT_FALSE(PickleIterator(pickle).GetReadPointerAndAdvance(INT_MIN));
217 size_t unit = Pickle::kPayloadUnit;
226 Pickle pickle;
227 pickle.WriteData(data_ptr,
232 EXPECT_EQ(unit, pickle.capacity());
233 EXPECT_EQ(pickle.payload_size(), payload_size_after_header);
236 pickle.WriteData(data_ptr, static_cast<int>(unit - sizeof(uint32)));
238 EXPECT_EQ(unit * 2, pickle.capacity());
239 EXPECT_EQ(cur_payload, pickle.payload_size());
242 pickle.WriteData(data_ptr, 1);
244 EXPECT_EQ(unit * 4, pickle.capacity());
245 EXPECT_EQ(cur_payload, pickle.payload_size());
250 struct CustomHeader : Pickle::Header {
259 Pickle pickle(sizeof(CustomHeader));
260 pickle.WriteInt(kMagic);
263 pickle.headerT<CustomHeader>()->blah = 10;
265 PickleIterator iter(pickle);
267 ASSERT_TRUE(pickle.ReadInt(&iter, &result));
273 Pickle source;
276 Pickle copy_refs_source_buffer(static_cast<const char*>(source.data()),
278 Pickle copy;
284 Pickle source;
295 Pickle str16_pickle;
303 Pickle bad_len;
309 Pickle big_len;
318 Pickle pickle;
319 EXPECT_TRUE(pickle.WriteData(NULL, 0));
321 PickleIterator iter(pickle);
324 EXPECT_TRUE(pickle.ReadData(&iter, &outdata, &outdatalen));
331 Pickle pickle;
333 EXPECT_TRUE(pickle.WriteBytes(&data, sizeof(data)));
335 PickleIterator iter(pickle);
337 EXPECT_TRUE(pickle.ReadBytes(&iter, &outdata_char, sizeof(data)));