Herb Derby | f0b5644 | 2020-09-23 16:14:45 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2020 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 | |
| 8 | #include "src/core/SkGlyph.h" |
| 9 | #include "tests/Test.h" |
| 10 | |
| 11 | DEF_TEST(SkGlyphRectBasic, reporter) { |
| 12 | using namespace skglyph; |
| 13 | SkGlyphRect r{1, 1, 10, 10}; |
| 14 | REPORTER_ASSERT(reporter, !r.empty()); |
| 15 | SkGlyphRect a = rect_union(r, empty_rect()); |
| 16 | REPORTER_ASSERT(reporter, a.iRect() == SkIRect::MakeLTRB(1, 1, 10, 10)); |
| 17 | |
| 18 | a = rect_intersection(r, full_rect()); |
| 19 | REPORTER_ASSERT(reporter, a.iRect() == SkIRect::MakeLTRB(1, 1, 10, 10)); |
| 20 | |
| 21 | SkGlyphRect acc = full_rect(); |
| 22 | for (int x = -10; x < 10; x++) { |
| 23 | for(int y = -10; y < 10; y++) { |
| 24 | acc = rect_intersection(acc, SkGlyphRect(x, y, x + 20, y + 20)); |
| 25 | } |
| 26 | } |
| 27 | REPORTER_ASSERT(reporter, acc.iRect() == SkIRect::MakeLTRB(9, 9, 10, 10)); |
| 28 | |
| 29 | acc = empty_rect(); |
| 30 | for (int x = -10; x < 10; x++) { |
| 31 | for(int y = -10; y < 10; y++) { |
| 32 | acc = rect_union(acc, SkGlyphRect(x, y, x + 20, y + 20)); |
| 33 | } |
| 34 | } |
| 35 | REPORTER_ASSERT(reporter, acc.iRect() == SkIRect::MakeLTRB(-10, -10, 29, 29)); |
| 36 | } |