OLD | NEW |
---|---|
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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <sstream> | 9 #include <sstream> |
10 #include <utility> | |
10 | 11 |
11 #include "base/bind.h" | 12 #include "base/bind.h" |
12 #include "base/callback.h" | 13 #include "base/callback.h" |
13 #include "base/macros.h" | 14 #include "base/macros.h" |
14 #include "build/build_config.h" | 15 #include "build/build_config.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
16 | 17 |
17 namespace { | 18 namespace { |
18 | 19 |
19 // Used to test depth subtyping. | 20 // Used to test depth subtyping. |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
405 #if !defined(OS_ANDROID) && !defined(OS_LINUX) | 406 #if !defined(OS_ANDROID) && !defined(OS_LINUX) |
406 // Test uncaught Pass() does not have side effects, because Pass() | 407 // Test uncaught Pass() does not have side effects, because Pass() |
407 // is implemented by std::move(). | 408 // is implemented by std::move(). |
408 // TODO(danakj): Remove this test case when we remove Pass(). | 409 // TODO(danakj): Remove this test case when we remove Pass(). |
409 { | 410 { |
410 ConDecLogger* logger = new ConDecLogger(&constructed); | 411 ConDecLogger* logger = new ConDecLogger(&constructed); |
411 scoped_ptr<ConDecLogger> scoper(logger); | 412 scoped_ptr<ConDecLogger> scoper(logger); |
412 EXPECT_EQ(1, constructed); | 413 EXPECT_EQ(1, constructed); |
413 | 414 |
414 // Should auto-destruct logger by end of scope. | 415 // Should auto-destruct logger by end of scope. |
415 scoped_ptr<ConDecLogger>&& rvalue = scoper.Pass(); | 416 scoped_ptr<ConDecLogger>&& rvalue = std::move(scoper); |
dcheng
2016/01/14 00:37:51
Oops, this got included by accident. I've reverted
| |
416 // The Pass() function mimics std::move(), which does not have side-effects. | 417 // The Pass() function mimics std::move(), which does not have side-effects. |
417 EXPECT_TRUE(scoper.get()); | 418 EXPECT_TRUE(scoper.get()); |
418 EXPECT_TRUE(rvalue); | 419 EXPECT_TRUE(rvalue); |
419 } | 420 } |
420 EXPECT_EQ(0, constructed); | 421 EXPECT_EQ(0, constructed); |
421 #endif | 422 #endif |
422 | 423 |
423 // Test that passing to function which does nothing does not leak. | 424 // Test that passing to function which does nothing does not leak. |
424 { | 425 { |
425 ConDecLogger* logger = new ConDecLogger(&constructed); | 426 ConDecLogger* logger = new ConDecLogger(&constructed); |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
833 EXPECT_FALSE(p < nullptr); | 834 EXPECT_FALSE(p < nullptr); |
834 EXPECT_TRUE(nullptr < p); | 835 EXPECT_TRUE(nullptr < p); |
835 EXPECT_FALSE(pnull < nullptr); | 836 EXPECT_FALSE(pnull < nullptr); |
836 EXPECT_FALSE(nullptr < pnull); | 837 EXPECT_FALSE(nullptr < pnull); |
837 | 838 |
838 EXPECT_FALSE(p <= nullptr); | 839 EXPECT_FALSE(p <= nullptr); |
839 EXPECT_TRUE(nullptr <= p); | 840 EXPECT_TRUE(nullptr <= p); |
840 EXPECT_TRUE(pnull <= nullptr); | 841 EXPECT_TRUE(pnull <= nullptr); |
841 EXPECT_TRUE(nullptr <= pnull); | 842 EXPECT_TRUE(nullptr <= pnull); |
842 } | 843 } |
OLD | NEW |