From 6fc321a18acc8c6437735007240eefe7054e83b0 Mon Sep 17 00:00:00 2001 From: "reed@google.com" Date: Wed, 27 Jul 2011 13:54:36 +0000 Subject: add test for SkConvertQuadToCubic git-svn-id: http://skia.googlecode.com/svn/trunk@1967 2bbb7eff-a529-9590-31e7-b0007b416f81 --- tests/GeometryTest.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tests/GeometryTest.cpp') diff --git a/tests/GeometryTest.cpp b/tests/GeometryTest.cpp index 5b05952c84..146528897d 100644 --- a/tests/GeometryTest.cpp +++ b/tests/GeometryTest.cpp @@ -1,6 +1,10 @@ #include "Test.h" #include "SkGeometry.h" +static bool nearly_equal(const SkPoint& a, const SkPoint& b) { + return SkScalarNearlyEqual(a.fX, b.fX) && SkScalarNearlyEqual(a.fY, b.fY); +} + static void TestGeometry(skiatest::Reporter* reporter) { SkPoint pts[3], dst[5]; @@ -10,6 +14,20 @@ static void TestGeometry(skiatest::Reporter* reporter) { int count = SkChopQuadAtMaxCurvature(pts, dst); REPORTER_ASSERT(reporter, count == 1 || count == 2); + + pts[0].set(0, 0); + pts[1].set(SkIntToScalar(3), 0); + pts[2].set(SkIntToScalar(3), SkIntToScalar(3)); + SkConvertQuadToCubic(pts, dst); + const SkPoint cubic[] = { + 0, 0, + SkIntToScalar(2), 0, + SkIntToScalar(3), SkIntToScalar(1), + SkIntToScalar(3), SkIntToScalar(3) + }; + for (int i = 0; i < 4; ++i) { + REPORTER_ASSERT(reporter, nearly_equal(cubic[i], dst[i])); + } } #include "TestClassDef.h" -- cgit v1.2.3