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

Unified Diff: tests/ScopedTest.cpp

Issue 2274863002: sk_at_scope_end (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: use it! Created 4 years, 4 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
« src/codec/SkWebpCodec.cpp ('K') | « src/codec/SkWebpCodec.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/ScopedTest.cpp
diff --git a/tests/ScopedTest.cpp b/tests/ScopedTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..aadcc704af840fe58921d154ed233dbe71c98fed
--- /dev/null
+++ b/tests/ScopedTest.cpp
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "Test.h"
+
+static void dec(int* p) { (*p)--; }
+
+DEF_TEST(sk_at_scope_end, r) {
+ int x = 5;
+ {
+ sk_at_scope_end(x--);
+ REPORTER_ASSERT(r, x == 5);
+ }
+ REPORTER_ASSERT(r, x == 4);
+ {
+ sk_at_scope_end(dec(&x));
+ REPORTER_ASSERT(r, x == 4);
+ }
+ REPORTER_ASSERT(r, x == 3);
+}
« src/codec/SkWebpCodec.cpp ('K') | « src/codec/SkWebpCodec.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698