PathOpsDLineTest.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  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. */
  7. #include "src/pathops/SkPathOpsLine.h"
  8. #include "tests/PathOpsTestCommon.h"
  9. #include "tests/Test.h"
  10. static const SkDLine tests[] = {
  11. {{{2, 1}, {2, 1}}},
  12. {{{2, 1}, {1, 1}}},
  13. {{{2, 1}, {2, 2}}},
  14. {{{1, 1}, {2, 2}}},
  15. {{{3, 0}, {2, 1}}},
  16. {{{3, 2}, {1, 1}}},
  17. };
  18. static const size_t tests_count = SK_ARRAY_COUNT(tests);
  19. DEF_TEST(PathOpsLineUtilities, reporter) {
  20. for (size_t index = 0; index < tests_count; ++index) {
  21. const SkDLine& line = tests[index];
  22. SkASSERT(ValidLine(line));
  23. SkDLine line2;
  24. SkPoint pts[2] = {line[0].asSkPoint(), line[1].asSkPoint()};
  25. line2.set(pts);
  26. REPORTER_ASSERT(reporter, line[0] == line2[0] && line[1] == line2[1]);
  27. SkDPoint mid = line.ptAtT(.5);
  28. REPORTER_ASSERT(reporter, approximately_equal((line[0].fX + line[1].fX) / 2, mid.fX));
  29. REPORTER_ASSERT(reporter, approximately_equal((line[0].fY + line[1].fY) / 2, mid.fY));
  30. }
  31. }