Fix SkSpan supspan() add test

Change-Id: Ida683aa054fef977b91b3232b063f74344ffc2c9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/289448
Auto-Submit: Herb Derby <herb@google.com>
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Herb Derby <herb@google.com>
This commit is contained in:
Herb Derby 2020-05-13 12:01:24 -04:00 committed by Skia Commit-Bot
parent 0c228e3f64
commit 537dc05d41
2 changed files with 5 additions and 1 deletions

View File

@ -52,7 +52,7 @@ public:
}
constexpr SkSpan<T> subspan(size_t offset, size_t count) const {
SkASSERT(offset <= this->size());
SkASSERT(count <= this->size - offset);
SkASSERT(count <= this->size() - offset);
if (count == 0) { return SkSpan{}; }
return SkSpan{fPtr + offset, count};
}

View File

@ -202,6 +202,10 @@ DEF_TEST(SkMakeSpan, reporter) {
REPORTER_ASSERT(reporter, s[3] == 4);
s[3] = 100;
REPORTER_ASSERT(reporter, s[3] == 100);
auto s1 = s.subspan(1,3);
REPORTER_ASSERT(reporter, s1.size() == 3);
REPORTER_ASSERT(reporter, s1.front() == 2);
REPORTER_ASSERT(reporter, s1.back() == 100);
}
{