From 014f2c41838f5dd648503a740415e0e80c8406f8 Mon Sep 17 00:00:00 2001 From: "mtklein@google.com" Date: Thu, 19 Sep 2013 20:56:46 +0000 Subject: [PATCH] Add an even more convenient way to declare tests, with example. BUG= R=reed@google.com Review URL: https://codereview.chromium.org/23828008 git-svn-id: http://skia.googlecode.com/svn/trunk@11405 2bbb7eff-a529-9590-31e7-b0007b416f81 --- tests/AAClipTest.cpp | 6 ++---- tests/TestClassDef.h | 12 ++++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/tests/AAClipTest.cpp b/tests/AAClipTest.cpp index e3be006..f70cfd6 100644 --- a/tests/AAClipTest.cpp +++ b/tests/AAClipTest.cpp @@ -394,7 +394,8 @@ static void test_regressions() { } } -static void TestAAClip(skiatest::Reporter* reporter) { +#include "TestClassDef.h" +DEF_TEST(AAClip, reporter) { test_empty(reporter); test_path_bounds(reporter); test_irect(reporter); @@ -403,6 +404,3 @@ static void TestAAClip(skiatest::Reporter* reporter) { test_regressions(); test_nearly_integral(reporter); } - -#include "TestClassDef.h" -DEFINE_TESTCLASS("AAClip", AAClipTestClass, TestAAClip) diff --git a/tests/TestClassDef.h b/tests/TestClassDef.h index 70d6039..89124c7 100644 --- a/tests/TestClassDef.h +++ b/tests/TestClassDef.h @@ -55,3 +55,15 @@ }; \ static TestRegistry gReg_##classname(classname::Factory); \ } + + +// Yet shorter way to define a test. E.g. +// +// DEF_TEST(some_test_name, r) { +// ... +// REPORTER_ASSERT(r, x == 15); +// } +#define DEF_TEST(name, reporter) \ + static void name(skiatest::Reporter* reporter); \ + DEFINE_TESTCLASS_SHORT(name) \ + static void name(skiatest::Reporter* reporter) -- 2.7.4