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

Side by Side Diff: tests/StringTest.cpp

Issue 17448012: Add SkString::appendU32() and SkString::appendU64() (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: add_cornercase_test_that_works_now Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/core/SkString.cpp ('k') | no next file » | 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 2011 Google Inc. 3 * Copyright 2011 Google Inc.
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 #include "Test.h" 8 #include "Test.h"
9 #include "SkString.h" 9 #include "SkString.h"
10 #include <stdarg.h> 10 #include <stdarg.h>
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 a.reset(); 95 a.reset();
96 b.resize(0); 96 b.resize(0);
97 REPORTER_ASSERT(reporter, a.isEmpty() && b.isEmpty() && a == b); 97 REPORTER_ASSERT(reporter, a.isEmpty() && b.isEmpty() && a == b);
98 98
99 a.set("a"); 99 a.set("a");
100 a.set("ab"); 100 a.set("ab");
101 a.set("abc"); 101 a.set("abc");
102 a.set("abcd"); 102 a.set("abcd");
103 103
104 a.set(""); 104 a.set("");
105 a.appendS64(72036854775808LL, 0); 105 a.appendS32(0x7FFFFFFFL);
106 REPORTER_ASSERT(reporter, a.equals("72036854775808")); 106 REPORTER_ASSERT(reporter, a.equals("2147483647"));
107 a.set("");
108 a.appendS32(0x80000001L);
109 REPORTER_ASSERT(reporter, a.equals("-2147483647"));
110 a.set("");
111 a.appendS32(0x80000000L);
112 REPORTER_ASSERT(reporter, a.equals("-2147483648"));
107 113
108 a.set(""); 114 a.set("");
109 a.appendS64(-1844674407370LL, 0); 115 a.appendU32(0x7FFFFFFFUL);
110 REPORTER_ASSERT(reporter, a.equals("-1844674407370")); 116 REPORTER_ASSERT(reporter, a.equals("2147483647"));
117 a.set("");
118 a.appendU32(0x80000001UL);
119 REPORTER_ASSERT(reporter, a.equals("2147483649"));
120 a.set("");
121 a.appendU32(0xFFFFFFFFUL);
122 REPORTER_ASSERT(reporter, a.equals("4294967295"));
111 123
112 a.set(""); 124 a.set("");
113 a.appendS64(73709551616LL, 15); 125 a.appendS64(0x7FFFFFFFFFFFFFFFLL, 0);
114 REPORTER_ASSERT(reporter, a.equals("000073709551616")); 126 REPORTER_ASSERT(reporter, a.equals("9223372036854775807"));
127 a.set("");
128 a.appendS64(0x8000000000000001LL, 0);
129 REPORTER_ASSERT(reporter, a.equals("-9223372036854775807"));
130 a.set("");
131 a.appendS64(0x8000000000000000LL, 0);
132 REPORTER_ASSERT(reporter, a.equals("-9223372036854775808"));
133 a.set("");
134 a.appendS64(0x0000000001000000LL, 15);
135 REPORTER_ASSERT(reporter, a.equals("000000016777216"));
136 a.set("");
137 a.appendS64(0xFFFFFFFFFF000000LL, 15);
138 REPORTER_ASSERT(reporter, a.equals("-000000016777216"));
115 139
116 a.set(""); 140 a.set("");
117 a.appendS64(-429496729612LL, 15); 141 a.appendU64(0x7FFFFFFFFFFFFFFFULL, 0);
118 REPORTER_ASSERT(reporter, a.equals("-000429496729612")); 142 REPORTER_ASSERT(reporter, a.equals("9223372036854775807"));
143 a.set("");
144 a.appendU64(0x8000000000000001ULL, 0);
145 REPORTER_ASSERT(reporter, a.equals("9223372036854775809"));
146 a.set("");
147 a.appendU64(0xFFFFFFFFFFFFFFFFULL, 0);
148 REPORTER_ASSERT(reporter, a.equals("18446744073709551615"));
149 a.set("");
150 a.appendU64(0x0000000001000000ULL, 15);
151 REPORTER_ASSERT(reporter, a.equals("000000016777216"));
119 152
120 static const struct { 153 static const struct {
121 SkScalar fValue; 154 SkScalar fValue;
122 const char* fString; 155 const char* fString;
123 } gRec[] = { 156 } gRec[] = {
124 { 0, "0" }, 157 { 0, "0" },
125 { SK_Scalar1, "1" }, 158 { SK_Scalar1, "1" },
126 { -SK_Scalar1, "-1" }, 159 { -SK_Scalar1, "-1" },
127 { SK_Scalar1/2, "0.5" }, 160 { SK_Scalar1/2, "0.5" },
128 #ifdef SK_SCALAR_IS_FLOAT 161 #ifdef SK_SCALAR_IS_FLOAT
(...skipping 23 matching lines...) Expand all
152 REPORTER_ASSERT(reporter, buffer[20] == 'a'); 185 REPORTER_ASSERT(reporter, buffer[20] == 'a');
153 printfAnalog(buffer, 20, "%30d", 0); 186 printfAnalog(buffer, 20, "%30d", 0);
154 REPORTER_ASSERT(reporter, buffer[18] == ' '); 187 REPORTER_ASSERT(reporter, buffer[18] == ' ');
155 REPORTER_ASSERT(reporter, buffer[19] == 0); 188 REPORTER_ASSERT(reporter, buffer[19] == 0);
156 REPORTER_ASSERT(reporter, buffer[20] == 'a'); 189 REPORTER_ASSERT(reporter, buffer[20] == 'a');
157 190
158 } 191 }
159 192
160 #include "TestClassDef.h" 193 #include "TestClassDef.h"
161 DEFINE_TESTCLASS("String", StringTestClass, TestString) 194 DEFINE_TESTCLASS("String", StringTestClass, TestString)
OLDNEW
« no previous file with comments | « src/core/SkString.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698