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

Side by Side Diff: base/bind_helpers_unittest.cc

Issue 2250373002: Readd base::UnwrapTraits to support rvalue-reference wrappers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@20_oneshot
Patch Set: rebase Created 4 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
« no previous file with comments | « base/bind_helpers.h ('k') | third_party/WebKit/Source/wtf/Functional.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/bind_helpers.h"
6
7 #include "base/memory/ptr_util.h"
8 #include "base/memory/ref_counted.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 namespace base {
12
13 TEST(BindHelpersTest, UnwrapUnretained) {
14 int i = 0;
15 auto unretained = Unretained(&i);
16 EXPECT_EQ(&i, internal::Unwrap(unretained));
17 EXPECT_EQ(&i, internal::Unwrap(std::move(unretained)));
18 }
19
20 TEST(BindHelpersTest, UnwrapConstRef) {
21 int p = 0;
22 auto const_ref = ConstRef(p);
23 EXPECT_EQ(&p, &internal::Unwrap(const_ref));
24 EXPECT_EQ(&p, &internal::Unwrap(std::move(const_ref)));
25 }
26
27 TEST(BindHelpersTest, UnwrapRetainedRef) {
28 auto p = make_scoped_refptr(new RefCountedData<int>);
29 auto retained_ref = RetainedRef(p);
30 EXPECT_EQ(p.get(), internal::Unwrap(retained_ref));
31 EXPECT_EQ(p.get(), internal::Unwrap(std::move(retained_ref)));
32 }
33
34 TEST(BindHelpersTest, UnwrapOwned) {
35 int* p = new int;
36 auto owned = Owned(p);
37 EXPECT_EQ(p, internal::Unwrap(owned));
38 EXPECT_EQ(p, internal::Unwrap(std::move(owned)));
39 }
40
41 TEST(BindHelpersTest, UnwrapPassed) {
42 int* p = new int;
43 auto passed = Passed(WrapUnique(p));
44 EXPECT_EQ(p, internal::Unwrap(passed).get());
45
46 p = new int;
47 EXPECT_EQ(p, internal::Unwrap(Passed(WrapUnique(p))).get());
48 }
49
50 } // namespace base
OLDNEW
« no previous file with comments | « base/bind_helpers.h ('k') | third_party/WebKit/Source/wtf/Functional.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698