Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1503)

Unified Diff: tests/TemplatesTest.cpp

Issue 2084213003: Make container classes in SkTemplates.h more consistent (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Make buffer classes in SkTemplates.h more consistent Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« include/private/SkTemplates.h ('K') | « include/private/SkTemplates.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/TemplatesTest.cpp
diff --git a/tests/TemplatesTest.cpp b/tests/TemplatesTest.cpp
index 31859f3f0cea620af3868ce26c93a01601be2b20..4698dbb483f27fdefb7860e99ca6a17789f5bdc1 100644
--- a/tests/TemplatesTest.cpp
+++ b/tests/TemplatesTest.cpp
@@ -67,6 +67,38 @@ static void test_automalloc_realloc(skiatest::Reporter* reporter) {
REPORTER_ASSERT(reporter, array[0] == 1);
}
+constexpr int static kStackPreallocCount = 10;
+
+// Ensures the buffers in SkTemplates.h all have a consistent api.
+template<typename TBuffer> static void test_buffer_apis(skiatest::Reporter* reporter) {
+ REPORTER_ASSERT(reporter, !TBuffer(0lu).get());
+ REPORTER_ASSERT(reporter, TBuffer(1).get());
+ REPORTER_ASSERT(reporter, TBuffer(kStackPreallocCount).get());
+ REPORTER_ASSERT(reporter, TBuffer(kStackPreallocCount + 1).get());
+
+ TBuffer buffer;
+ // The default constructor may or may not init to empty, depending on the type of buffer.
+
+ buffer.reset(1);
+ REPORTER_ASSERT(reporter, buffer.get());
+
+ buffer.reset(kStackPreallocCount);
+ REPORTER_ASSERT(reporter, buffer.get());
+
+ buffer.reset(kStackPreallocCount + 1);
+ REPORTER_ASSERT(reporter, buffer.get());
+
+ buffer.reset(0);
+ REPORTER_ASSERT(reporter, !buffer.get());
+}
+
DEF_TEST(Templates, reporter) {
test_automalloc_realloc(reporter);
}
+
+DEF_TEST(TemplateBuffers, reporter) {
+ test_buffer_apis<SkAutoTArray<int> >(reporter);
+ test_buffer_apis<SkAutoSTArray<kStackPreallocCount, int> >(reporter);
+ test_buffer_apis<SkAutoTMalloc<int> >(reporter);
+ test_buffer_apis<SkAutoSTMalloc<kStackPreallocCount, int> >(reporter);
+}
« include/private/SkTemplates.h ('K') | « include/private/SkTemplates.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698