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

Side by Side Diff: test/cctest/test-fixed-dtoa.cc

Issue 888613002: Initial switch to Chromium-style CHECK_* and DCHECK_* macros. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: CHECK_NULL/NOT_NULL is back. Created 5 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
« no previous file with comments | « test/cctest/test-feedback-vector.cc ('k') | test/cctest/test-flags.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 28 matching lines...) Expand all
39 39
40 static const int kBufferSize = 500; 40 static const int kBufferSize = 500;
41 41
42 TEST(FastFixedVariousDoubles) { 42 TEST(FastFixedVariousDoubles) {
43 char buffer_container[kBufferSize]; 43 char buffer_container[kBufferSize];
44 Vector<char> buffer(buffer_container, kBufferSize); 44 Vector<char> buffer(buffer_container, kBufferSize);
45 int length; 45 int length;
46 int point; 46 int point;
47 47
48 CHECK(FastFixedDtoa(1.0, 1, buffer, &length, &point)); 48 CHECK(FastFixedDtoa(1.0, 1, buffer, &length, &point));
49 CHECK_EQ("1", buffer.start()); 49 CHECK_EQ(0, strcmp("1", buffer.start()));
50 CHECK_EQ(1, point); 50 CHECK_EQ(1, point);
51 51
52 CHECK(FastFixedDtoa(1.0, 15, buffer, &length, &point)); 52 CHECK(FastFixedDtoa(1.0, 15, buffer, &length, &point));
53 CHECK_EQ("1", buffer.start()); 53 CHECK_EQ(0, strcmp("1", buffer.start()));
54 CHECK_EQ(1, point); 54 CHECK_EQ(1, point);
55 55
56 CHECK(FastFixedDtoa(1.0, 0, buffer, &length, &point)); 56 CHECK(FastFixedDtoa(1.0, 0, buffer, &length, &point));
57 CHECK_EQ("1", buffer.start()); 57 CHECK_EQ(0, strcmp("1", buffer.start()));
58 CHECK_EQ(1, point); 58 CHECK_EQ(1, point);
59 59
60 CHECK(FastFixedDtoa(0xFFFFFFFF, 5, buffer, &length, &point)); 60 CHECK(FastFixedDtoa(0xFFFFFFFF, 5, buffer, &length, &point));
61 CHECK_EQ("4294967295", buffer.start()); 61 CHECK_EQ(0, strcmp("4294967295", buffer.start()));
62 CHECK_EQ(10, point); 62 CHECK_EQ(10, point);
63 63
64 CHECK(FastFixedDtoa(4294967296.0, 5, buffer, &length, &point)); 64 CHECK(FastFixedDtoa(4294967296.0, 5, buffer, &length, &point));
65 CHECK_EQ("4294967296", buffer.start()); 65 CHECK_EQ(0, strcmp("4294967296", buffer.start()));
66 CHECK_EQ(10, point); 66 CHECK_EQ(10, point);
67 67
68 CHECK(FastFixedDtoa(1e21, 5, buffer, &length, &point)); 68 CHECK(FastFixedDtoa(1e21, 5, buffer, &length, &point));
69 CHECK_EQ("1", buffer.start()); 69 CHECK_EQ(0, strcmp("1", buffer.start()));
70 // CHECK_EQ(22, point); 70 // CHECK_EQ(22, point);
71 CHECK_EQ(22, point); 71 CHECK_EQ(22, point);
72 72
73 CHECK(FastFixedDtoa(999999999999999868928.00, 2, buffer, &length, &point)); 73 CHECK(FastFixedDtoa(999999999999999868928.00, 2, buffer, &length, &point));
74 CHECK_EQ("999999999999999868928", buffer.start()); 74 CHECK_EQ(0, strcmp("999999999999999868928", buffer.start()));
75 CHECK_EQ(21, point); 75 CHECK_EQ(21, point);
76 76
77 CHECK(FastFixedDtoa(6.9999999999999989514240000e+21, 5, buffer, 77 CHECK(FastFixedDtoa(6.9999999999999989514240000e+21, 5, buffer,
78 &length, &point)); 78 &length, &point));
79 CHECK_EQ("6999999999999998951424", buffer.start()); 79 CHECK_EQ(0, strcmp("6999999999999998951424", buffer.start()));
80 CHECK_EQ(22, point); 80 CHECK_EQ(22, point);
81 81
82 CHECK(FastFixedDtoa(1.5, 5, buffer, &length, &point)); 82 CHECK(FastFixedDtoa(1.5, 5, buffer, &length, &point));
83 CHECK_EQ("15", buffer.start()); 83 CHECK_EQ(0, strcmp("15", buffer.start()));
84 CHECK_EQ(1, point); 84 CHECK_EQ(1, point);
85 85
86 CHECK(FastFixedDtoa(1.55, 5, buffer, &length, &point)); 86 CHECK(FastFixedDtoa(1.55, 5, buffer, &length, &point));
87 CHECK_EQ("155", buffer.start()); 87 CHECK_EQ(0, strcmp("155", buffer.start()));
88 CHECK_EQ(1, point); 88 CHECK_EQ(1, point);
89 89
90 CHECK(FastFixedDtoa(1.55, 1, buffer, &length, &point)); 90 CHECK(FastFixedDtoa(1.55, 1, buffer, &length, &point));
91 CHECK_EQ("16", buffer.start()); 91 CHECK_EQ(0, strcmp("16", buffer.start()));
92 CHECK_EQ(1, point); 92 CHECK_EQ(1, point);
93 93
94 CHECK(FastFixedDtoa(1.00000001, 15, buffer, &length, &point)); 94 CHECK(FastFixedDtoa(1.00000001, 15, buffer, &length, &point));
95 CHECK_EQ("100000001", buffer.start()); 95 CHECK_EQ(0, strcmp("100000001", buffer.start()));
96 CHECK_EQ(1, point); 96 CHECK_EQ(1, point);
97 97
98 CHECK(FastFixedDtoa(0.1, 10, buffer, &length, &point)); 98 CHECK(FastFixedDtoa(0.1, 10, buffer, &length, &point));
99 CHECK_EQ("1", buffer.start()); 99 CHECK_EQ(0, strcmp("1", buffer.start()));
100 CHECK_EQ(0, point); 100 CHECK_EQ(0, point);
101 101
102 CHECK(FastFixedDtoa(0.01, 10, buffer, &length, &point)); 102 CHECK(FastFixedDtoa(0.01, 10, buffer, &length, &point));
103 CHECK_EQ("1", buffer.start()); 103 CHECK_EQ(0, strcmp("1", buffer.start()));
104 CHECK_EQ(-1, point); 104 CHECK_EQ(-1, point);
105 105
106 CHECK(FastFixedDtoa(0.001, 10, buffer, &length, &point)); 106 CHECK(FastFixedDtoa(0.001, 10, buffer, &length, &point));
107 CHECK_EQ("1", buffer.start()); 107 CHECK_EQ(0, strcmp("1", buffer.start()));
108 CHECK_EQ(-2, point); 108 CHECK_EQ(-2, point);
109 109
110 CHECK(FastFixedDtoa(0.0001, 10, buffer, &length, &point)); 110 CHECK(FastFixedDtoa(0.0001, 10, buffer, &length, &point));
111 CHECK_EQ("1", buffer.start()); 111 CHECK_EQ(0, strcmp("1", buffer.start()));
112 CHECK_EQ(-3, point); 112 CHECK_EQ(-3, point);
113 113
114 CHECK(FastFixedDtoa(0.00001, 10, buffer, &length, &point)); 114 CHECK(FastFixedDtoa(0.00001, 10, buffer, &length, &point));
115 CHECK_EQ("1", buffer.start()); 115 CHECK_EQ(0, strcmp("1", buffer.start()));
116 CHECK_EQ(-4, point); 116 CHECK_EQ(-4, point);
117 117
118 CHECK(FastFixedDtoa(0.000001, 10, buffer, &length, &point)); 118 CHECK(FastFixedDtoa(0.000001, 10, buffer, &length, &point));
119 CHECK_EQ("1", buffer.start()); 119 CHECK_EQ(0, strcmp("1", buffer.start()));
120 CHECK_EQ(-5, point); 120 CHECK_EQ(-5, point);
121 121
122 CHECK(FastFixedDtoa(0.0000001, 10, buffer, &length, &point)); 122 CHECK(FastFixedDtoa(0.0000001, 10, buffer, &length, &point));
123 CHECK_EQ("1", buffer.start()); 123 CHECK_EQ(0, strcmp("1", buffer.start()));
124 CHECK_EQ(-6, point); 124 CHECK_EQ(-6, point);
125 125
126 CHECK(FastFixedDtoa(0.00000001, 10, buffer, &length, &point)); 126 CHECK(FastFixedDtoa(0.00000001, 10, buffer, &length, &point));
127 CHECK_EQ("1", buffer.start()); 127 CHECK_EQ(0, strcmp("1", buffer.start()));
128 CHECK_EQ(-7, point); 128 CHECK_EQ(-7, point);
129 129
130 CHECK(FastFixedDtoa(0.000000001, 10, buffer, &length, &point)); 130 CHECK(FastFixedDtoa(0.000000001, 10, buffer, &length, &point));
131 CHECK_EQ("1", buffer.start()); 131 CHECK_EQ(0, strcmp("1", buffer.start()));
132 CHECK_EQ(-8, point); 132 CHECK_EQ(-8, point);
133 133
134 CHECK(FastFixedDtoa(0.0000000001, 15, buffer, &length, &point)); 134 CHECK(FastFixedDtoa(0.0000000001, 15, buffer, &length, &point));
135 CHECK_EQ("1", buffer.start()); 135 CHECK_EQ(0, strcmp("1", buffer.start()));
136 CHECK_EQ(-9, point); 136 CHECK_EQ(-9, point);
137 137
138 CHECK(FastFixedDtoa(0.00000000001, 15, buffer, &length, &point)); 138 CHECK(FastFixedDtoa(0.00000000001, 15, buffer, &length, &point));
139 CHECK_EQ("1", buffer.start()); 139 CHECK_EQ(0, strcmp("1", buffer.start()));
140 CHECK_EQ(-10, point); 140 CHECK_EQ(-10, point);
141 141
142 CHECK(FastFixedDtoa(0.000000000001, 15, buffer, &length, &point)); 142 CHECK(FastFixedDtoa(0.000000000001, 15, buffer, &length, &point));
143 CHECK_EQ("1", buffer.start()); 143 CHECK_EQ(0, strcmp("1", buffer.start()));
144 CHECK_EQ(-11, point); 144 CHECK_EQ(-11, point);
145 145
146 CHECK(FastFixedDtoa(0.0000000000001, 15, buffer, &length, &point)); 146 CHECK(FastFixedDtoa(0.0000000000001, 15, buffer, &length, &point));
147 CHECK_EQ("1", buffer.start()); 147 CHECK_EQ(0, strcmp("1", buffer.start()));
148 CHECK_EQ(-12, point); 148 CHECK_EQ(-12, point);
149 149
150 CHECK(FastFixedDtoa(0.00000000000001, 15, buffer, &length, &point)); 150 CHECK(FastFixedDtoa(0.00000000000001, 15, buffer, &length, &point));
151 CHECK_EQ("1", buffer.start()); 151 CHECK_EQ(0, strcmp("1", buffer.start()));
152 CHECK_EQ(-13, point); 152 CHECK_EQ(-13, point);
153 153
154 CHECK(FastFixedDtoa(0.000000000000001, 20, buffer, &length, &point)); 154 CHECK(FastFixedDtoa(0.000000000000001, 20, buffer, &length, &point));
155 CHECK_EQ("1", buffer.start()); 155 CHECK_EQ(0, strcmp("1", buffer.start()));
156 CHECK_EQ(-14, point); 156 CHECK_EQ(-14, point);
157 157
158 CHECK(FastFixedDtoa(0.0000000000000001, 20, buffer, &length, &point)); 158 CHECK(FastFixedDtoa(0.0000000000000001, 20, buffer, &length, &point));
159 CHECK_EQ("1", buffer.start()); 159 CHECK_EQ(0, strcmp("1", buffer.start()));
160 CHECK_EQ(-15, point); 160 CHECK_EQ(-15, point);
161 161
162 CHECK(FastFixedDtoa(0.00000000000000001, 20, buffer, &length, &point)); 162 CHECK(FastFixedDtoa(0.00000000000000001, 20, buffer, &length, &point));
163 CHECK_EQ("1", buffer.start()); 163 CHECK_EQ(0, strcmp("1", buffer.start()));
164 CHECK_EQ(-16, point); 164 CHECK_EQ(-16, point);
165 165
166 CHECK(FastFixedDtoa(0.000000000000000001, 20, buffer, &length, &point)); 166 CHECK(FastFixedDtoa(0.000000000000000001, 20, buffer, &length, &point));
167 CHECK_EQ("1", buffer.start()); 167 CHECK_EQ(0, strcmp("1", buffer.start()));
168 CHECK_EQ(-17, point); 168 CHECK_EQ(-17, point);
169 169
170 CHECK(FastFixedDtoa(0.0000000000000000001, 20, buffer, &length, &point)); 170 CHECK(FastFixedDtoa(0.0000000000000000001, 20, buffer, &length, &point));
171 CHECK_EQ("1", buffer.start()); 171 CHECK_EQ(0, strcmp("1", buffer.start()));
172 CHECK_EQ(-18, point); 172 CHECK_EQ(-18, point);
173 173
174 CHECK(FastFixedDtoa(0.00000000000000000001, 20, buffer, &length, &point)); 174 CHECK(FastFixedDtoa(0.00000000000000000001, 20, buffer, &length, &point));
175 CHECK_EQ("1", buffer.start()); 175 CHECK_EQ(0, strcmp("1", buffer.start()));
176 CHECK_EQ(-19, point); 176 CHECK_EQ(-19, point);
177 177
178 CHECK(FastFixedDtoa(0.10000000004, 10, buffer, &length, &point)); 178 CHECK(FastFixedDtoa(0.10000000004, 10, buffer, &length, &point));
179 CHECK_EQ("1", buffer.start()); 179 CHECK_EQ(0, strcmp("1", buffer.start()));
180 CHECK_EQ(0, point); 180 CHECK_EQ(0, point);
181 181
182 CHECK(FastFixedDtoa(0.01000000004, 10, buffer, &length, &point)); 182 CHECK(FastFixedDtoa(0.01000000004, 10, buffer, &length, &point));
183 CHECK_EQ("1", buffer.start()); 183 CHECK_EQ(0, strcmp("1", buffer.start()));
184 CHECK_EQ(-1, point); 184 CHECK_EQ(-1, point);
185 185
186 CHECK(FastFixedDtoa(0.00100000004, 10, buffer, &length, &point)); 186 CHECK(FastFixedDtoa(0.00100000004, 10, buffer, &length, &point));
187 CHECK_EQ("1", buffer.start()); 187 CHECK_EQ(0, strcmp("1", buffer.start()));
188 CHECK_EQ(-2, point); 188 CHECK_EQ(-2, point);
189 189
190 CHECK(FastFixedDtoa(0.00010000004, 10, buffer, &length, &point)); 190 CHECK(FastFixedDtoa(0.00010000004, 10, buffer, &length, &point));
191 CHECK_EQ("1", buffer.start()); 191 CHECK_EQ(0, strcmp("1", buffer.start()));
192 CHECK_EQ(-3, point); 192 CHECK_EQ(-3, point);
193 193
194 CHECK(FastFixedDtoa(0.00001000004, 10, buffer, &length, &point)); 194 CHECK(FastFixedDtoa(0.00001000004, 10, buffer, &length, &point));
195 CHECK_EQ("1", buffer.start()); 195 CHECK_EQ(0, strcmp("1", buffer.start()));
196 CHECK_EQ(-4, point); 196 CHECK_EQ(-4, point);
197 197
198 CHECK(FastFixedDtoa(0.00000100004, 10, buffer, &length, &point)); 198 CHECK(FastFixedDtoa(0.00000100004, 10, buffer, &length, &point));
199 CHECK_EQ("1", buffer.start()); 199 CHECK_EQ(0, strcmp("1", buffer.start()));
200 CHECK_EQ(-5, point); 200 CHECK_EQ(-5, point);
201 201
202 CHECK(FastFixedDtoa(0.00000010004, 10, buffer, &length, &point)); 202 CHECK(FastFixedDtoa(0.00000010004, 10, buffer, &length, &point));
203 CHECK_EQ("1", buffer.start()); 203 CHECK_EQ(0, strcmp("1", buffer.start()));
204 CHECK_EQ(-6, point); 204 CHECK_EQ(-6, point);
205 205
206 CHECK(FastFixedDtoa(0.00000001004, 10, buffer, &length, &point)); 206 CHECK(FastFixedDtoa(0.00000001004, 10, buffer, &length, &point));
207 CHECK_EQ("1", buffer.start()); 207 CHECK_EQ(0, strcmp("1", buffer.start()));
208 CHECK_EQ(-7, point); 208 CHECK_EQ(-7, point);
209 209
210 CHECK(FastFixedDtoa(0.00000000104, 10, buffer, &length, &point)); 210 CHECK(FastFixedDtoa(0.00000000104, 10, buffer, &length, &point));
211 CHECK_EQ("1", buffer.start()); 211 CHECK_EQ(0, strcmp("1", buffer.start()));
212 CHECK_EQ(-8, point); 212 CHECK_EQ(-8, point);
213 213
214 CHECK(FastFixedDtoa(0.0000000001000004, 15, buffer, &length, &point)); 214 CHECK(FastFixedDtoa(0.0000000001000004, 15, buffer, &length, &point));
215 CHECK_EQ("1", buffer.start()); 215 CHECK_EQ(0, strcmp("1", buffer.start()));
216 CHECK_EQ(-9, point); 216 CHECK_EQ(-9, point);
217 217
218 CHECK(FastFixedDtoa(0.0000000000100004, 15, buffer, &length, &point)); 218 CHECK(FastFixedDtoa(0.0000000000100004, 15, buffer, &length, &point));
219 CHECK_EQ("1", buffer.start()); 219 CHECK_EQ(0, strcmp("1", buffer.start()));
220 CHECK_EQ(-10, point); 220 CHECK_EQ(-10, point);
221 221
222 CHECK(FastFixedDtoa(0.0000000000010004, 15, buffer, &length, &point)); 222 CHECK(FastFixedDtoa(0.0000000000010004, 15, buffer, &length, &point));
223 CHECK_EQ("1", buffer.start()); 223 CHECK_EQ(0, strcmp("1", buffer.start()));
224 CHECK_EQ(-11, point); 224 CHECK_EQ(-11, point);
225 225
226 CHECK(FastFixedDtoa(0.0000000000001004, 15, buffer, &length, &point)); 226 CHECK(FastFixedDtoa(0.0000000000001004, 15, buffer, &length, &point));
227 CHECK_EQ("1", buffer.start()); 227 CHECK_EQ(0, strcmp("1", buffer.start()));
228 CHECK_EQ(-12, point); 228 CHECK_EQ(-12, point);
229 229
230 CHECK(FastFixedDtoa(0.0000000000000104, 15, buffer, &length, &point)); 230 CHECK(FastFixedDtoa(0.0000000000000104, 15, buffer, &length, &point));
231 CHECK_EQ("1", buffer.start()); 231 CHECK_EQ(0, strcmp("1", buffer.start()));
232 CHECK_EQ(-13, point); 232 CHECK_EQ(-13, point);
233 233
234 CHECK(FastFixedDtoa(0.000000000000001000004, 20, buffer, &length, &point)); 234 CHECK(FastFixedDtoa(0.000000000000001000004, 20, buffer, &length, &point));
235 CHECK_EQ("1", buffer.start()); 235 CHECK_EQ(0, strcmp("1", buffer.start()));
236 CHECK_EQ(-14, point); 236 CHECK_EQ(-14, point);
237 237
238 CHECK(FastFixedDtoa(0.000000000000000100004, 20, buffer, &length, &point)); 238 CHECK(FastFixedDtoa(0.000000000000000100004, 20, buffer, &length, &point));
239 CHECK_EQ("1", buffer.start()); 239 CHECK_EQ(0, strcmp("1", buffer.start()));
240 CHECK_EQ(-15, point); 240 CHECK_EQ(-15, point);
241 241
242 CHECK(FastFixedDtoa(0.000000000000000010004, 20, buffer, &length, &point)); 242 CHECK(FastFixedDtoa(0.000000000000000010004, 20, buffer, &length, &point));
243 CHECK_EQ("1", buffer.start()); 243 CHECK_EQ(0, strcmp("1", buffer.start()));
244 CHECK_EQ(-16, point); 244 CHECK_EQ(-16, point);
245 245
246 CHECK(FastFixedDtoa(0.000000000000000001004, 20, buffer, &length, &point)); 246 CHECK(FastFixedDtoa(0.000000000000000001004, 20, buffer, &length, &point));
247 CHECK_EQ("1", buffer.start()); 247 CHECK_EQ(0, strcmp("1", buffer.start()));
248 CHECK_EQ(-17, point); 248 CHECK_EQ(-17, point);
249 249
250 CHECK(FastFixedDtoa(0.000000000000000000104, 20, buffer, &length, &point)); 250 CHECK(FastFixedDtoa(0.000000000000000000104, 20, buffer, &length, &point));
251 CHECK_EQ("1", buffer.start()); 251 CHECK_EQ(0, strcmp("1", buffer.start()));
252 CHECK_EQ(-18, point); 252 CHECK_EQ(-18, point);
253 253
254 CHECK(FastFixedDtoa(0.000000000000000000014, 20, buffer, &length, &point)); 254 CHECK(FastFixedDtoa(0.000000000000000000014, 20, buffer, &length, &point));
255 CHECK_EQ("1", buffer.start()); 255 CHECK_EQ(0, strcmp("1", buffer.start()));
256 CHECK_EQ(-19, point); 256 CHECK_EQ(-19, point);
257 257
258 CHECK(FastFixedDtoa(0.10000000006, 10, buffer, &length, &point)); 258 CHECK(FastFixedDtoa(0.10000000006, 10, buffer, &length, &point));
259 CHECK_EQ("1000000001", buffer.start()); 259 CHECK_EQ(0, strcmp("1000000001", buffer.start()));
260 CHECK_EQ(0, point); 260 CHECK_EQ(0, point);
261 261
262 CHECK(FastFixedDtoa(0.01000000006, 10, buffer, &length, &point)); 262 CHECK(FastFixedDtoa(0.01000000006, 10, buffer, &length, &point));
263 CHECK_EQ("100000001", buffer.start()); 263 CHECK_EQ(0, strcmp("100000001", buffer.start()));
264 CHECK_EQ(-1, point); 264 CHECK_EQ(-1, point);
265 265
266 CHECK(FastFixedDtoa(0.00100000006, 10, buffer, &length, &point)); 266 CHECK(FastFixedDtoa(0.00100000006, 10, buffer, &length, &point));
267 CHECK_EQ("10000001", buffer.start()); 267 CHECK_EQ(0, strcmp("10000001", buffer.start()));
268 CHECK_EQ(-2, point); 268 CHECK_EQ(-2, point);
269 269
270 CHECK(FastFixedDtoa(0.00010000006, 10, buffer, &length, &point)); 270 CHECK(FastFixedDtoa(0.00010000006, 10, buffer, &length, &point));
271 CHECK_EQ("1000001", buffer.start()); 271 CHECK_EQ(0, strcmp("1000001", buffer.start()));
272 CHECK_EQ(-3, point); 272 CHECK_EQ(-3, point);
273 273
274 CHECK(FastFixedDtoa(0.00001000006, 10, buffer, &length, &point)); 274 CHECK(FastFixedDtoa(0.00001000006, 10, buffer, &length, &point));
275 CHECK_EQ("100001", buffer.start()); 275 CHECK_EQ(0, strcmp("100001", buffer.start()));
276 CHECK_EQ(-4, point); 276 CHECK_EQ(-4, point);
277 277
278 CHECK(FastFixedDtoa(0.00000100006, 10, buffer, &length, &point)); 278 CHECK(FastFixedDtoa(0.00000100006, 10, buffer, &length, &point));
279 CHECK_EQ("10001", buffer.start()); 279 CHECK_EQ(0, strcmp("10001", buffer.start()));
280 CHECK_EQ(-5, point); 280 CHECK_EQ(-5, point);
281 281
282 CHECK(FastFixedDtoa(0.00000010006, 10, buffer, &length, &point)); 282 CHECK(FastFixedDtoa(0.00000010006, 10, buffer, &length, &point));
283 CHECK_EQ("1001", buffer.start()); 283 CHECK_EQ(0, strcmp("1001", buffer.start()));
284 CHECK_EQ(-6, point); 284 CHECK_EQ(-6, point);
285 285
286 CHECK(FastFixedDtoa(0.00000001006, 10, buffer, &length, &point)); 286 CHECK(FastFixedDtoa(0.00000001006, 10, buffer, &length, &point));
287 CHECK_EQ("101", buffer.start()); 287 CHECK_EQ(0, strcmp("101", buffer.start()));
288 CHECK_EQ(-7, point); 288 CHECK_EQ(-7, point);
289 289
290 CHECK(FastFixedDtoa(0.00000000106, 10, buffer, &length, &point)); 290 CHECK(FastFixedDtoa(0.00000000106, 10, buffer, &length, &point));
291 CHECK_EQ("11", buffer.start()); 291 CHECK_EQ(0, strcmp("11", buffer.start()));
292 CHECK_EQ(-8, point); 292 CHECK_EQ(-8, point);
293 293
294 CHECK(FastFixedDtoa(0.0000000001000006, 15, buffer, &length, &point)); 294 CHECK(FastFixedDtoa(0.0000000001000006, 15, buffer, &length, &point));
295 CHECK_EQ("100001", buffer.start()); 295 CHECK_EQ(0, strcmp("100001", buffer.start()));
296 CHECK_EQ(-9, point); 296 CHECK_EQ(-9, point);
297 297
298 CHECK(FastFixedDtoa(0.0000000000100006, 15, buffer, &length, &point)); 298 CHECK(FastFixedDtoa(0.0000000000100006, 15, buffer, &length, &point));
299 CHECK_EQ("10001", buffer.start()); 299 CHECK_EQ(0, strcmp("10001", buffer.start()));
300 CHECK_EQ(-10, point); 300 CHECK_EQ(-10, point);
301 301
302 CHECK(FastFixedDtoa(0.0000000000010006, 15, buffer, &length, &point)); 302 CHECK(FastFixedDtoa(0.0000000000010006, 15, buffer, &length, &point));
303 CHECK_EQ("1001", buffer.start()); 303 CHECK_EQ(0, strcmp("1001", buffer.start()));
304 CHECK_EQ(-11, point); 304 CHECK_EQ(-11, point);
305 305
306 CHECK(FastFixedDtoa(0.0000000000001006, 15, buffer, &length, &point)); 306 CHECK(FastFixedDtoa(0.0000000000001006, 15, buffer, &length, &point));
307 CHECK_EQ("101", buffer.start()); 307 CHECK_EQ(0, strcmp("101", buffer.start()));
308 CHECK_EQ(-12, point); 308 CHECK_EQ(-12, point);
309 309
310 CHECK(FastFixedDtoa(0.0000000000000106, 15, buffer, &length, &point)); 310 CHECK(FastFixedDtoa(0.0000000000000106, 15, buffer, &length, &point));
311 CHECK_EQ("11", buffer.start()); 311 CHECK_EQ(0, strcmp("11", buffer.start()));
312 CHECK_EQ(-13, point); 312 CHECK_EQ(-13, point);
313 313
314 CHECK(FastFixedDtoa(0.000000000000001000006, 20, buffer, &length, &point)); 314 CHECK(FastFixedDtoa(0.000000000000001000006, 20, buffer, &length, &point));
315 CHECK_EQ("100001", buffer.start()); 315 CHECK_EQ(0, strcmp("100001", buffer.start()));
316 CHECK_EQ(-14, point); 316 CHECK_EQ(-14, point);
317 317
318 CHECK(FastFixedDtoa(0.000000000000000100006, 20, buffer, &length, &point)); 318 CHECK(FastFixedDtoa(0.000000000000000100006, 20, buffer, &length, &point));
319 CHECK_EQ("10001", buffer.start()); 319 CHECK_EQ(0, strcmp("10001", buffer.start()));
320 CHECK_EQ(-15, point); 320 CHECK_EQ(-15, point);
321 321
322 CHECK(FastFixedDtoa(0.000000000000000010006, 20, buffer, &length, &point)); 322 CHECK(FastFixedDtoa(0.000000000000000010006, 20, buffer, &length, &point));
323 CHECK_EQ("1001", buffer.start()); 323 CHECK_EQ(0, strcmp("1001", buffer.start()));
324 CHECK_EQ(-16, point); 324 CHECK_EQ(-16, point);
325 325
326 CHECK(FastFixedDtoa(0.000000000000000001006, 20, buffer, &length, &point)); 326 CHECK(FastFixedDtoa(0.000000000000000001006, 20, buffer, &length, &point));
327 CHECK_EQ("101", buffer.start()); 327 CHECK_EQ(0, strcmp("101", buffer.start()));
328 CHECK_EQ(-17, point); 328 CHECK_EQ(-17, point);
329 329
330 CHECK(FastFixedDtoa(0.000000000000000000106, 20, buffer, &length, &point)); 330 CHECK(FastFixedDtoa(0.000000000000000000106, 20, buffer, &length, &point));
331 CHECK_EQ("11", buffer.start()); 331 CHECK_EQ(0, strcmp("11", buffer.start()));
332 CHECK_EQ(-18, point); 332 CHECK_EQ(-18, point);
333 333
334 CHECK(FastFixedDtoa(0.000000000000000000016, 20, buffer, &length, &point)); 334 CHECK(FastFixedDtoa(0.000000000000000000016, 20, buffer, &length, &point));
335 CHECK_EQ("2", buffer.start()); 335 CHECK_EQ(0, strcmp("2", buffer.start()));
336 CHECK_EQ(-19, point); 336 CHECK_EQ(-19, point);
337 337
338 CHECK(FastFixedDtoa(0.6, 0, buffer, &length, &point)); 338 CHECK(FastFixedDtoa(0.6, 0, buffer, &length, &point));
339 CHECK_EQ("1", buffer.start()); 339 CHECK_EQ(0, strcmp("1", buffer.start()));
340 CHECK_EQ(1, point); 340 CHECK_EQ(1, point);
341 341
342 CHECK(FastFixedDtoa(0.96, 1, buffer, &length, &point)); 342 CHECK(FastFixedDtoa(0.96, 1, buffer, &length, &point));
343 CHECK_EQ("1", buffer.start()); 343 CHECK_EQ(0, strcmp("1", buffer.start()));
344 CHECK_EQ(1, point); 344 CHECK_EQ(1, point);
345 345
346 CHECK(FastFixedDtoa(0.996, 2, buffer, &length, &point)); 346 CHECK(FastFixedDtoa(0.996, 2, buffer, &length, &point));
347 CHECK_EQ("1", buffer.start()); 347 CHECK_EQ(0, strcmp("1", buffer.start()));
348 CHECK_EQ(1, point); 348 CHECK_EQ(1, point);
349 349
350 CHECK(FastFixedDtoa(0.9996, 3, buffer, &length, &point)); 350 CHECK(FastFixedDtoa(0.9996, 3, buffer, &length, &point));
351 CHECK_EQ("1", buffer.start()); 351 CHECK_EQ(0, strcmp("1", buffer.start()));
352 CHECK_EQ(1, point); 352 CHECK_EQ(1, point);
353 353
354 CHECK(FastFixedDtoa(0.99996, 4, buffer, &length, &point)); 354 CHECK(FastFixedDtoa(0.99996, 4, buffer, &length, &point));
355 CHECK_EQ("1", buffer.start()); 355 CHECK_EQ(0, strcmp("1", buffer.start()));
356 CHECK_EQ(1, point); 356 CHECK_EQ(1, point);
357 357
358 CHECK(FastFixedDtoa(0.999996, 5, buffer, &length, &point)); 358 CHECK(FastFixedDtoa(0.999996, 5, buffer, &length, &point));
359 CHECK_EQ("1", buffer.start()); 359 CHECK_EQ(0, strcmp("1", buffer.start()));
360 CHECK_EQ(1, point); 360 CHECK_EQ(1, point);
361 361
362 CHECK(FastFixedDtoa(0.9999996, 6, buffer, &length, &point)); 362 CHECK(FastFixedDtoa(0.9999996, 6, buffer, &length, &point));
363 CHECK_EQ("1", buffer.start()); 363 CHECK_EQ(0, strcmp("1", buffer.start()));
364 CHECK_EQ(1, point); 364 CHECK_EQ(1, point);
365 365
366 CHECK(FastFixedDtoa(0.99999996, 7, buffer, &length, &point)); 366 CHECK(FastFixedDtoa(0.99999996, 7, buffer, &length, &point));
367 CHECK_EQ("1", buffer.start()); 367 CHECK_EQ(0, strcmp("1", buffer.start()));
368 CHECK_EQ(1, point); 368 CHECK_EQ(1, point);
369 369
370 CHECK(FastFixedDtoa(0.999999996, 8, buffer, &length, &point)); 370 CHECK(FastFixedDtoa(0.999999996, 8, buffer, &length, &point));
371 CHECK_EQ("1", buffer.start()); 371 CHECK_EQ(0, strcmp("1", buffer.start()));
372 CHECK_EQ(1, point); 372 CHECK_EQ(1, point);
373 373
374 CHECK(FastFixedDtoa(0.9999999996, 9, buffer, &length, &point)); 374 CHECK(FastFixedDtoa(0.9999999996, 9, buffer, &length, &point));
375 CHECK_EQ("1", buffer.start()); 375 CHECK_EQ(0, strcmp("1", buffer.start()));
376 CHECK_EQ(1, point); 376 CHECK_EQ(1, point);
377 377
378 CHECK(FastFixedDtoa(0.99999999996, 10, buffer, &length, &point)); 378 CHECK(FastFixedDtoa(0.99999999996, 10, buffer, &length, &point));
379 CHECK_EQ("1", buffer.start()); 379 CHECK_EQ(0, strcmp("1", buffer.start()));
380 CHECK_EQ(1, point); 380 CHECK_EQ(1, point);
381 381
382 CHECK(FastFixedDtoa(0.999999999996, 11, buffer, &length, &point)); 382 CHECK(FastFixedDtoa(0.999999999996, 11, buffer, &length, &point));
383 CHECK_EQ("1", buffer.start()); 383 CHECK_EQ(0, strcmp("1", buffer.start()));
384 CHECK_EQ(1, point); 384 CHECK_EQ(1, point);
385 385
386 CHECK(FastFixedDtoa(0.9999999999996, 12, buffer, &length, &point)); 386 CHECK(FastFixedDtoa(0.9999999999996, 12, buffer, &length, &point));
387 CHECK_EQ("1", buffer.start()); 387 CHECK_EQ(0, strcmp("1", buffer.start()));
388 CHECK_EQ(1, point); 388 CHECK_EQ(1, point);
389 389
390 CHECK(FastFixedDtoa(0.99999999999996, 13, buffer, &length, &point)); 390 CHECK(FastFixedDtoa(0.99999999999996, 13, buffer, &length, &point));
391 CHECK_EQ("1", buffer.start()); 391 CHECK_EQ(0, strcmp("1", buffer.start()));
392 CHECK_EQ(1, point); 392 CHECK_EQ(1, point);
393 393
394 CHECK(FastFixedDtoa(0.999999999999996, 14, buffer, &length, &point)); 394 CHECK(FastFixedDtoa(0.999999999999996, 14, buffer, &length, &point));
395 CHECK_EQ("1", buffer.start()); 395 CHECK_EQ(0, strcmp("1", buffer.start()));
396 CHECK_EQ(1, point); 396 CHECK_EQ(1, point);
397 397
398 CHECK(FastFixedDtoa(0.9999999999999996, 15, buffer, &length, &point)); 398 CHECK(FastFixedDtoa(0.9999999999999996, 15, buffer, &length, &point));
399 CHECK_EQ("1", buffer.start()); 399 CHECK_EQ(0, strcmp("1", buffer.start()));
400 CHECK_EQ(1, point); 400 CHECK_EQ(1, point);
401 401
402 CHECK(FastFixedDtoa(0.00999999999999996, 16, buffer, &length, &point)); 402 CHECK(FastFixedDtoa(0.00999999999999996, 16, buffer, &length, &point));
403 CHECK_EQ("1", buffer.start()); 403 CHECK_EQ(0, strcmp("1", buffer.start()));
404 CHECK_EQ(-1, point); 404 CHECK_EQ(-1, point);
405 405
406 CHECK(FastFixedDtoa(0.000999999999999996, 17, buffer, &length, &point)); 406 CHECK(FastFixedDtoa(0.000999999999999996, 17, buffer, &length, &point));
407 CHECK_EQ("1", buffer.start()); 407 CHECK_EQ(0, strcmp("1", buffer.start()));
408 CHECK_EQ(-2, point); 408 CHECK_EQ(-2, point);
409 409
410 CHECK(FastFixedDtoa(0.0000999999999999996, 18, buffer, &length, &point)); 410 CHECK(FastFixedDtoa(0.0000999999999999996, 18, buffer, &length, &point));
411 CHECK_EQ("1", buffer.start()); 411 CHECK_EQ(0, strcmp("1", buffer.start()));
412 CHECK_EQ(-3, point); 412 CHECK_EQ(-3, point);
413 413
414 CHECK(FastFixedDtoa(0.00000999999999999996, 19, buffer, &length, &point)); 414 CHECK(FastFixedDtoa(0.00000999999999999996, 19, buffer, &length, &point));
415 CHECK_EQ("1", buffer.start()); 415 CHECK_EQ(0, strcmp("1", buffer.start()));
416 CHECK_EQ(-4, point); 416 CHECK_EQ(-4, point);
417 417
418 CHECK(FastFixedDtoa(0.000000999999999999996, 20, buffer, &length, &point)); 418 CHECK(FastFixedDtoa(0.000000999999999999996, 20, buffer, &length, &point));
419 CHECK_EQ("1", buffer.start()); 419 CHECK_EQ(0, strcmp("1", buffer.start()));
420 CHECK_EQ(-5, point); 420 CHECK_EQ(-5, point);
421 421
422 CHECK(FastFixedDtoa(323423.234234, 10, buffer, &length, &point)); 422 CHECK(FastFixedDtoa(323423.234234, 10, buffer, &length, &point));
423 CHECK_EQ("323423234234", buffer.start()); 423 CHECK_EQ(0, strcmp("323423234234", buffer.start()));
424 CHECK_EQ(6, point); 424 CHECK_EQ(6, point);
425 425
426 CHECK(FastFixedDtoa(12345678.901234, 4, buffer, &length, &point)); 426 CHECK(FastFixedDtoa(12345678.901234, 4, buffer, &length, &point));
427 CHECK_EQ("123456789012", buffer.start()); 427 CHECK_EQ(0, strcmp("123456789012", buffer.start()));
428 CHECK_EQ(8, point); 428 CHECK_EQ(8, point);
429 429
430 CHECK(FastFixedDtoa(98765.432109, 5, buffer, &length, &point)); 430 CHECK(FastFixedDtoa(98765.432109, 5, buffer, &length, &point));
431 CHECK_EQ("9876543211", buffer.start()); 431 CHECK_EQ(0, strcmp("9876543211", buffer.start()));
432 CHECK_EQ(5, point); 432 CHECK_EQ(5, point);
433 433
434 CHECK(FastFixedDtoa(42, 20, buffer, &length, &point)); 434 CHECK(FastFixedDtoa(42, 20, buffer, &length, &point));
435 CHECK_EQ("42", buffer.start()); 435 CHECK_EQ(0, strcmp("42", buffer.start()));
436 CHECK_EQ(2, point); 436 CHECK_EQ(2, point);
437 437
438 CHECK(FastFixedDtoa(0.5, 0, buffer, &length, &point)); 438 CHECK(FastFixedDtoa(0.5, 0, buffer, &length, &point));
439 CHECK_EQ("1", buffer.start()); 439 CHECK_EQ(0, strcmp("1", buffer.start()));
440 CHECK_EQ(1, point); 440 CHECK_EQ(1, point);
441 441
442 CHECK(FastFixedDtoa(1e-23, 10, buffer, &length, &point)); 442 CHECK(FastFixedDtoa(1e-23, 10, buffer, &length, &point));
443 CHECK_EQ("", buffer.start()); 443 CHECK_EQ(0, strcmp("", buffer.start()));
444 CHECK_EQ(-10, point); 444 CHECK_EQ(-10, point);
445 445
446 CHECK(FastFixedDtoa(1e-123, 2, buffer, &length, &point)); 446 CHECK(FastFixedDtoa(1e-123, 2, buffer, &length, &point));
447 CHECK_EQ("", buffer.start()); 447 CHECK_EQ(0, strcmp("", buffer.start()));
448 CHECK_EQ(-2, point); 448 CHECK_EQ(-2, point);
449 449
450 CHECK(FastFixedDtoa(1e-123, 0, buffer, &length, &point)); 450 CHECK(FastFixedDtoa(1e-123, 0, buffer, &length, &point));
451 CHECK_EQ("", buffer.start()); 451 CHECK_EQ(0, strcmp("", buffer.start()));
452 CHECK_EQ(0, point); 452 CHECK_EQ(0, point);
453 453
454 CHECK(FastFixedDtoa(1e-23, 20, buffer, &length, &point)); 454 CHECK(FastFixedDtoa(1e-23, 20, buffer, &length, &point));
455 CHECK_EQ("", buffer.start()); 455 CHECK_EQ(0, strcmp("", buffer.start()));
456 CHECK_EQ(-20, point); 456 CHECK_EQ(-20, point);
457 457
458 CHECK(FastFixedDtoa(1e-21, 20, buffer, &length, &point)); 458 CHECK(FastFixedDtoa(1e-21, 20, buffer, &length, &point));
459 CHECK_EQ("", buffer.start()); 459 CHECK_EQ(0, strcmp("", buffer.start()));
460 CHECK_EQ(-20, point); 460 CHECK_EQ(-20, point);
461 461
462 CHECK(FastFixedDtoa(1e-22, 20, buffer, &length, &point)); 462 CHECK(FastFixedDtoa(1e-22, 20, buffer, &length, &point));
463 CHECK_EQ("", buffer.start()); 463 CHECK_EQ(0, strcmp("", buffer.start()));
464 CHECK_EQ(-20, point); 464 CHECK_EQ(-20, point);
465 465
466 CHECK(FastFixedDtoa(6e-21, 20, buffer, &length, &point)); 466 CHECK(FastFixedDtoa(6e-21, 20, buffer, &length, &point));
467 CHECK_EQ("1", buffer.start()); 467 CHECK_EQ(0, strcmp("1", buffer.start()));
468 CHECK_EQ(-19, point); 468 CHECK_EQ(-19, point);
469 469
470 CHECK(FastFixedDtoa(9.1193616301674545152000000e+19, 0, 470 CHECK(FastFixedDtoa(9.1193616301674545152000000e+19, 0,
471 buffer, &length, &point)); 471 buffer, &length, &point));
472 CHECK_EQ("91193616301674545152", buffer.start()); 472 CHECK_EQ(0, strcmp("91193616301674545152", buffer.start()));
473 CHECK_EQ(20, point); 473 CHECK_EQ(20, point);
474 474
475 CHECK(FastFixedDtoa(4.8184662102767651659096515e-04, 19, 475 CHECK(FastFixedDtoa(4.8184662102767651659096515e-04, 19,
476 buffer, &length, &point)); 476 buffer, &length, &point));
477 CHECK_EQ("4818466210276765", buffer.start()); 477 CHECK_EQ(0, strcmp("4818466210276765", buffer.start()));
478 CHECK_EQ(-3, point); 478 CHECK_EQ(-3, point);
479 479
480 CHECK(FastFixedDtoa(1.9023164229540652612705182e-23, 8, 480 CHECK(FastFixedDtoa(1.9023164229540652612705182e-23, 8,
481 buffer, &length, &point)); 481 buffer, &length, &point));
482 CHECK_EQ("", buffer.start()); 482 CHECK_EQ(0, strcmp("", buffer.start()));
483 CHECK_EQ(-8, point); 483 CHECK_EQ(-8, point);
484 484
485 CHECK(FastFixedDtoa(1000000000000000128.0, 0, 485 CHECK(FastFixedDtoa(1000000000000000128.0, 0,
486 buffer, &length, &point)); 486 buffer, &length, &point));
487 CHECK_EQ("1000000000000000128", buffer.start()); 487 CHECK_EQ(0, strcmp("1000000000000000128", buffer.start()));
488 CHECK_EQ(19, point); 488 CHECK_EQ(19, point);
489 } 489 }
490 490
491 491
492 TEST(FastFixedDtoaGayFixed) { 492 TEST(FastFixedDtoaGayFixed) {
493 char buffer_container[kBufferSize]; 493 char buffer_container[kBufferSize];
494 Vector<char> buffer(buffer_container, kBufferSize); 494 Vector<char> buffer(buffer_container, kBufferSize);
495 bool status; 495 bool status;
496 int length; 496 int length;
497 int point; 497 int point;
498 498
499 Vector<const PrecomputedFixed> precomputed = 499 Vector<const PrecomputedFixed> precomputed =
500 PrecomputedFixedRepresentations(); 500 PrecomputedFixedRepresentations();
501 for (int i = 0; i < precomputed.length(); ++i) { 501 for (int i = 0; i < precomputed.length(); ++i) {
502 const PrecomputedFixed current_test = precomputed[i]; 502 const PrecomputedFixed current_test = precomputed[i];
503 double v = current_test.v; 503 double v = current_test.v;
504 int number_digits = current_test.number_digits; 504 int number_digits = current_test.number_digits;
505 status = FastFixedDtoa(v, number_digits, 505 status = FastFixedDtoa(v, number_digits,
506 buffer, &length, &point); 506 buffer, &length, &point);
507 CHECK(status); 507 CHECK(status);
508 CHECK_EQ(current_test.decimal_point, point); 508 CHECK_EQ(current_test.decimal_point, point);
509 CHECK_GE(number_digits, length - point); 509 CHECK_GE(number_digits, length - point);
510 CHECK_EQ(current_test.representation, buffer.start()); 510 CHECK_EQ(0, strcmp(current_test.representation, buffer.start()));
511 } 511 }
512 } 512 }
OLDNEW
« no previous file with comments | « test/cctest/test-feedback-vector.cc ('k') | test/cctest/test-flags.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698