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

Side by Side Diff: tests/DataRefTest.cpp

Issue 100113004: Use DEFINE_TESTCLASS_SHORT macro in tests. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase Created 7 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/ColorTest.cpp ('k') | tests/DequeTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1
2 /* 1 /*
3 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
4 * 3 *
5 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 5 * found in the LICENSE file.
7 */ 6 */
7
8 #include "Test.h" 8 #include "Test.h"
9 #include "TestClassDef.h"
9 #include "SkData.h" 10 #include "SkData.h"
10 #include "SkDataTable.h" 11 #include "SkDataTable.h"
11 #include "SkOrderedReadBuffer.h" 12 #include "SkOrderedReadBuffer.h"
12 #include "SkOrderedWriteBuffer.h" 13 #include "SkOrderedWriteBuffer.h"
13 #include "SkOSFile.h" 14 #include "SkOSFile.h"
14 #include "SkStream.h" 15 #include "SkStream.h"
15 16
16 static void test_is_equal(skiatest::Reporter* reporter, 17 static void test_is_equal(skiatest::Reporter* reporter,
17 const SkDataTable* a, const SkDataTable* b) { 18 const SkDataTable* a, const SkDataTable* b) {
18 REPORTER_ASSERT(reporter, a->count() == b->count()); 19 REPORTER_ASSERT(reporter, a->count() == b->count());
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 127
127 REPORTER_ASSERT(reporter, table->count() == count); 128 REPORTER_ASSERT(reporter, table->count() == count);
128 for (int i = 0; i < count; ++i) { 129 for (int i = 0; i < count; ++i) {
129 size_t size; 130 size_t size;
130 REPORTER_ASSERT(reporter, table->atSize(i) == sizeof(int)); 131 REPORTER_ASSERT(reporter, table->atSize(i) == sizeof(int));
131 REPORTER_ASSERT(reporter, *table->atT<const char>(i, &size) == i); 132 REPORTER_ASSERT(reporter, *table->atT<const char>(i, &size) == i);
132 REPORTER_ASSERT(reporter, sizeof(int) == size); 133 REPORTER_ASSERT(reporter, sizeof(int) == size);
133 } 134 }
134 } 135 }
135 136
136 static void TestDataTable(skiatest::Reporter* reporter) { 137 DEF_TEST(DataTable, reporter) {
137 test_emptytable(reporter); 138 test_emptytable(reporter);
138 test_simpletable(reporter); 139 test_simpletable(reporter);
139 test_vartable(reporter); 140 test_vartable(reporter);
140 test_tablebuilder(reporter); 141 test_tablebuilder(reporter);
141 test_globaltable(reporter); 142 test_globaltable(reporter);
142 } 143 }
143 144
144 static void* gGlobal; 145 static void* gGlobal;
145 146
146 static void delete_int_proc(const void* ptr, size_t len, void* context) { 147 static void delete_int_proc(const void* ptr, size_t len, void* context) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 REPORTER_ASSERT(reporter, r1->size() == 26); 200 REPORTER_ASSERT(reporter, r1->size() == 26);
200 REPORTER_ASSERT(reporter, strncmp(static_cast<const char*>(r1->data()), s, 2 6) == 0); 201 REPORTER_ASSERT(reporter, strncmp(static_cast<const char*>(r1->data()), s, 2 6) == 0);
201 202
202 int fd = sk_fileno(file); 203 int fd = sk_fileno(file);
203 SkAutoTUnref<SkData> r2(SkData::NewFromFD(fd)); 204 SkAutoTUnref<SkData> r2(SkData::NewFromFD(fd));
204 REPORTER_ASSERT(reporter, r2.get() != NULL); 205 REPORTER_ASSERT(reporter, r2.get() != NULL);
205 REPORTER_ASSERT(reporter, r2->size() == 26); 206 REPORTER_ASSERT(reporter, r2->size() == 26);
206 REPORTER_ASSERT(reporter, strncmp(static_cast<const char*>(r2->data()), s, 2 6) == 0); 207 REPORTER_ASSERT(reporter, strncmp(static_cast<const char*>(r2->data()), s, 2 6) == 0);
207 } 208 }
208 209
209 static void TestData(skiatest::Reporter* reporter) { 210 DEF_TEST(Data, reporter) {
210 const char* str = "We the people, in order to form a more perfect union."; 211 const char* str = "We the people, in order to form a more perfect union.";
211 const int N = 10; 212 const int N = 10;
212 213
213 SkAutoTUnref<SkData> r0(SkData::NewEmpty()); 214 SkAutoTUnref<SkData> r0(SkData::NewEmpty());
214 SkAutoTUnref<SkData> r1(SkData::NewWithCopy(str, strlen(str))); 215 SkAutoTUnref<SkData> r1(SkData::NewWithCopy(str, strlen(str)));
215 SkAutoTUnref<SkData> r2(SkData::NewWithProc(new int[N], N*sizeof(int), 216 SkAutoTUnref<SkData> r2(SkData::NewWithProc(new int[N], N*sizeof(int),
216 delete_int_proc, gGlobal)); 217 delete_int_proc, gGlobal));
217 SkAutoTUnref<SkData> r3(SkData::NewSubset(r1, 7, 6)); 218 SkAutoTUnref<SkData> r3(SkData::NewSubset(r1, 7, 6));
218 219
219 assert_len(reporter, r0, 0); 220 assert_len(reporter, r0, 0);
220 assert_len(reporter, r1, strlen(str)); 221 assert_len(reporter, r1, strlen(str));
221 assert_len(reporter, r2, N * sizeof(int)); 222 assert_len(reporter, r2, N * sizeof(int));
222 assert_len(reporter, r3, 6); 223 assert_len(reporter, r3, 6);
223 224
224 assert_data(reporter, r1, str, strlen(str)); 225 assert_data(reporter, r1, str, strlen(str));
225 assert_data(reporter, r3, "people", 6); 226 assert_data(reporter, r3, "people", 6);
226 227
227 SkData* tmp = SkData::NewSubset(r1, strlen(str), 10); 228 SkData* tmp = SkData::NewSubset(r1, strlen(str), 10);
228 assert_len(reporter, tmp, 0); 229 assert_len(reporter, tmp, 0);
229 tmp->unref(); 230 tmp->unref();
230 tmp = SkData::NewSubset(r1, 0, 0); 231 tmp = SkData::NewSubset(r1, 0, 0);
231 assert_len(reporter, tmp, 0); 232 assert_len(reporter, tmp, 0);
232 tmp->unref(); 233 tmp->unref();
233 234
234 test_cstring(reporter); 235 test_cstring(reporter);
235 test_files(reporter); 236 test_files(reporter);
236 } 237 }
237
238 #include "TestClassDef.h"
239 DEFINE_TESTCLASS("Data", DataTestClass, TestData)
240 DEFINE_TESTCLASS("DataTable", DataTableTestClass, TestDataTable)
OLDNEW
« no previous file with comments | « tests/ColorTest.cpp ('k') | tests/DequeTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698