avoid illegal enum values in PathTest
We're testing here that when isRect() returns false,
the isClosed and direction fields are unchanged.
Instead of using illegal values (which trip up UBSAN)
test all combinations of legal values.
It looks like we were trying to use an illegal -1 bool
to do the same trick as the enum, but I think it was
legal and just always true.
Change-Id: Ia4ab4c3d52f61bf67e888dea67549ab09750902a
Reviewed-on: https://skia-review.googlesource.com/147001
Reviewed-by: Yuqian Li <liyuqian@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp
index a742bcb..5f6aa3d 100644
--- a/tests/PathTest.cpp
+++ b/tests/PathTest.cpp
@@ -2069,13 +2069,16 @@
} else {
SkRect computed;
computed.set(123, 456, 789, 1011);
- bool isClosed = (bool)-1;
- SkPath::Direction direction = (SkPath::Direction) - 1;
- REPORTER_ASSERT(reporter, !path.isRect(&computed, &isClosed, &direction));
- REPORTER_ASSERT(reporter, computed.fLeft == 123 && computed.fTop == 456);
- REPORTER_ASSERT(reporter, computed.fRight == 789 && computed.fBottom == 1011);
- REPORTER_ASSERT(reporter, isClosed == (bool) -1);
- REPORTER_ASSERT(reporter, direction == (SkPath::Direction) -1);
+ for (auto c : {true, false})
+ for (auto d : {SkPath::kCW_Direction, SkPath::kCCW_Direction}) {
+ bool isClosed = c;
+ SkPath::Direction direction = d;
+ REPORTER_ASSERT(reporter, !path.isRect(&computed, &isClosed, &direction));
+ REPORTER_ASSERT(reporter, computed.fLeft == 123 && computed.fTop == 456);
+ REPORTER_ASSERT(reporter, computed.fRight == 789 && computed.fBottom == 1011);
+ REPORTER_ASSERT(reporter, isClosed == c);
+ REPORTER_ASSERT(reporter, direction == d);
+ }
}
}