From 1b2c1b893adb7fdd4ee2ac305e47009c428ba72a Mon Sep 17 00:00:00 2001 From: "commit-bot@chromium.org" Date: Thu, 5 Dec 2013 19:20:49 +0000 Subject: SkOnce: let f be any functor, update comments BUG= R=bungeman@google.com Author: mtklein@google.com Review URL: https://codereview.chromium.org/104433005 git-svn-id: http://skia.googlecode.com/svn/trunk@12518 2bbb7eff-a529-9590-31e7-b0007b416f81 --- tests/OnceTest.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests/OnceTest.cpp') diff --git a/tests/OnceTest.cpp b/tests/OnceTest.cpp index 31c6a85a44..d3a0a0066a 100644 --- a/tests/OnceTest.cpp +++ b/tests/OnceTest.cpp @@ -28,6 +28,20 @@ DEF_TEST(SkOnce_Singlethreaded, r) { REPORTER_ASSERT(r, 5 == x); } +struct AddFour { void operator()(int* x) { *x += 4; } }; + +DEF_TEST(SkOnce_MiscFeatures, r) { + // Tests that we support functors and explicit SkOnceFlags. + int x = 0; + + SkOnceFlag once = SK_ONCE_INIT; + SkOnce(&once, AddFour(), &x); + SkOnce(&once, AddFour(), &x); + SkOnce(&once, AddFour(), &x); + + REPORTER_ASSERT(r, 4 == x); +} + static void add_six(int* x) { *x += 6; } -- cgit v1.2.3