Index: tests/DataRefTest.cpp |
diff --git a/tests/DataRefTest.cpp b/tests/DataRefTest.cpp |
index 0c7d5f452023d0e42e4fc857220feb3fe00b362f..f1e645ec7e7cbac855b5bc9de44ca664384cdec4 100644 |
--- a/tests/DataRefTest.cpp |
+++ b/tests/DataRefTest.cpp |
@@ -313,3 +313,18 @@ DEF_TEST(RWBuffer, reporter) { |
delete streams[i]; |
} |
} |
+ |
+// Tests that it is safe to call SkROBuffer::Iter::size() when exhausted. |
+DEF_TEST(RWBuffer_size, r) { |
+ SkRWBuffer buffer; |
+ buffer.append(gABC, 26); |
+ |
+ SkAutoTUnref<SkROBuffer> roBuffer(buffer.newRBufferSnapshot()); |
+ SkROBuffer::Iter iter(roBuffer); |
+ REPORTER_ASSERT(r, iter.data()); |
+ REPORTER_ASSERT(r, iter.size() == 26); |
+ |
+ // There is only one block in this buffer. |
+ REPORTER_ASSERT(r, !iter.next()); |
+ REPORTER_ASSERT(r, 0 == iter.size()); |
+} |