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

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

Powered by Google App Engine
This is Rietveld 408576698