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

Side by Side Diff: base/mac/bind_objc_block_unittest.mm

Issue 723343002: Update from https://crrev.com/304121 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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/mac/bind_objc_block.h ('k') | base/memory/scoped_ptr_unittest.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 #import "base/mac/bind_objc_block.h" 5 #import "base/mac/bind_objc_block.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 std::string result; 57 std::string result;
58 std::string* ptr = &result; 58 std::string* ptr = &result;
59 base::Callback<void(const std::string&, const std::string&)> c = 59 base::Callback<void(const std::string&, const std::string&)> c =
60 base::BindBlock(^(const std::string& a, const std::string& b) { 60 base::BindBlock(^(const std::string& a, const std::string& b) {
61 *ptr = a + b; 61 *ptr = a + b;
62 }); 62 });
63 c.Run("forty", "two"); 63 c.Run("forty", "two");
64 EXPECT_EQ(result, "fortytwo"); 64 EXPECT_EQ(result, "fortytwo");
65 } 65 }
66 66
67 TEST(BindObjcBlockTest, TestThreeArguments) {
68 std::string result;
69 std::string* ptr = &result;
70 base::Callback<void(const std::string&,
71 const std::string&,
72 const std::string&)> c =
73 base::BindBlock(^(const std::string& a,
74 const std::string& b,
75 const std::string& c) {
76 *ptr = a + b + c;
77 });
78 c.Run("six", "times", "nine");
79 EXPECT_EQ(result, "sixtimesnine");
80 }
81
82 TEST(BindObjcBlockTest, TestSixArguments) {
83 std::string result1;
84 std::string* ptr = &result1;
85 int result2;
86 int* ptr2 = &result2;
87 base::Callback<void(int, int, const std::string&, const std::string&,
88 int, const std::string&)> c =
89 base::BindBlock(^(int a, int b, const std::string& c,
90 const std::string& d, int e, const std::string& f) {
91 *ptr = c + d + f;
92 *ptr2 = a + b + e;
93 });
94 c.Run(1, 2, "infinite", "improbability", 3, "drive");
95 EXPECT_EQ(result1, "infiniteimprobabilitydrive");
96 EXPECT_EQ(result2, 6);
97 }
98
67 } // namespace 99 } // namespace
OLDNEW
« no previous file with comments | « base/mac/bind_objc_block.h ('k') | base/memory/scoped_ptr_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698