Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 1 | // Copyright 2019 Google LLC. |
| 2 | // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 3 | #include "tools/fiddle/examples.h" |
Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 4 | // HASH=c6c5b40cad7c3a839fdf576b380391a6 |
Hal Canary | a7181e7c | 2019-03-18 16:06:34 -0400 | [diff] [blame] | 5 | REG_FIDDLE(Rect_equal_operator, 256, 256, true, 0) { |
Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 6 | void draw(SkCanvas* canvas) { |
| 7 | auto debugster = [](const SkRect& test) -> void { |
| 8 | SkRect negZero = {-0.0f, -0.0f, 2, 2}; |
| 9 | SkDebugf("{%g, %g, %g, %g} %c= {%g, %g, %g, %g} %s numerically equal\n", |
| 10 | test.fLeft, test.fTop, test.fRight, test.fBottom, |
| 11 | negZero.fLeft, negZero.fTop, negZero.fRight, negZero.fBottom, |
| 12 | test == negZero ? '=' : '!', |
| 13 | test.fLeft == negZero.fLeft && test.fTop == negZero.fTop && |
| 14 | test.fRight == negZero.fRight && test.fBottom == negZero.fBottom ? |
| 15 | "and are" : "yet are not"); |
| 16 | }; |
| 17 | SkRect tests[] = {{0, 0, 2, 2}, {-0, -0, 2, 2}, {0.0f, 0.0f, 2, 2}}; |
| 18 | SkDebugf("tests are %s" "equal\n", tests[0] == tests[1] && tests[1] == tests[2] ? "" : "not "); |
| 19 | for (auto rect : tests) { |
| 20 | debugster(rect); |
| 21 | } |
| 22 | } |
| 23 | } // END FIDDLE |