caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
caryclark@google.com | 8d0a524 | 2013-07-16 16:11:16 +0000 | [diff] [blame] | 7 | #include "PathOpsTestCommon.h" |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 8 | #include "SkPathOpsLine.h" |
| 9 | #include "Test.h" |
| 10 | |
| 11 | static const SkDLine tests[] = { |
| 12 | {{{2, 1}, {2, 1}}}, |
| 13 | {{{2, 1}, {1, 1}}}, |
| 14 | {{{2, 1}, {2, 2}}}, |
| 15 | {{{1, 1}, {2, 2}}}, |
| 16 | {{{3, 0}, {2, 1}}}, |
| 17 | {{{3, 2}, {1, 1}}}, |
| 18 | }; |
| 19 | |
caryclark@google.com | ad65a3e | 2013-04-15 19:13:59 +0000 | [diff] [blame] | 20 | static const size_t tests_count = SK_ARRAY_COUNT(tests); |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 21 | |
tfarina@chromium.org | 78e7b4e | 2014-01-02 21:45:03 +0000 | [diff] [blame] | 22 | DEF_TEST(PathOpsLineUtilities, reporter) { |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 23 | for (size_t index = 0; index < tests_count; ++index) { |
| 24 | const SkDLine& line = tests[index]; |
caryclark@google.com | 8d0a524 | 2013-07-16 16:11:16 +0000 | [diff] [blame] | 25 | SkASSERT(ValidLine(line)); |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 26 | SkDLine line2; |
| 27 | SkPoint pts[2] = {line[0].asSkPoint(), line[1].asSkPoint()}; |
| 28 | line2.set(pts); |
| 29 | REPORTER_ASSERT(reporter, line[0] == line2[0] && line[1] == line2[1]); |
caryclark@google.com | 4fdbb22 | 2013-07-23 15:27:41 +0000 | [diff] [blame] | 30 | SkDPoint mid = line.ptAtT(.5); |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 31 | REPORTER_ASSERT(reporter, approximately_equal((line[0].fX + line[1].fX) / 2, mid.fX)); |
| 32 | REPORTER_ASSERT(reporter, approximately_equal((line[0].fY + line[1].fY) / 2, mid.fY)); |
| 33 | } |
| 34 | } |