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

Side by Side Diff: tests/DataRefTest.cpp

Issue 1316233002: Style Change: NULL->nullptr (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-27 (Thursday) 10:25:06 EDT Created 5 years, 3 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 unified diff | Download patch
« no previous file with comments | « tests/DashPathEffectTest.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 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * 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
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkData.h" 8 #include "SkData.h"
9 #include "SkDataTable.h" 9 #include "SkDataTable.h"
10 #include "SkOSFile.h" 10 #include "SkOSFile.h"
(...skipping 15 matching lines...) Expand all
26 } 26 }
27 27
28 static void test_datatable_is_empty(skiatest::Reporter* reporter, 28 static void test_datatable_is_empty(skiatest::Reporter* reporter,
29 SkDataTable* table) { 29 SkDataTable* table) {
30 REPORTER_ASSERT(reporter, table->isEmpty()); 30 REPORTER_ASSERT(reporter, table->isEmpty());
31 REPORTER_ASSERT(reporter, 0 == table->count()); 31 REPORTER_ASSERT(reporter, 0 == table->count());
32 } 32 }
33 33
34 static void test_emptytable(skiatest::Reporter* reporter) { 34 static void test_emptytable(skiatest::Reporter* reporter) {
35 SkAutoTUnref<SkDataTable> table0(SkDataTable::NewEmpty()); 35 SkAutoTUnref<SkDataTable> table0(SkDataTable::NewEmpty());
36 SkAutoTUnref<SkDataTable> table1(SkDataTable::NewCopyArrays(NULL, NULL, 0)); 36 SkAutoTUnref<SkDataTable> table1(SkDataTable::NewCopyArrays(nullptr, nullptr , 0));
37 SkAutoTUnref<SkDataTable> table2(SkDataTable::NewCopyArray(NULL, 0, 0)); 37 SkAutoTUnref<SkDataTable> table2(SkDataTable::NewCopyArray(nullptr, 0, 0));
38 SkAutoTUnref<SkDataTable> table3(SkDataTable::NewArrayProc(NULL, 0, 0, 38 SkAutoTUnref<SkDataTable> table3(SkDataTable::NewArrayProc(nullptr, 0, 0,
39 NULL, NULL)); 39 nullptr, nullptr) );
40 40
41 test_datatable_is_empty(reporter, table0); 41 test_datatable_is_empty(reporter, table0);
42 test_datatable_is_empty(reporter, table1); 42 test_datatable_is_empty(reporter, table1);
43 test_datatable_is_empty(reporter, table2); 43 test_datatable_is_empty(reporter, table2);
44 test_datatable_is_empty(reporter, table3); 44 test_datatable_is_empty(reporter, table3);
45 45
46 test_is_equal(reporter, table0, table1); 46 test_is_equal(reporter, table0, table1);
47 test_is_equal(reporter, table0, table2); 47 test_is_equal(reporter, table0, table2);
48 test_is_equal(reporter, table0, table3); 48 test_is_equal(reporter, table0, table3);
49 } 49 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 } 115 }
116 } 116 }
117 117
118 static void test_globaltable(skiatest::Reporter* reporter) { 118 static void test_globaltable(skiatest::Reporter* reporter) {
119 static const int gData[] = { 119 static const int gData[] = {
120 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 120 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
121 }; 121 };
122 int count = SK_ARRAY_COUNT(gData); 122 int count = SK_ARRAY_COUNT(gData);
123 123
124 SkAutoTUnref<SkDataTable> table(SkDataTable::NewArrayProc(gData, 124 SkAutoTUnref<SkDataTable> table(SkDataTable::NewArrayProc(gData,
125 sizeof(gData[0]), count, NULL, NULL)); 125 sizeof(gData[0]), count, nullptr, null ptr));
126 126
127 REPORTER_ASSERT(reporter, table->count() == count); 127 REPORTER_ASSERT(reporter, table->count() == count);
128 for (int i = 0; i < count; ++i) { 128 for (int i = 0; i < count; ++i) {
129 size_t size; 129 size_t size;
130 REPORTER_ASSERT(reporter, table->atSize(i) == sizeof(int)); 130 REPORTER_ASSERT(reporter, table->atSize(i) == sizeof(int));
131 REPORTER_ASSERT(reporter, *table->atT<const char>(i, &size) == i); 131 REPORTER_ASSERT(reporter, *table->atT<const char>(i, &size) == i);
132 REPORTER_ASSERT(reporter, sizeof(int) == size); 132 REPORTER_ASSERT(reporter, sizeof(int) == size);
133 } 133 }
134 } 134 }
135 135
(...skipping 25 matching lines...) Expand all
161 161
162 static void test_cstring(skiatest::Reporter* reporter) { 162 static void test_cstring(skiatest::Reporter* reporter) {
163 const char str[] = "Hello world"; 163 const char str[] = "Hello world";
164 size_t len = strlen(str); 164 size_t len = strlen(str);
165 165
166 SkAutoTUnref<SkData> r0(SkData::NewWithCopy(str, len + 1)); 166 SkAutoTUnref<SkData> r0(SkData::NewWithCopy(str, len + 1));
167 SkAutoTUnref<SkData> r1(SkData::NewWithCString(str)); 167 SkAutoTUnref<SkData> r1(SkData::NewWithCString(str));
168 168
169 REPORTER_ASSERT(reporter, r0->equals(r1)); 169 REPORTER_ASSERT(reporter, r0->equals(r1));
170 170
171 SkAutoTUnref<SkData> r2(SkData::NewWithCString(NULL)); 171 SkAutoTUnref<SkData> r2(SkData::NewWithCString(nullptr));
172 REPORTER_ASSERT(reporter, 1 == r2->size()); 172 REPORTER_ASSERT(reporter, 1 == r2->size());
173 REPORTER_ASSERT(reporter, 0 == *r2->bytes()); 173 REPORTER_ASSERT(reporter, 0 == *r2->bytes());
174 } 174 }
175 175
176 static void test_files(skiatest::Reporter* reporter) { 176 static void test_files(skiatest::Reporter* reporter) {
177 SkString tmpDir = skiatest::GetTmpDir(); 177 SkString tmpDir = skiatest::GetTmpDir();
178 if (tmpDir.isEmpty()) { 178 if (tmpDir.isEmpty()) {
179 return; 179 return;
180 } 180 }
181 181
182 SkString path = SkOSPath::Join(tmpDir.c_str(), "data_test"); 182 SkString path = SkOSPath::Join(tmpDir.c_str(), "data_test");
183 183
184 const char s[] = "abcdefghijklmnopqrstuvwxyz"; 184 const char s[] = "abcdefghijklmnopqrstuvwxyz";
185 { 185 {
186 SkFILEWStream writer(path.c_str()); 186 SkFILEWStream writer(path.c_str());
187 if (!writer.isValid()) { 187 if (!writer.isValid()) {
188 ERRORF(reporter, "Failed to create tmp file %s\n", path.c_str()); 188 ERRORF(reporter, "Failed to create tmp file %s\n", path.c_str());
189 return; 189 return;
190 } 190 }
191 writer.write(s, 26); 191 writer.write(s, 26);
192 } 192 }
193 193
194 SkFILE* file = sk_fopen(path.c_str(), kRead_SkFILE_Flag); 194 SkFILE* file = sk_fopen(path.c_str(), kRead_SkFILE_Flag);
195 SkAutoTUnref<SkData> r1(SkData::NewFromFILE(file)); 195 SkAutoTUnref<SkData> r1(SkData::NewFromFILE(file));
196 REPORTER_ASSERT(reporter, r1.get() != NULL); 196 REPORTER_ASSERT(reporter, r1.get() != nullptr);
197 REPORTER_ASSERT(reporter, r1->size() == 26); 197 REPORTER_ASSERT(reporter, r1->size() == 26);
198 REPORTER_ASSERT(reporter, strncmp(static_cast<const char*>(r1->data()), s, 2 6) == 0); 198 REPORTER_ASSERT(reporter, strncmp(static_cast<const char*>(r1->data()), s, 2 6) == 0);
199 199
200 int fd = sk_fileno(file); 200 int fd = sk_fileno(file);
201 SkAutoTUnref<SkData> r2(SkData::NewFromFD(fd)); 201 SkAutoTUnref<SkData> r2(SkData::NewFromFD(fd));
202 REPORTER_ASSERT(reporter, r2.get() != NULL); 202 REPORTER_ASSERT(reporter, r2.get() != nullptr);
203 REPORTER_ASSERT(reporter, r2->size() == 26); 203 REPORTER_ASSERT(reporter, r2->size() == 26);
204 REPORTER_ASSERT(reporter, strncmp(static_cast<const char*>(r2->data()), s, 2 6) == 0); 204 REPORTER_ASSERT(reporter, strncmp(static_cast<const char*>(r2->data()), s, 2 6) == 0);
205 } 205 }
206 206
207 DEF_TEST(Data, reporter) { 207 DEF_TEST(Data, reporter) {
208 const char* str = "We the people, in order to form a more perfect union."; 208 const char* str = "We the people, in order to form a more perfect union.";
209 const int N = 10; 209 const int N = 10;
210 210
211 SkAutoTUnref<SkData> r0(SkData::NewEmpty()); 211 SkAutoTUnref<SkData> r0(SkData::NewEmpty());
212 SkAutoTUnref<SkData> r1(SkData::NewWithCopy(str, strlen(str))); 212 SkAutoTUnref<SkData> r1(SkData::NewWithCopy(str, strlen(str)));
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 } 306 }
307 307
308 for (int i = 0; i < N; ++i) { 308 for (int i = 0; i < N; ++i) {
309 REPORTER_ASSERT(reporter, (i + 1) * 26U == readers[i]->size()); 309 REPORTER_ASSERT(reporter, (i + 1) * 26U == readers[i]->size());
310 check_alphabet_buffer(reporter, readers[i]); 310 check_alphabet_buffer(reporter, readers[i]);
311 check_alphabet_stream(reporter, streams[i]); 311 check_alphabet_stream(reporter, streams[i]);
312 readers[i]->unref(); 312 readers[i]->unref();
313 delete streams[i]; 313 delete streams[i];
314 } 314 }
315 } 315 }
OLDNEW
« no previous file with comments | « tests/DashPathEffectTest.cpp ('k') | tests/DequeTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698