| Index: base/bind_unittest.cc
|
| diff --git a/base/bind_unittest.cc b/base/bind_unittest.cc
|
| index a30b7756704658a599a84e3df88e80166e731ce7..2f3891bfd95b954ec35bacea4b2812d2aed18e6f 100644
|
| --- a/base/bind_unittest.cc
|
| +++ b/base/bind_unittest.cc
|
| @@ -4,6 +4,7 @@
|
|
|
| #include "base/bind.h"
|
|
|
| +#include "base/bind_lambda.h"
|
| #include "base/callback.h"
|
| #include "base/memory/ref_counted.h"
|
| #include "base/memory/scoped_ptr.h"
|
| @@ -786,6 +787,27 @@ TEST_F(BindTest, ArgumentCopies) {
|
| EXPECT_EQ(0, assigns);
|
| }
|
|
|
| +TEST_F(BindTest, Lambdas) {
|
| + static const int kValueToSet = 55;
|
| + int value_set_from_lambda = 0;
|
| +
|
| + Callback<void(int)> callback =
|
| + BindLambda([&](int new_val) { value_set_from_lambda = new_val; });
|
| + callback.Run(kValueToSet);
|
| + EXPECT_EQ(kValueToSet, value_set_from_lambda);
|
| +}
|
| +
|
| +TEST_F(BindTest, LambdasNestedInBind) {
|
| + static const int kValueToSet = 55;
|
| + int value_set_from_lambda = 0;
|
| +
|
| + Callback<void()> callback =
|
| + Bind(BindLambda([&](int new_val) { value_set_from_lambda = new_val; }),
|
| + kValueToSet);
|
| + callback.Run();
|
| + EXPECT_EQ(kValueToSet, value_set_from_lambda);
|
| +}
|
| +
|
| // Callback construction and assignment tests.
|
| // - Construction from an InvokerStorageHolder should not cause ref/deref.
|
| // - Assignment from other callback should only cause one ref
|
|
|