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

Side by Side Diff: base/memory/scoped_ptr_unittest.cc

Issue 935333002: Update from https://crrev.com/316786 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « base/memory/scoped_ptr.h ('k') | base/message_loop/message_loop.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 "base/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 6
7 #include <sstream>
8
7 #include "base/basictypes.h" 9 #include "base/basictypes.h"
8 #include "base/bind.h" 10 #include "base/bind.h"
9 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/strings/stringprintf.h"
10 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
11 14
12 namespace { 15 namespace {
13 16
14 // Used to test depth subtyping. 17 // Used to test depth subtyping.
15 class ConDecLoggerParent { 18 class ConDecLoggerParent {
16 public: 19 public:
17 virtual ~ConDecLoggerParent() {} 20 virtual ~ConDecLoggerParent() {}
18 21
19 virtual void SetPtr(int* ptr) = 0; 22 virtual void SetPtr(int* ptr) = 0;
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 struct NoOpDeleter { 674 struct NoOpDeleter {
672 #if !defined(NDEBUG) 675 #if !defined(NDEBUG)
673 typedef void AllowSelfReset; 676 typedef void AllowSelfReset;
674 #endif 677 #endif
675 inline void operator()(int*) {} 678 inline void operator()(int*) {}
676 }; 679 };
677 scoped_ptr<int> owner(new int); 680 scoped_ptr<int> owner(new int);
678 scoped_ptr<int, NoOpDeleter> x(owner.get()); 681 scoped_ptr<int, NoOpDeleter> x(owner.get());
679 x.reset(x.get()); 682 x.reset(x.get());
680 } 683 }
684
685 // Logging a scoped_ptr<T> to an ostream shouldn't convert it to a boolean
686 // value first.
687 TEST(ScopedPtrTest, LoggingDoesntConvertToBoolean) {
688 scoped_ptr<int> x(new int);
689 std::stringstream s;
690 s << x;
691 std::string expected = base::StringPrintf("%p", x.get());
692 EXPECT_EQ(expected, s.str());
693 }
OLDNEW
« no previous file with comments | « base/memory/scoped_ptr.h ('k') | base/message_loop/message_loop.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698