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

Side by Side Diff: test/cctest/test-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-deoptimization.cc ('k') | test/cctest/test-fast-dtoa.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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 57
58 58
59 TEST(DtoaVariousDoubles) { 59 TEST(DtoaVariousDoubles) {
60 char buffer_container[kBufferSize]; 60 char buffer_container[kBufferSize];
61 Vector<char> buffer(buffer_container, kBufferSize); 61 Vector<char> buffer(buffer_container, kBufferSize);
62 int length; 62 int length;
63 int point; 63 int point;
64 int sign; 64 int sign;
65 65
66 DoubleToAscii(0.0, DTOA_SHORTEST, 0, buffer, &sign, &length, &point); 66 DoubleToAscii(0.0, DTOA_SHORTEST, 0, buffer, &sign, &length, &point);
67 CHECK_EQ("0", buffer.start()); 67 CHECK_EQ(0, strcmp("0", buffer.start()));
68 CHECK_EQ(1, point); 68 CHECK_EQ(1, point);
69 69
70 DoubleToAscii(0.0, DTOA_FIXED, 2, buffer, &sign, &length, &point); 70 DoubleToAscii(0.0, DTOA_FIXED, 2, buffer, &sign, &length, &point);
71 CHECK_EQ(1, length); 71 CHECK_EQ(1, length);
72 CHECK_EQ("0", buffer.start()); 72 CHECK_EQ(0, strcmp("0", buffer.start()));
73 CHECK_EQ(1, point); 73 CHECK_EQ(1, point);
74 74
75 DoubleToAscii(0.0, DTOA_PRECISION, 3, buffer, &sign, &length, &point); 75 DoubleToAscii(0.0, DTOA_PRECISION, 3, buffer, &sign, &length, &point);
76 CHECK_EQ(1, length); 76 CHECK_EQ(1, length);
77 CHECK_EQ("0", buffer.start()); 77 CHECK_EQ(0, strcmp("0", buffer.start()));
78 CHECK_EQ(1, point); 78 CHECK_EQ(1, point);
79 79
80 DoubleToAscii(1.0, DTOA_SHORTEST, 0, buffer, &sign, &length, &point); 80 DoubleToAscii(1.0, DTOA_SHORTEST, 0, buffer, &sign, &length, &point);
81 CHECK_EQ("1", buffer.start()); 81 CHECK_EQ(0, strcmp("1", buffer.start()));
82 CHECK_EQ(1, point); 82 CHECK_EQ(1, point);
83 83
84 DoubleToAscii(1.0, DTOA_FIXED, 3, buffer, &sign, &length, &point); 84 DoubleToAscii(1.0, DTOA_FIXED, 3, buffer, &sign, &length, &point);
85 CHECK_GE(3, length - point); 85 CHECK_GE(3, length - point);
86 TrimRepresentation(buffer); 86 TrimRepresentation(buffer);
87 CHECK_EQ("1", buffer.start()); 87 CHECK_EQ(0, strcmp("1", buffer.start()));
88 CHECK_EQ(1, point); 88 CHECK_EQ(1, point);
89 89
90 DoubleToAscii(1.0, DTOA_PRECISION, 3, buffer, &sign, &length, &point); 90 DoubleToAscii(1.0, DTOA_PRECISION, 3, buffer, &sign, &length, &point);
91 CHECK_GE(3, length); 91 CHECK_GE(3, length);
92 TrimRepresentation(buffer); 92 TrimRepresentation(buffer);
93 CHECK_EQ("1", buffer.start()); 93 CHECK_EQ(0, strcmp("1", buffer.start()));
94 CHECK_EQ(1, point); 94 CHECK_EQ(1, point);
95 95
96 DoubleToAscii(1.5, DTOA_SHORTEST, 0, buffer, &sign, &length, &point); 96 DoubleToAscii(1.5, DTOA_SHORTEST, 0, buffer, &sign, &length, &point);
97 CHECK_EQ("15", buffer.start()); 97 CHECK_EQ(0, strcmp("15", buffer.start()));
98 CHECK_EQ(1, point); 98 CHECK_EQ(1, point);
99 99
100 DoubleToAscii(1.5, DTOA_FIXED, 10, buffer, &sign, &length, &point); 100 DoubleToAscii(1.5, DTOA_FIXED, 10, buffer, &sign, &length, &point);
101 CHECK_GE(10, length - point); 101 CHECK_GE(10, length - point);
102 TrimRepresentation(buffer); 102 TrimRepresentation(buffer);
103 CHECK_EQ("15", buffer.start()); 103 CHECK_EQ(0, strcmp("15", buffer.start()));
104 CHECK_EQ(1, point); 104 CHECK_EQ(1, point);
105 105
106 DoubleToAscii(1.5, DTOA_PRECISION, 10, buffer, &sign, &length, &point); 106 DoubleToAscii(1.5, DTOA_PRECISION, 10, buffer, &sign, &length, &point);
107 CHECK_GE(10, length); 107 CHECK_GE(10, length);
108 TrimRepresentation(buffer); 108 TrimRepresentation(buffer);
109 CHECK_EQ("15", buffer.start()); 109 CHECK_EQ(0, strcmp("15", buffer.start()));
110 CHECK_EQ(1, point); 110 CHECK_EQ(1, point);
111 111
112 double min_double = 5e-324; 112 double min_double = 5e-324;
113 DoubleToAscii(min_double, DTOA_SHORTEST, 0, buffer, &sign, &length, &point); 113 DoubleToAscii(min_double, DTOA_SHORTEST, 0, buffer, &sign, &length, &point);
114 CHECK_EQ("5", buffer.start()); 114 CHECK_EQ(0, strcmp("5", buffer.start()));
115 CHECK_EQ(-323, point); 115 CHECK_EQ(-323, point);
116 116
117 DoubleToAscii(min_double, DTOA_FIXED, 5, buffer, &sign, &length, &point); 117 DoubleToAscii(min_double, DTOA_FIXED, 5, buffer, &sign, &length, &point);
118 CHECK_GE(5, length - point); 118 CHECK_GE(5, length - point);
119 TrimRepresentation(buffer); 119 TrimRepresentation(buffer);
120 CHECK_EQ("", buffer.start()); 120 CHECK_EQ(0, strcmp("", buffer.start()));
121 CHECK_GE(-5, point); 121 CHECK_GE(-5, point);
122 122
123 DoubleToAscii(min_double, DTOA_PRECISION, 5, buffer, &sign, &length, &point); 123 DoubleToAscii(min_double, DTOA_PRECISION, 5, buffer, &sign, &length, &point);
124 CHECK_GE(5, length); 124 CHECK_GE(5, length);
125 TrimRepresentation(buffer); 125 TrimRepresentation(buffer);
126 CHECK_EQ("49407", buffer.start()); 126 CHECK_EQ(0, strcmp("49407", buffer.start()));
127 CHECK_EQ(-323, point); 127 CHECK_EQ(-323, point);
128 128
129 double max_double = 1.7976931348623157e308; 129 double max_double = 1.7976931348623157e308;
130 DoubleToAscii(max_double, DTOA_SHORTEST, 0, buffer, &sign, &length, &point); 130 DoubleToAscii(max_double, DTOA_SHORTEST, 0, buffer, &sign, &length, &point);
131 CHECK_EQ("17976931348623157", buffer.start()); 131 CHECK_EQ(0, strcmp("17976931348623157", buffer.start()));
132 CHECK_EQ(309, point); 132 CHECK_EQ(309, point);
133 133
134 DoubleToAscii(max_double, DTOA_PRECISION, 7, buffer, &sign, &length, &point); 134 DoubleToAscii(max_double, DTOA_PRECISION, 7, buffer, &sign, &length, &point);
135 CHECK_GE(7, length); 135 CHECK_GE(7, length);
136 TrimRepresentation(buffer); 136 TrimRepresentation(buffer);
137 CHECK_EQ("1797693", buffer.start()); 137 CHECK_EQ(0, strcmp("1797693", buffer.start()));
138 CHECK_EQ(309, point); 138 CHECK_EQ(309, point);
139 139
140 DoubleToAscii(4294967272.0, DTOA_SHORTEST, 0, buffer, &sign, &length, &point); 140 DoubleToAscii(4294967272.0, DTOA_SHORTEST, 0, buffer, &sign, &length, &point);
141 CHECK_EQ("4294967272", buffer.start()); 141 CHECK_EQ(0, strcmp("4294967272", buffer.start()));
142 CHECK_EQ(10, point); 142 CHECK_EQ(10, point);
143 143
144 DoubleToAscii(4294967272.0, DTOA_FIXED, 5, buffer, &sign, &length, &point); 144 DoubleToAscii(4294967272.0, DTOA_FIXED, 5, buffer, &sign, &length, &point);
145 CHECK_GE(5, length - point); 145 CHECK_GE(5, length - point);
146 TrimRepresentation(buffer); 146 TrimRepresentation(buffer);
147 CHECK_EQ("4294967272", buffer.start()); 147 CHECK_EQ(0, strcmp("4294967272", buffer.start()));
148 CHECK_EQ(10, point); 148 CHECK_EQ(10, point);
149 149
150 150
151 DoubleToAscii(4294967272.0, DTOA_PRECISION, 14, 151 DoubleToAscii(4294967272.0, DTOA_PRECISION, 14,
152 buffer, &sign, &length, &point); 152 buffer, &sign, &length, &point);
153 CHECK_GE(14, length); 153 CHECK_GE(14, length);
154 TrimRepresentation(buffer); 154 TrimRepresentation(buffer);
155 CHECK_EQ("4294967272", buffer.start()); 155 CHECK_EQ(0, strcmp("4294967272", buffer.start()));
156 CHECK_EQ(10, point); 156 CHECK_EQ(10, point);
157 157
158 DoubleToAscii(4.1855804968213567e298, DTOA_SHORTEST, 0, 158 DoubleToAscii(4.1855804968213567e298, DTOA_SHORTEST, 0,
159 buffer, &sign, &length, &point); 159 buffer, &sign, &length, &point);
160 CHECK_EQ("4185580496821357", buffer.start()); 160 CHECK_EQ(0, strcmp("4185580496821357", buffer.start()));
161 CHECK_EQ(299, point); 161 CHECK_EQ(299, point);
162 162
163 DoubleToAscii(4.1855804968213567e298, DTOA_PRECISION, 20, 163 DoubleToAscii(4.1855804968213567e298, DTOA_PRECISION, 20,
164 buffer, &sign, &length, &point); 164 buffer, &sign, &length, &point);
165 CHECK_GE(20, length); 165 CHECK_GE(20, length);
166 TrimRepresentation(buffer); 166 TrimRepresentation(buffer);
167 CHECK_EQ("41855804968213567225", buffer.start()); 167 CHECK_EQ(0, strcmp("41855804968213567225", buffer.start()));
168 CHECK_EQ(299, point); 168 CHECK_EQ(299, point);
169 169
170 DoubleToAscii(5.5626846462680035e-309, DTOA_SHORTEST, 0, 170 DoubleToAscii(5.5626846462680035e-309, DTOA_SHORTEST, 0,
171 buffer, &sign, &length, &point); 171 buffer, &sign, &length, &point);
172 CHECK_EQ("5562684646268003", buffer.start()); 172 CHECK_EQ(0, strcmp("5562684646268003", buffer.start()));
173 CHECK_EQ(-308, point); 173 CHECK_EQ(-308, point);
174 174
175 DoubleToAscii(5.5626846462680035e-309, DTOA_PRECISION, 1, 175 DoubleToAscii(5.5626846462680035e-309, DTOA_PRECISION, 1,
176 buffer, &sign, &length, &point); 176 buffer, &sign, &length, &point);
177 CHECK_GE(1, length); 177 CHECK_GE(1, length);
178 TrimRepresentation(buffer); 178 TrimRepresentation(buffer);
179 CHECK_EQ("6", buffer.start()); 179 CHECK_EQ(0, strcmp("6", buffer.start()));
180 CHECK_EQ(-308, point); 180 CHECK_EQ(-308, point);
181 181
182 DoubleToAscii(-2147483648.0, DTOA_SHORTEST, 0, 182 DoubleToAscii(-2147483648.0, DTOA_SHORTEST, 0,
183 buffer, &sign, &length, &point); 183 buffer, &sign, &length, &point);
184 CHECK_EQ(1, sign); 184 CHECK_EQ(1, sign);
185 CHECK_EQ("2147483648", buffer.start()); 185 CHECK_EQ(0, strcmp("2147483648", buffer.start()));
186 CHECK_EQ(10, point); 186 CHECK_EQ(10, point);
187 187
188 188
189 DoubleToAscii(-2147483648.0, DTOA_FIXED, 2, buffer, &sign, &length, &point); 189 DoubleToAscii(-2147483648.0, DTOA_FIXED, 2, buffer, &sign, &length, &point);
190 CHECK_GE(2, length - point); 190 CHECK_GE(2, length - point);
191 TrimRepresentation(buffer); 191 TrimRepresentation(buffer);
192 CHECK_EQ(1, sign); 192 CHECK_EQ(1, sign);
193 CHECK_EQ("2147483648", buffer.start()); 193 CHECK_EQ(0, strcmp("2147483648", buffer.start()));
194 CHECK_EQ(10, point); 194 CHECK_EQ(10, point);
195 195
196 DoubleToAscii(-2147483648.0, DTOA_PRECISION, 5, 196 DoubleToAscii(-2147483648.0, DTOA_PRECISION, 5,
197 buffer, &sign, &length, &point); 197 buffer, &sign, &length, &point);
198 CHECK_GE(5, length); 198 CHECK_GE(5, length);
199 TrimRepresentation(buffer); 199 TrimRepresentation(buffer);
200 CHECK_EQ(1, sign); 200 CHECK_EQ(1, sign);
201 CHECK_EQ("21475", buffer.start()); 201 CHECK_EQ(0, strcmp("21475", buffer.start()));
202 CHECK_EQ(10, point); 202 CHECK_EQ(10, point);
203 203
204 DoubleToAscii(-3.5844466002796428e+298, DTOA_SHORTEST, 0, 204 DoubleToAscii(-3.5844466002796428e+298, DTOA_SHORTEST, 0,
205 buffer, &sign, &length, &point); 205 buffer, &sign, &length, &point);
206 CHECK_EQ(1, sign); 206 CHECK_EQ(1, sign);
207 CHECK_EQ("35844466002796428", buffer.start()); 207 CHECK_EQ(0, strcmp("35844466002796428", buffer.start()));
208 CHECK_EQ(299, point); 208 CHECK_EQ(299, point);
209 209
210 DoubleToAscii(-3.5844466002796428e+298, DTOA_PRECISION, 10, 210 DoubleToAscii(-3.5844466002796428e+298, DTOA_PRECISION, 10,
211 buffer, &sign, &length, &point); 211 buffer, &sign, &length, &point);
212 CHECK_EQ(1, sign); 212 CHECK_EQ(1, sign);
213 CHECK_GE(10, length); 213 CHECK_GE(10, length);
214 TrimRepresentation(buffer); 214 TrimRepresentation(buffer);
215 CHECK_EQ("35844466", buffer.start()); 215 CHECK_EQ(0, strcmp("35844466", buffer.start()));
216 CHECK_EQ(299, point); 216 CHECK_EQ(299, point);
217 217
218 uint64_t smallest_normal64 = V8_2PART_UINT64_C(0x00100000, 00000000); 218 uint64_t smallest_normal64 = V8_2PART_UINT64_C(0x00100000, 00000000);
219 double v = Double(smallest_normal64).value(); 219 double v = Double(smallest_normal64).value();
220 DoubleToAscii(v, DTOA_SHORTEST, 0, buffer, &sign, &length, &point); 220 DoubleToAscii(v, DTOA_SHORTEST, 0, buffer, &sign, &length, &point);
221 CHECK_EQ("22250738585072014", buffer.start()); 221 CHECK_EQ(0, strcmp("22250738585072014", buffer.start()));
222 CHECK_EQ(-307, point); 222 CHECK_EQ(-307, point);
223 223
224 DoubleToAscii(v, DTOA_PRECISION, 20, buffer, &sign, &length, &point); 224 DoubleToAscii(v, DTOA_PRECISION, 20, buffer, &sign, &length, &point);
225 CHECK_GE(20, length); 225 CHECK_GE(20, length);
226 TrimRepresentation(buffer); 226 TrimRepresentation(buffer);
227 CHECK_EQ("22250738585072013831", buffer.start()); 227 CHECK_EQ(0, strcmp("22250738585072013831", buffer.start()));
228 CHECK_EQ(-307, point); 228 CHECK_EQ(-307, point);
229 229
230 uint64_t largest_denormal64 = V8_2PART_UINT64_C(0x000FFFFF, FFFFFFFF); 230 uint64_t largest_denormal64 = V8_2PART_UINT64_C(0x000FFFFF, FFFFFFFF);
231 v = Double(largest_denormal64).value(); 231 v = Double(largest_denormal64).value();
232 DoubleToAscii(v, DTOA_SHORTEST, 0, buffer, &sign, &length, &point); 232 DoubleToAscii(v, DTOA_SHORTEST, 0, buffer, &sign, &length, &point);
233 CHECK_EQ("2225073858507201", buffer.start()); 233 CHECK_EQ(0, strcmp("2225073858507201", buffer.start()));
234 CHECK_EQ(-307, point); 234 CHECK_EQ(-307, point);
235 235
236 DoubleToAscii(v, DTOA_PRECISION, 20, buffer, &sign, &length, &point); 236 DoubleToAscii(v, DTOA_PRECISION, 20, buffer, &sign, &length, &point);
237 CHECK_GE(20, length); 237 CHECK_GE(20, length);
238 TrimRepresentation(buffer); 238 TrimRepresentation(buffer);
239 CHECK_EQ("2225073858507200889", buffer.start()); 239 CHECK_EQ(0, strcmp("2225073858507200889", buffer.start()));
240 CHECK_EQ(-307, point); 240 CHECK_EQ(-307, point);
241 241
242 DoubleToAscii(4128420500802942e-24, DTOA_SHORTEST, 0, 242 DoubleToAscii(4128420500802942e-24, DTOA_SHORTEST, 0,
243 buffer, &sign, &length, &point); 243 buffer, &sign, &length, &point);
244 CHECK_EQ(0, sign); 244 CHECK_EQ(0, sign);
245 CHECK_EQ("4128420500802942", buffer.start()); 245 CHECK_EQ(0, strcmp("4128420500802942", buffer.start()));
246 CHECK_EQ(-8, point); 246 CHECK_EQ(-8, point);
247 247
248 v = -3.9292015898194142585311918e-10; 248 v = -3.9292015898194142585311918e-10;
249 DoubleToAscii(v, DTOA_SHORTEST, 0, buffer, &sign, &length, &point); 249 DoubleToAscii(v, DTOA_SHORTEST, 0, buffer, &sign, &length, &point);
250 CHECK_EQ("39292015898194143", buffer.start()); 250 CHECK_EQ(0, strcmp("39292015898194143", buffer.start()));
251 251
252 v = 4194304.0; 252 v = 4194304.0;
253 DoubleToAscii(v, DTOA_FIXED, 5, buffer, &sign, &length, &point); 253 DoubleToAscii(v, DTOA_FIXED, 5, buffer, &sign, &length, &point);
254 CHECK_GE(5, length - point); 254 CHECK_GE(5, length - point);
255 TrimRepresentation(buffer); 255 TrimRepresentation(buffer);
256 CHECK_EQ("4194304", buffer.start()); 256 CHECK_EQ(0, strcmp("4194304", buffer.start()));
257 257
258 v = 3.3161339052167390562200598e-237; 258 v = 3.3161339052167390562200598e-237;
259 DoubleToAscii(v, DTOA_PRECISION, 19, buffer, &sign, &length, &point); 259 DoubleToAscii(v, DTOA_PRECISION, 19, buffer, &sign, &length, &point);
260 CHECK_GE(19, length); 260 CHECK_GE(19, length);
261 TrimRepresentation(buffer); 261 TrimRepresentation(buffer);
262 CHECK_EQ("3316133905216739056", buffer.start()); 262 CHECK_EQ(0, strcmp("3316133905216739056", buffer.start()));
263 CHECK_EQ(-236, point); 263 CHECK_EQ(-236, point);
264 } 264 }
265 265
266 266
267 TEST(DtoaGayShortest) { 267 TEST(DtoaGayShortest) {
268 char buffer_container[kBufferSize]; 268 char buffer_container[kBufferSize];
269 Vector<char> buffer(buffer_container, kBufferSize); 269 Vector<char> buffer(buffer_container, kBufferSize);
270 int sign; 270 int sign;
271 int length; 271 int length;
272 int point; 272 int point;
273 273
274 Vector<const PrecomputedShortest> precomputed = 274 Vector<const PrecomputedShortest> precomputed =
275 PrecomputedShortestRepresentations(); 275 PrecomputedShortestRepresentations();
276 for (int i = 0; i < precomputed.length(); ++i) { 276 for (int i = 0; i < precomputed.length(); ++i) {
277 const PrecomputedShortest current_test = precomputed[i]; 277 const PrecomputedShortest current_test = precomputed[i];
278 double v = current_test.v; 278 double v = current_test.v;
279 DoubleToAscii(v, DTOA_SHORTEST, 0, buffer, &sign, &length, &point); 279 DoubleToAscii(v, DTOA_SHORTEST, 0, buffer, &sign, &length, &point);
280 CHECK_EQ(0, sign); // All precomputed numbers are positive. 280 CHECK_EQ(0, sign); // All precomputed numbers are positive.
281 CHECK_EQ(current_test.decimal_point, point); 281 CHECK_EQ(current_test.decimal_point, point);
282 CHECK_EQ(current_test.representation, buffer.start()); 282 CHECK_EQ(0, strcmp(current_test.representation, buffer.start()));
283 } 283 }
284 } 284 }
285 285
286 286
287 TEST(DtoaGayFixed) { 287 TEST(DtoaGayFixed) {
288 char buffer_container[kBufferSize]; 288 char buffer_container[kBufferSize];
289 Vector<char> buffer(buffer_container, kBufferSize); 289 Vector<char> buffer(buffer_container, kBufferSize);
290 int sign; 290 int sign;
291 int length; 291 int length;
292 int point; 292 int point;
293 293
294 Vector<const PrecomputedFixed> precomputed = 294 Vector<const PrecomputedFixed> precomputed =
295 PrecomputedFixedRepresentations(); 295 PrecomputedFixedRepresentations();
296 for (int i = 0; i < precomputed.length(); ++i) { 296 for (int i = 0; i < precomputed.length(); ++i) {
297 const PrecomputedFixed current_test = precomputed[i]; 297 const PrecomputedFixed current_test = precomputed[i];
298 double v = current_test.v; 298 double v = current_test.v;
299 int number_digits = current_test.number_digits; 299 int number_digits = current_test.number_digits;
300 DoubleToAscii(v, DTOA_FIXED, number_digits, buffer, &sign, &length, &point); 300 DoubleToAscii(v, DTOA_FIXED, number_digits, buffer, &sign, &length, &point);
301 CHECK_EQ(0, sign); // All precomputed numbers are positive. 301 CHECK_EQ(0, sign); // All precomputed numbers are positive.
302 CHECK_EQ(current_test.decimal_point, point); 302 CHECK_EQ(current_test.decimal_point, point);
303 CHECK_GE(number_digits, length - point); 303 CHECK_GE(number_digits, length - point);
304 TrimRepresentation(buffer); 304 TrimRepresentation(buffer);
305 CHECK_EQ(current_test.representation, buffer.start()); 305 CHECK_EQ(0, strcmp(current_test.representation, buffer.start()));
306 } 306 }
307 } 307 }
308 308
309 309
310 TEST(DtoaGayPrecision) { 310 TEST(DtoaGayPrecision) {
311 char buffer_container[kBufferSize]; 311 char buffer_container[kBufferSize];
312 Vector<char> buffer(buffer_container, kBufferSize); 312 Vector<char> buffer(buffer_container, kBufferSize);
313 int sign; 313 int sign;
314 int length; 314 int length;
315 int point; 315 int point;
316 316
317 Vector<const PrecomputedPrecision> precomputed = 317 Vector<const PrecomputedPrecision> precomputed =
318 PrecomputedPrecisionRepresentations(); 318 PrecomputedPrecisionRepresentations();
319 for (int i = 0; i < precomputed.length(); ++i) { 319 for (int i = 0; i < precomputed.length(); ++i) {
320 const PrecomputedPrecision current_test = precomputed[i]; 320 const PrecomputedPrecision current_test = precomputed[i];
321 double v = current_test.v; 321 double v = current_test.v;
322 int number_digits = current_test.number_digits; 322 int number_digits = current_test.number_digits;
323 DoubleToAscii(v, DTOA_PRECISION, number_digits, 323 DoubleToAscii(v, DTOA_PRECISION, number_digits,
324 buffer, &sign, &length, &point); 324 buffer, &sign, &length, &point);
325 CHECK_EQ(0, sign); // All precomputed numbers are positive. 325 CHECK_EQ(0, sign); // All precomputed numbers are positive.
326 CHECK_EQ(current_test.decimal_point, point); 326 CHECK_EQ(current_test.decimal_point, point);
327 CHECK_GE(number_digits, length); 327 CHECK_GE(number_digits, length);
328 TrimRepresentation(buffer); 328 TrimRepresentation(buffer);
329 CHECK_EQ(current_test.representation, buffer.start()); 329 CHECK_EQ(0, strcmp(current_test.representation, buffer.start()));
330 } 330 }
331 } 331 }
OLDNEW
« no previous file with comments | « test/cctest/test-deoptimization.cc ('k') | test/cctest/test-fast-dtoa.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698