Home | History | Annotate | Download | only in base

Lines Matching defs:pickle

9 #include "base/pickle.h"
29 void VerifyResult(const Pickle& pickle) {
30 PickleIterator iter(pickle);
33 EXPECT_TRUE(pickle.ReadInt(&iter, &outint));
37 EXPECT_TRUE(pickle.ReadString(&iter, &outstr));
41 EXPECT_TRUE(pickle.ReadWString(&iter, &outwstr));
45 EXPECT_TRUE(pickle.ReadBool(&iter, &outbool));
47 EXPECT_TRUE(pickle.ReadBool(&iter, &outbool));
51 EXPECT_TRUE(pickle.ReadUInt16(&iter, &outuint16));
55 EXPECT_TRUE(pickle.ReadFloat(&iter, &outfloat));
60 EXPECT_TRUE(pickle.ReadData(&iter, &outdata, &outdatalen));
65 EXPECT_FALSE(pickle.ReadInt(&iter, &outint));
71 Pickle pickle;
73 EXPECT_TRUE(pickle.WriteInt(testint));
74 EXPECT_TRUE(pickle.WriteString(teststr));
75 EXPECT_TRUE(pickle.WriteWString(testwstr));
76 EXPECT_TRUE(pickle.WriteBool(testbool1));
77 EXPECT_TRUE(pickle.WriteBool(testbool2));
78 EXPECT_TRUE(pickle.WriteUInt16(testuint16));
79 EXPECT_TRUE(pickle.WriteFloat(testfloat));
80 EXPECT_TRUE(pickle.WriteData(testdata, testdatalen));
81 VerifyResult(pickle);
84 Pickle pickle2(pickle);
88 Pickle pickle3;
89 pickle3 = pickle;
98 Pickle pickle(buffer.get(), 1);
100 PickleIterator iter(pickle);
102 EXPECT_FALSE(pickle.ReadInt(&iter, &data));
109 Pickle pickle(reinterpret_cast<char*>(buffer), sizeof(buffer));
111 PickleIterator iter(pickle);
113 EXPECT_FALSE(pickle.ReadInt(&iter, &data));
119 Pickle pickle(reinterpret_cast<char*>(buffer), sizeof(buffer));
121 PickleIterator iter(pickle);
123 EXPECT_FALSE(pickle.ReadInt(&iter, &data));
127 Pickle pickle;
128 EXPECT_TRUE(pickle.WriteString(std::string()));
130 PickleIterator iter(pickle);
132 EXPECT_TRUE(pickle.ReadString(&iter, &outstr));
137 Pickle pickle;
138 EXPECT_TRUE(pickle.WriteWString(std::wstring()));
140 PickleIterator iter(pickle);
142 EXPECT_TRUE(pickle.ReadString(&iter, &outstr));
147 Pickle pickle;
148 EXPECT_TRUE(pickle.WriteInt(-2));
150 PickleIterator iter(pickle);
152 EXPECT_FALSE(pickle.ReadString(&iter, &outstr));
156 Pickle pickle;
157 EXPECT_TRUE(pickle.WriteInt(-1));
159 PickleIterator iter(pickle);
161 EXPECT_FALSE(pickle.ReadWString(&iter, &woutstr));
165 Pickle pickle;
166 EXPECT_TRUE(pickle.WriteInt(1));
167 EXPECT_TRUE(pickle.WriteString("Domo"));
169 const char* start = reinterpret_cast<const char*>(pickle.data());
170 const char* end = start + pickle.size();
172 EXPECT_TRUE(end == Pickle::FindNext(pickle.header_size_, start, end));
173 EXPECT_TRUE(NULL == Pickle::FindNext(pickle.header_size_, start, end - 1));
174 EXPECT_TRUE(end == Pickle::FindNext(pickle.header_size_, start, end + 1));
178 size_t header_size = sizeof(Pickle::Header);
185 EXPECT_TRUE(NULL == Pickle::FindNext(header_size, start, end));
193 size_t header_size = sizeof(Pickle::Header);
198 Pickle::Header* header = reinterpret_cast<Pickle::Header*>(buffer.get());
206 EXPECT_TRUE(NULL == Pickle::FindNext(header_size2, start, end));
209 EXPECT_TRUE(NULL == Pickle::FindNext(header_size2, start, end));
213 EXPECT_TRUE(NULL == Pickle::FindNext(header_size2, start, end));
220 Pickle pickle;
222 PickleIterator iter(pickle);
225 EXPECT_TRUE(pickle.WriteInt(1));
226 EXPECT_TRUE(pickle.WriteInt(2));
229 EXPECT_TRUE(PickleIterator(pickle).GetReadPointerAndAdvance(0));
230 EXPECT_TRUE(PickleIterator(pickle).GetReadPointerAndAdvance(1));
231 EXPECT_FALSE(PickleIterator(pickle).GetReadPointerAndAdvance(-1));
232 EXPECT_TRUE(PickleIterator(pickle).GetReadPointerAndAdvance(bytes));
233 EXPECT_FALSE(PickleIterator(pickle).GetReadPointerAndAdvance(bytes + 1));
234 EXPECT_FALSE(PickleIterator(pickle).GetReadPointerAndAdvance(INT_MAX));
235 EXPECT_FALSE(PickleIterator(pickle).GetReadPointerAndAdvance(INT_MIN));
239 size_t unit = Pickle::kPayloadUnit;
248 Pickle pickle;
249 pickle.WriteData(data_ptr,
254 EXPECT_EQ(unit, pickle.capacity_after_header());
255 EXPECT_EQ(pickle.payload_size(), payload_size_after_header);
258 pickle.WriteData(data_ptr, static_cast<int>(unit - sizeof(uint32)));
260 EXPECT_EQ(unit * 2, pickle.capacity_after_header());
261 EXPECT_EQ(cur_payload, pickle.payload_size());
264 pickle.WriteData(data_ptr, 1);
266 EXPECT_EQ(unit * 4, pickle.capacity_after_header());
267 EXPECT_EQ(cur_payload, pickle.payload_size());
272 struct CustomHeader : Pickle::Header {
281 Pickle pickle(sizeof(CustomHeader));
282 pickle.WriteInt(kMagic);
285 pickle.headerT<CustomHeader>()->blah = 10;
287 PickleIterator iter(pickle);
289 ASSERT_TRUE(pickle.ReadInt(&iter, &result));
295 Pickle source;
298 Pickle copy_refs_source_buffer(static_cast<const char*>(source.data()),
300 Pickle copy;
306 Pickle source;
317 Pickle str16_pickle;
325 Pickle bad_len;
331 Pickle big_len;
340 Pickle pickle;
341 EXPECT_TRUE(pickle.WriteData(NULL, 0));
343 PickleIterator iter(pickle);
346 EXPECT_TRUE(pickle.ReadData(&iter, &outdata, &outdatalen));
353 Pickle pickle;
355 EXPECT_TRUE(pickle.WriteBytes(&data, sizeof(data)));
357 PickleIterator iter(pickle);
359 EXPECT_TRUE(pickle.ReadBytes(&iter, &outdata_char, sizeof(data)));