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

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

Issue 599313003: Add nullptr support to scoped_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« base/memory/scoped_ptr.h ('K') | « base/memory/scoped_ptr.h ('k') | no next file » | 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 "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 { 595 {
596 OverloadedNewAndDelete::ResetCounters(); 596 OverloadedNewAndDelete::ResetCounters();
597 scoped_ptr<OverloadedNewAndDelete> scoper(new OverloadedNewAndDelete()); 597 scoped_ptr<OverloadedNewAndDelete> scoper(new OverloadedNewAndDelete());
598 EXPECT_TRUE(scoper.get()); 598 EXPECT_TRUE(scoper.get());
599 599
600 scoped_ptr<OverloadedNewAndDelete> scoper2(scoper.Pass()); 600 scoped_ptr<OverloadedNewAndDelete> scoper2(scoper.Pass());
601 } 601 }
602 EXPECT_EQ(1, OverloadedNewAndDelete::delete_count()); 602 EXPECT_EQ(1, OverloadedNewAndDelete::delete_count());
603 EXPECT_EQ(1, OverloadedNewAndDelete::new_count()); 603 EXPECT_EQ(1, OverloadedNewAndDelete::new_count());
604 } 604 }
605
606 scoped_ptr<int> NullIntReturn() {
607 return nullptr;
608 }
609
610 TEST(ScopedPtrTest, Nullptr) {
611 scoped_ptr<int> scoper1(nullptr);
612 scoped_ptr<int> scoper2(new int);
613 scoper2 = nullptr;
614 scoped_ptr<int> scoper3(NullIntReturn());
615 scoped_ptr<int> scoper4 = NullIntReturn();
616 EXPECT_EQ(nullptr, scoper1.get());
617 EXPECT_EQ(nullptr, scoper2.get());
618 EXPECT_EQ(nullptr, scoper3.get());
619 EXPECT_EQ(nullptr, scoper4.get());
620 }
621
622 scoped_ptr<int[]> NullIntArrayReturn() {
623 return nullptr;
624 }
625
626 TEST(ScopedPtrTest, NullptrArray) {
627 scoped_ptr<int[]> scoper1(nullptr);
628 scoped_ptr<int[]> scoper2(new int);
629 scoper2 = nullptr;
630 scoped_ptr<int[]> scoper3(NullIntArrayReturn());
631 scoped_ptr<int[]> scoper4 = NullIntArrayReturn();
632 EXPECT_EQ(nullptr, scoper1.get());
633 EXPECT_EQ(nullptr, scoper2.get());
634 EXPECT_EQ(nullptr, scoper3.get());
635 EXPECT_EQ(nullptr, scoper4.get());
636 }
OLDNEW
« base/memory/scoped_ptr.h ('K') | « base/memory/scoped_ptr.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698