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

Side by Side Diff: src/utils/SkBase64.cpp

Issue 132233060: Port SkBase64 test to our test driver. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: mtklein review Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « src/utils/SkBase64.h ('k') | tests/SkBase64Test.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 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkBase64.h" 10 #include "SkBase64.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 155
156 SkBase64::Error SkBase64::decode(const char* src, size_t len) { 156 SkBase64::Error SkBase64::decode(const char* src, size_t len) {
157 Error err = decode(src, len, false); 157 Error err = decode(src, len, false);
158 SkASSERT(err == kNoError); 158 SkASSERT(err == kNoError);
159 if (err != kNoError) 159 if (err != kNoError)
160 return err; 160 return err;
161 fData = new char[fLength]; // should use sk_malloc/sk_free 161 fData = new char[fLength]; // should use sk_malloc/sk_free
162 decode(src, len, true); 162 decode(src, len, true);
163 return kNoError; 163 return kNoError;
164 } 164 }
165
166 #ifdef SK_SUPPORT_UNITTEST
167 void SkBase64::UnitTest() {
168 signed char all[256];
169 for (int index = 0; index < 256; index++)
170 all[index] = (signed char) (index + 1);
171 for (int offset = 0; offset < 6; offset++) {
172 size_t length = 256 - offset;
173 size_t encodeLength = Encode(all + offset, length, NULL);
174 char* src = (char*)sk_malloc_throw(encodeLength + 1);
175 Encode(all + offset, length, src);
176 src[encodeLength] = '\0';
177 SkBase64 tryMe;
178 tryMe.decode(src, encodeLength);
179 SkASSERT(length == tryMe.fLength);
180 SkASSERT(strcmp((const char*) (all + offset), tryMe.fData) == 0);
181 sk_free(src);
182 delete[] tryMe.fData;
183 }
184 }
185 #endif
OLDNEW
« no previous file with comments | « src/utils/SkBase64.h ('k') | tests/SkBase64Test.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698