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

Unified Diff: base/callback_helpers_unittest.cc

Issue 2820993002: Introduce base::IgnoreReuse() to wrap OnceCallback into RepeatingCallback (Closed)
Patch Set: Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: base/callback_helpers_unittest.cc
diff --git a/base/callback_helpers_unittest.cc b/base/callback_helpers_unittest.cc
index 6c48d7ce4e52eeea056722df4cd97f8047f68292..19d9acbe0542470ef40c8748f38386d717e00bcb 100644
--- a/base/callback_helpers_unittest.cc
+++ b/base/callback_helpers_unittest.cc
@@ -109,4 +109,19 @@ TEST(CallbackHelpersTest, TestScopedClosureRunnerMoveAssignment) {
EXPECT_EQ(1, run_count_2);
}
+TEST(CallbackHelpersTest, TestIgnoreReuse) {
+ int count = 0;
+ base::OnceCallback<void(int*)> cb =
+ base::BindOnce([](int* count) { ++*count; });
+
+ base::RepeatingCallback<void(int*)> wrapped =
+ base::IgnoreReuse(std::move(cb));
+
+ EXPECT_EQ(0, count);
+ wrapped.Run(&count);
+ EXPECT_EQ(1, count);
+ wrapped.Run(&count);
+ EXPECT_EQ(1, count);
+}
+
} // namespace

Powered by Google App Engine
This is Rietveld 408576698