| OLD | NEW | 
|---|
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 430 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 441   lo = 18273 * (lo & 0xFFFF) + (lo >> 16); | 441   lo = 18273 * (lo & 0xFFFF) + (lo >> 16); | 
| 442   return (hi << 16) + (lo & 0xFFFF); | 442   return (hi << 16) + (lo & 0xFFFF); | 
| 443 } | 443 } | 
| 444 | 444 | 
| 445 | 445 | 
| 446 static const int kBufferSize = 1024; | 446 static const int kBufferSize = 1024; | 
| 447 static const int kShortStrtodRandomCount = 2; | 447 static const int kShortStrtodRandomCount = 2; | 
| 448 static const int kLargeStrtodRandomCount = 2; | 448 static const int kLargeStrtodRandomCount = 2; | 
| 449 | 449 | 
| 450 TEST(RandomStrtod) { | 450 TEST(RandomStrtod) { | 
| 451   srand(time(NULL)); | 451   srand(static_cast<unsigned int>(time(NULL))); | 
| 452   char buffer[kBufferSize]; | 452   char buffer[kBufferSize]; | 
| 453   for (int length = 1; length < 15; length++) { | 453   for (int length = 1; length < 15; length++) { | 
| 454     for (int i = 0; i < kShortStrtodRandomCount; ++i) { | 454     for (int i = 0; i < kShortStrtodRandomCount; ++i) { | 
| 455       int pos = 0; | 455       int pos = 0; | 
| 456       for (int j = 0; j < length; ++j) { | 456       for (int j = 0; j < length; ++j) { | 
| 457         buffer[pos++] = rand() % 10 + '0'; | 457         buffer[pos++] = rand() % 10 + '0'; | 
| 458       } | 458       } | 
| 459       int exponent = DeterministicRandom() % (25*2 + 1) - 25 - length; | 459       int exponent = DeterministicRandom() % (25*2 + 1) - 25 - length; | 
| 460       buffer[pos] = '\0'; | 460       buffer[pos] = '\0'; | 
| 461       Vector<const char> vector(buffer, pos); | 461       Vector<const char> vector(buffer, pos); | 
| 462       double strtod_result = Strtod(vector, exponent); | 462       double strtod_result = Strtod(vector, exponent); | 
| 463       CHECK(CheckDouble(vector, exponent, strtod_result)); | 463       CHECK(CheckDouble(vector, exponent, strtod_result)); | 
| 464     } | 464     } | 
| 465   } | 465   } | 
| 466   for (int length = 15; length < 800; length += 2) { | 466   for (int length = 15; length < 800; length += 2) { | 
| 467     for (int i = 0; i < kLargeStrtodRandomCount; ++i) { | 467     for (int i = 0; i < kLargeStrtodRandomCount; ++i) { | 
| 468       int pos = 0; | 468       int pos = 0; | 
| 469       for (int j = 0; j < length; ++j) { | 469       for (int j = 0; j < length; ++j) { | 
| 470         buffer[pos++] = rand() % 10 + '0'; | 470         buffer[pos++] = rand() % 10 + '0'; | 
| 471       } | 471       } | 
| 472       int exponent = DeterministicRandom() % (308*2 + 1) - 308 - length; | 472       int exponent = DeterministicRandom() % (308*2 + 1) - 308 - length; | 
| 473       buffer[pos] = '\0'; | 473       buffer[pos] = '\0'; | 
| 474       Vector<const char> vector(buffer, pos); | 474       Vector<const char> vector(buffer, pos); | 
| 475       double strtod_result = Strtod(vector, exponent); | 475       double strtod_result = Strtod(vector, exponent); | 
| 476       CHECK(CheckDouble(vector, exponent, strtod_result)); | 476       CHECK(CheckDouble(vector, exponent, strtod_result)); | 
| 477     } | 477     } | 
| 478   } | 478   } | 
| 479 } | 479 } | 
| OLD | NEW | 
|---|