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

Side by Side Diff: base/pickle_unittest.cc

Issue 13145003: Rewrite std::string("") to std::string(), Linux edition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ugh Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « base/nix/mime_util_xdg.cc ('k') | base/prefs/pref_change_registrar_unittest.cc » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <string> 5 #include <string>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/pickle.h" 9 #include "base/pickle.h"
10 #include "base/string16.h" 10 #include "base/string16.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 127
128 Pickle pickle(reinterpret_cast<char*>(buffer), sizeof(buffer)); 128 Pickle pickle(reinterpret_cast<char*>(buffer), sizeof(buffer));
129 129
130 PickleIterator iter(pickle); 130 PickleIterator iter(pickle);
131 int data; 131 int data;
132 EXPECT_FALSE(pickle.ReadInt(&iter, &data)); 132 EXPECT_FALSE(pickle.ReadInt(&iter, &data));
133 } 133 }
134 134
135 TEST(PickleTest, ZeroLenStr) { 135 TEST(PickleTest, ZeroLenStr) {
136 Pickle pickle; 136 Pickle pickle;
137 EXPECT_TRUE(pickle.WriteString("")); 137 EXPECT_TRUE(pickle.WriteString(std::string()));
138 138
139 PickleIterator iter(pickle); 139 PickleIterator iter(pickle);
140 std::string outstr; 140 std::string outstr;
141 EXPECT_TRUE(pickle.ReadString(&iter, &outstr)); 141 EXPECT_TRUE(pickle.ReadString(&iter, &outstr));
142 EXPECT_EQ("", outstr); 142 EXPECT_EQ("", outstr);
143 } 143 }
144 144
145 TEST(PickleTest, ZeroLenWStr) { 145 TEST(PickleTest, ZeroLenWStr) {
146 Pickle pickle; 146 Pickle pickle;
147 EXPECT_TRUE(pickle.WriteWString(L"")); 147 EXPECT_TRUE(pickle.WriteWString(std::wstring()));
148 148
149 PickleIterator iter(pickle); 149 PickleIterator iter(pickle);
150 std::string outstr; 150 std::string outstr;
151 EXPECT_TRUE(pickle.ReadString(&iter, &outstr)); 151 EXPECT_TRUE(pickle.ReadString(&iter, &outstr));
152 EXPECT_EQ("", outstr); 152 EXPECT_EQ("", outstr);
153 } 153 }
154 154
155 TEST(PickleTest, BadLenStr) { 155 TEST(PickleTest, BadLenStr) {
156 Pickle pickle; 156 Pickle pickle;
157 EXPECT_TRUE(pickle.WriteInt(-2)); 157 EXPECT_TRUE(pickle.WriteInt(-2));
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 EXPECT_TRUE(pickle.WriteBytes(&data, sizeof(data))); 333 EXPECT_TRUE(pickle.WriteBytes(&data, sizeof(data)));
334 334
335 PickleIterator iter(pickle); 335 PickleIterator iter(pickle);
336 const char* outdata_char = NULL; 336 const char* outdata_char = NULL;
337 EXPECT_TRUE(pickle.ReadBytes(&iter, &outdata_char, sizeof(data))); 337 EXPECT_TRUE(pickle.ReadBytes(&iter, &outdata_char, sizeof(data)));
338 338
339 int outdata; 339 int outdata;
340 memcpy(&outdata, outdata_char, sizeof(outdata)); 340 memcpy(&outdata, outdata_char, sizeof(outdata));
341 EXPECT_EQ(data, outdata); 341 EXPECT_EQ(data, outdata);
342 } 342 }
OLDNEW
« no previous file with comments | « base/nix/mime_util_xdg.cc ('k') | base/prefs/pref_change_registrar_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698