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

Side by Side Diff: base/stl_util_unittest.cc

Issue 862133002: Update from https://crrev.com/312398 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "base/stl_util.h" 5 #include "base/stl_util.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 a3.insert(5); 231 a3.insert(5);
232 232
233 EXPECT_TRUE(STLIncludes<std::set<int> >(a1, a2)); 233 EXPECT_TRUE(STLIncludes<std::set<int> >(a1, a2));
234 EXPECT_FALSE(STLIncludes<std::set<int> >(a1, a3)); 234 EXPECT_FALSE(STLIncludes<std::set<int> >(a1, a3));
235 EXPECT_FALSE(STLIncludes<std::set<int> >(a2, a1)); 235 EXPECT_FALSE(STLIncludes<std::set<int> >(a2, a1));
236 EXPECT_FALSE(STLIncludes<std::set<int> >(a2, a3)); 236 EXPECT_FALSE(STLIncludes<std::set<int> >(a2, a3));
237 EXPECT_FALSE(STLIncludes<std::set<int> >(a3, a1)); 237 EXPECT_FALSE(STLIncludes<std::set<int> >(a3, a1));
238 EXPECT_TRUE(STLIncludes<std::set<int> >(a3, a2)); 238 EXPECT_TRUE(STLIncludes<std::set<int> >(a3, a2));
239 } 239 }
240 240
241 TEST(StringAsArrayTest, Empty) {
242 std::string empty;
243 EXPECT_EQ(nullptr, string_as_array(&empty));
244 }
245
246 TEST(StringAsArrayTest, NullTerminated) {
247 // If any std::string implementation is not null-terminated, this should
248 // fail. All compilers we use return a null-terminated buffer, but please do
249 // not rely on this fact in your code.
250 std::string str("abcde");
251 str.resize(3);
252 EXPECT_STREQ("abc", string_as_array(&str));
253 }
254
255 TEST(StringAsArrayTest, WriteCopy) {
256 // With a COW implementation, this test will fail if
257 // string_as_array(&str) is implemented as
258 // const_cast<char*>(str->data()).
259 std::string s1("abc");
260 const std::string s2(s1);
261 string_as_array(&s1)[1] = 'x';
262 EXPECT_EQ("axc", s1);
263 EXPECT_EQ("abc", s2);
264 }
265
241 } // namespace 266 } // namespace
242 } // namespace base 267 } // namespace base
OLDNEW
« no previous file with comments | « base/process/process_win.cc ('k') | base/test/gtest_util.h » ('j') | shell/BUILD.gn » ('J')

Powered by Google App Engine
This is Rietveld 408576698