aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/OnceTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/OnceTest.cpp')
-rw-r--r--tests/OnceTest.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/OnceTest.cpp b/tests/OnceTest.cpp
index f9ab427c16..3a99c39d53 100644
--- a/tests/OnceTest.cpp
+++ b/tests/OnceTest.cpp
@@ -77,3 +77,15 @@ DEF_TEST(SkOnce_Multithreaded, r) {
// Only one should have done the +=.
REPORTER_ASSERT(r, 6 == x);
}
+
+// Test that the atExit option works.
+static int gToDecrement = 1;
+static void noop(int) {}
+static void decrement() { gToDecrement--; }
+static void checkDecremented() { SkASSERT(gToDecrement == 0); }
+
+DEF_TEST(SkOnce_atExit, r) {
+ atexit(checkDecremented);
+ SK_DECLARE_STATIC_ONCE(once);
+ SkOnce(&once, noop, 0, decrement);
+}