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); |
+} |