Commit e7409329 authored by jameslahm's avatar jameslahm Committed by V8 LUCI CQ

[test] Move cctest/{test-bignum-dtoa, test-dtoa

... ,test-fast-dtoa, test-fixed-dtoa} to unittests/base/
{bignum-dtoa-unittest, dtoa-unittest, fast-dtoa-unittest,
fixed-dtoa-unittest}.

This CL also moves cctest/{gay-fixed, gay-precision,
gay-shortest} to unittest/{gay-fixed, gay-precision,
gay-shortest}.

Bug: v8:12781
Change-Id: Id6072f92908ad3abfe683c69dac041227de2553f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3607114
Commit-Queue: 王澳 <wangao.james@bytedance.com>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80572}
parent 5c416ad2
......@@ -128,12 +128,6 @@ v8_source_set("cctest_sources") {
"compiler/value-helper.cc",
"compiler/value-helper.h",
"expression-type-collector-macros.h",
"gay-fixed.cc",
"gay-fixed.h",
"gay-precision.cc",
"gay-precision.h",
"gay-shortest.cc",
"gay-shortest.h",
"heap/heap-tester.h",
"heap/heap-utils.cc",
"heap/heap-utils.h",
......@@ -193,7 +187,6 @@ v8_source_set("cctest_sources") {
"test-api.cc",
"test-api.h",
"test-atomicops.cc",
"test-bignum-dtoa.cc",
"test-code-stub-assembler.cc",
"test-constantpool.cc",
"test-cpu-profiler.cc",
......@@ -206,13 +199,10 @@ v8_source_set("cctest_sources") {
"test-disasm-regex-helper.cc",
"test-disasm-regex-helper.h",
"test-diy-fp.cc",
"test-dtoa.cc",
"test-factory.cc",
"test-fast-dtoa.cc",
"test-feedback-vector.cc",
"test-feedback-vector.h",
"test-field-type-tracking.cc",
"test-fixed-dtoa.cc",
"test-flags.cc",
"test-func-name-inference.cc",
"test-global-handles.cc",
......
......@@ -221,11 +221,15 @@ v8_source_set("unittests_sources") {
"api/v8-script-unittest.cc",
"base/address-region-unittest.cc",
"base/atomic-utils-unittest.cc",
"base/bignum-dtoa-unittest.cc",
"base/bignum-unittest.cc",
"base/bits-unittest.cc",
"base/cpu-unittest.cc",
"base/division-by-constant-unittest.cc",
"base/double-unittest.cc",
"base/dtoa-unittest.cc",
"base/fast-dtoa-unittest.cc",
"base/fixed-dtoa-unittest.cc",
"base/flags-unittest.cc",
"base/functional-unittest.cc",
"base/ieee754-unittest.cc",
......@@ -325,6 +329,12 @@ v8_source_set("unittests_sources") {
"diagnostics/eh-frame-writer-unittest.cc",
"diagnostics/gdb-jit-unittest.cc",
"execution/microtask-queue-unittest.cc",
"gay-fixed.cc",
"gay-fixed.h",
"gay-precision.cc",
"gay-precision.h",
"gay-shortest.cc",
"gay-shortest.h",
"heap/allocation-observer-unittest.cc",
"heap/bitmap-test-utils.h",
"heap/bitmap-unittest.cc",
......
......@@ -25,18 +25,22 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "src/base/numbers/bignum-dtoa.h"
#include <stdlib.h>
#include "src/base/numbers/bignum-dtoa.h"
#include "src/base/numbers/double.h"
#include "src/base/platform/platform.h"
#include "src/init/v8.h"
#include "test/cctest/cctest.h"
#include "test/cctest/gay-fixed.h"
#include "test/cctest/gay-precision.h"
#include "test/cctest/gay-shortest.h"
#include "test/unittests/gay-fixed.h"
#include "test/unittests/gay-precision.h"
#include "test/unittests/gay-shortest.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace v8 {
using BignumDtoaTest = ::testing::Test;
namespace base {
namespace test_bignum_dtoa {
......@@ -50,8 +54,7 @@ static void TrimRepresentation(char* representation) {
static const int kBufferSize = 100;
TEST(BignumDtoaVariousDoubles) {
TEST_F(BignumDtoaTest, BignumDtoaVariousDoubles) {
char buffer_container[kBufferSize];
Vector<char> buffer(buffer_container, kBufferSize);
int length;
......@@ -124,64 +127,59 @@ TEST(BignumDtoaVariousDoubles) {
CHECK_EQ(0, strcmp("429496727200000", buffer.begin()));
CHECK_EQ(10, point);
BignumDtoa(4294967272.0, BIGNUM_DTOA_PRECISION, 14, buffer, &length, &point);
CHECK_GE(14, length);
TrimRepresentation(buffer.begin());
CHECK_EQ(0, strcmp("4294967272", buffer.begin()));
CHECK_EQ(10, point);
BignumDtoa(4.1855804968213567e298, BIGNUM_DTOA_SHORTEST, 0,
buffer, &length, &point);
BignumDtoa(4.1855804968213567e298, BIGNUM_DTOA_SHORTEST, 0, buffer, &length,
&point);
CHECK_EQ(0, strcmp("4185580496821357", buffer.begin()));
CHECK_EQ(299, point);
BignumDtoa(4.1855804968213567e298, BIGNUM_DTOA_PRECISION, 20,
buffer, &length, &point);
BignumDtoa(4.1855804968213567e298, BIGNUM_DTOA_PRECISION, 20, buffer, &length,
&point);
CHECK_GE(20, length);
TrimRepresentation(buffer.begin());
CHECK_EQ(0, strcmp("41855804968213567225", buffer.begin()));
CHECK_EQ(299, point);
BignumDtoa(5.5626846462680035e-309, BIGNUM_DTOA_SHORTEST, 0,
buffer, &length, &point);
BignumDtoa(5.5626846462680035e-309, BIGNUM_DTOA_SHORTEST, 0, buffer, &length,
&point);
CHECK_EQ(0, strcmp("5562684646268003", buffer.begin()));
CHECK_EQ(-308, point);
BignumDtoa(5.5626846462680035e-309, BIGNUM_DTOA_PRECISION, 1,
buffer, &length, &point);
BignumDtoa(5.5626846462680035e-309, BIGNUM_DTOA_PRECISION, 1, buffer, &length,
&point);
CHECK_GE(1, length);
TrimRepresentation(buffer.begin());
CHECK_EQ(0, strcmp("6", buffer.begin()));
CHECK_EQ(-308, point);
BignumDtoa(2147483648.0, BIGNUM_DTOA_SHORTEST, 0,
buffer, &length, &point);
BignumDtoa(2147483648.0, BIGNUM_DTOA_SHORTEST, 0, buffer, &length, &point);
CHECK_EQ(0, strcmp("2147483648", buffer.begin()));
CHECK_EQ(10, point);
BignumDtoa(2147483648.0, BIGNUM_DTOA_FIXED, 2,
buffer, &length, &point);
BignumDtoa(2147483648.0, BIGNUM_DTOA_FIXED, 2, buffer, &length, &point);
CHECK_GE(2, length - point);
TrimRepresentation(buffer.begin());
CHECK_EQ(0, strcmp("2147483648", buffer.begin()));
CHECK_EQ(10, point);
BignumDtoa(2147483648.0, BIGNUM_DTOA_PRECISION, 5,
buffer, &length, &point);
BignumDtoa(2147483648.0, BIGNUM_DTOA_PRECISION, 5, buffer, &length, &point);
CHECK_GE(5, length);
TrimRepresentation(buffer.begin());
CHECK_EQ(0, strcmp("21475", buffer.begin()));
CHECK_EQ(10, point);
BignumDtoa(3.5844466002796428e+298, BIGNUM_DTOA_SHORTEST, 0,
buffer, &length, &point);
BignumDtoa(3.5844466002796428e+298, BIGNUM_DTOA_SHORTEST, 0, buffer, &length,
&point);
CHECK_EQ(0, strcmp("35844466002796428", buffer.begin()));
CHECK_EQ(299, point);
BignumDtoa(3.5844466002796428e+298, BIGNUM_DTOA_PRECISION, 10,
buffer, &length, &point);
BignumDtoa(3.5844466002796428e+298, BIGNUM_DTOA_PRECISION, 10, buffer,
&length, &point);
CHECK_GE(10, length);
TrimRepresentation(buffer.begin());
CHECK_EQ(0, strcmp("35844466", buffer.begin()));
......@@ -211,8 +209,8 @@ TEST(BignumDtoaVariousDoubles) {
CHECK_EQ(0, strcmp("2225073858507200889", buffer.begin()));
CHECK_EQ(-307, point);
BignumDtoa(4128420500802942e-24, BIGNUM_DTOA_SHORTEST, 0,
buffer, &length, &point);
BignumDtoa(4128420500802942e-24, BIGNUM_DTOA_SHORTEST, 0, buffer, &length,
&point);
CHECK_EQ(0, strcmp("4128420500802942", buffer.begin()));
CHECK_EQ(-8, point);
......@@ -248,8 +246,7 @@ TEST(BignumDtoaVariousDoubles) {
CHECK_EQ(18, point);
}
TEST(BignumDtoaGayShortest) {
TEST_F(BignumDtoaTest, BignumDtoaGayShortest) {
char buffer_container[kBufferSize];
Vector<char> buffer(buffer_container, kBufferSize);
int length;
......@@ -266,8 +263,7 @@ TEST(BignumDtoaGayShortest) {
}
}
TEST(BignumDtoaGayFixed) {
TEST_F(BignumDtoaTest, BignumDtoaGayFixed) {
char buffer_container[kBufferSize];
Vector<char> buffer(buffer_container, kBufferSize);
int length;
......@@ -287,8 +283,7 @@ TEST(BignumDtoaGayFixed) {
}
}
TEST(BignumDtoaGayPrecision) {
TEST_F(BignumDtoaTest, BignumDtoaGayPrecision) {
char buffer_container[kBufferSize];
Vector<char> buffer(buffer_container, kBufferSize);
int length;
......@@ -300,8 +295,8 @@ TEST(BignumDtoaGayPrecision) {
const PrecomputedPrecision current_test = precomputed[i];
double v = current_test.v;
int number_digits = current_test.number_digits;
BignumDtoa(v, BIGNUM_DTOA_PRECISION, number_digits,
buffer, &length, &point);
BignumDtoa(v, BIGNUM_DTOA_PRECISION, number_digits, buffer, &length,
&point);
CHECK_EQ(current_test.decimal_point, point);
CHECK_GE(number_digits, length);
TrimRepresentation(buffer.begin());
......
......@@ -25,18 +25,22 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "src/base/numbers/dtoa.h"
#include <stdlib.h>
#include "src/base/numbers/double.h"
#include "src/base/numbers/dtoa.h"
#include "src/base/platform/platform.h"
#include "src/init/v8.h"
#include "test/cctest/cctest.h"
#include "test/cctest/gay-fixed.h"
#include "test/cctest/gay-precision.h"
#include "test/cctest/gay-shortest.h"
#include "test/unittests/gay-fixed.h"
#include "test/unittests/gay-precision.h"
#include "test/unittests/gay-shortest.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace v8 {
using DtoaTest = ::testing::Test;
namespace base {
namespace test_dtoa {
......@@ -50,8 +54,7 @@ static void TrimRepresentation(char* representation) {
static const int kBufferSize = 100;
TEST(DtoaVariousDoubles) {
TEST_F(DtoaTest, DtoaVariousDoubles) {
char buffer_container[kBufferSize];
base::Vector<char> buffer(buffer_container, kBufferSize);
int length;
......@@ -142,45 +145,43 @@ TEST(DtoaVariousDoubles) {
CHECK_EQ(0, strcmp("4294967272", buffer.begin()));
CHECK_EQ(10, point);
DoubleToAscii(4294967272.0, DTOA_PRECISION, 14,
buffer, &sign, &length, &point);
DoubleToAscii(4294967272.0, DTOA_PRECISION, 14, buffer, &sign, &length,
&point);
CHECK_GE(14, length);
TrimRepresentation(buffer.begin());
CHECK_EQ(0, strcmp("4294967272", buffer.begin()));
CHECK_EQ(10, point);
DoubleToAscii(4.1855804968213567e298, DTOA_SHORTEST, 0,
buffer, &sign, &length, &point);
DoubleToAscii(4.1855804968213567e298, DTOA_SHORTEST, 0, buffer, &sign,
&length, &point);
CHECK_EQ(0, strcmp("4185580496821357", buffer.begin()));
CHECK_EQ(299, point);
DoubleToAscii(4.1855804968213567e298, DTOA_PRECISION, 20,
buffer, &sign, &length, &point);
DoubleToAscii(4.1855804968213567e298, DTOA_PRECISION, 20, buffer, &sign,
&length, &point);
CHECK_GE(20, length);
TrimRepresentation(buffer.begin());
CHECK_EQ(0, strcmp("41855804968213567225", buffer.begin()));
CHECK_EQ(299, point);
DoubleToAscii(5.5626846462680035e-309, DTOA_SHORTEST, 0,
buffer, &sign, &length, &point);
DoubleToAscii(5.5626846462680035e-309, DTOA_SHORTEST, 0, buffer, &sign,
&length, &point);
CHECK_EQ(0, strcmp("5562684646268003", buffer.begin()));
CHECK_EQ(-308, point);
DoubleToAscii(5.5626846462680035e-309, DTOA_PRECISION, 1,
buffer, &sign, &length, &point);
DoubleToAscii(5.5626846462680035e-309, DTOA_PRECISION, 1, buffer, &sign,
&length, &point);
CHECK_GE(1, length);
TrimRepresentation(buffer.begin());
CHECK_EQ(0, strcmp("6", buffer.begin()));
CHECK_EQ(-308, point);
DoubleToAscii(-2147483648.0, DTOA_SHORTEST, 0,
buffer, &sign, &length, &point);
DoubleToAscii(-2147483648.0, DTOA_SHORTEST, 0, buffer, &sign, &length,
&point);
CHECK_EQ(1, sign);
CHECK_EQ(0, strcmp("2147483648", buffer.begin()));
CHECK_EQ(10, point);
DoubleToAscii(-2147483648.0, DTOA_FIXED, 2, buffer, &sign, &length, &point);
CHECK_GE(2, length - point);
TrimRepresentation(buffer.begin());
......@@ -188,22 +189,22 @@ TEST(DtoaVariousDoubles) {
CHECK_EQ(0, strcmp("2147483648", buffer.begin()));
CHECK_EQ(10, point);
DoubleToAscii(-2147483648.0, DTOA_PRECISION, 5,
buffer, &sign, &length, &point);
DoubleToAscii(-2147483648.0, DTOA_PRECISION, 5, buffer, &sign, &length,
&point);
CHECK_GE(5, length);
TrimRepresentation(buffer.begin());
CHECK_EQ(1, sign);
CHECK_EQ(0, strcmp("21475", buffer.begin()));
CHECK_EQ(10, point);
DoubleToAscii(-3.5844466002796428e+298, DTOA_SHORTEST, 0,
buffer, &sign, &length, &point);
DoubleToAscii(-3.5844466002796428e+298, DTOA_SHORTEST, 0, buffer, &sign,
&length, &point);
CHECK_EQ(1, sign);
CHECK_EQ(0, strcmp("35844466002796428", buffer.begin()));
CHECK_EQ(299, point);
DoubleToAscii(-3.5844466002796428e+298, DTOA_PRECISION, 10,
buffer, &sign, &length, &point);
DoubleToAscii(-3.5844466002796428e+298, DTOA_PRECISION, 10, buffer, &sign,
&length, &point);
CHECK_EQ(1, sign);
CHECK_GE(10, length);
TrimRepresentation(buffer.begin());
......@@ -234,8 +235,8 @@ TEST(DtoaVariousDoubles) {
CHECK_EQ(0, strcmp("2225073858507200889", buffer.begin()));
CHECK_EQ(-307, point);
DoubleToAscii(4128420500802942e-24, DTOA_SHORTEST, 0,
buffer, &sign, &length, &point);
DoubleToAscii(4128420500802942e-24, DTOA_SHORTEST, 0, buffer, &sign, &length,
&point);
CHECK_EQ(0, sign);
CHECK_EQ(0, strcmp("4128420500802942", buffer.begin()));
CHECK_EQ(-8, point);
......@@ -258,8 +259,7 @@ TEST(DtoaVariousDoubles) {
CHECK_EQ(-236, point);
}
TEST(DtoaGayShortest) {
TEST_F(DtoaTest, DtoaGayShortest) {
char buffer_container[kBufferSize];
base::Vector<char> buffer(buffer_container, kBufferSize);
int sign;
......@@ -278,8 +278,7 @@ TEST(DtoaGayShortest) {
}
}
TEST(DtoaGayFixed) {
TEST_F(DtoaTest, DtoaGayFixed) {
char buffer_container[kBufferSize];
base::Vector<char> buffer(buffer_container, kBufferSize);
int sign;
......@@ -301,8 +300,7 @@ TEST(DtoaGayFixed) {
}
}
TEST(DtoaGayPrecision) {
TEST_F(DtoaTest, DtoaGayPrecision) {
char buffer_container[kBufferSize];
base::Vector<char> buffer(buffer_container, kBufferSize);
int sign;
......@@ -315,8 +313,8 @@ TEST(DtoaGayPrecision) {
const PrecomputedPrecision current_test = precomputed[i];
double v = current_test.v;
int number_digits = current_test.number_digits;
DoubleToAscii(v, DTOA_PRECISION, number_digits,
buffer, &sign, &length, &point);
DoubleToAscii(v, DTOA_PRECISION, number_digits, buffer, &sign, &length,
&point);
CHECK_EQ(0, sign); // All precomputed numbers are positive.
CHECK_EQ(current_test.decimal_point, point);
CHECK_GE(number_digits, length);
......
......@@ -25,18 +25,22 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "src/base/numbers/fast-dtoa.h"
#include <stdlib.h>
#include "src/base/numbers/diy-fp.h"
#include "src/base/numbers/double.h"
#include "src/base/numbers/fast-dtoa.h"
#include "src/base/platform/platform.h"
#include "src/init/v8.h"
#include "test/cctest/cctest.h"
#include "test/cctest/gay-precision.h"
#include "test/cctest/gay-shortest.h"
#include "test/unittests/gay-precision.h"
#include "test/unittests/gay-shortest.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace v8 {
using FastDtoaTest = ::testing::Test;
namespace base {
namespace test_fast_dtoa {
......@@ -50,7 +54,7 @@ static void TrimRepresentation(char* representation) {
representation[len] = '\0';
}
TEST(FastDtoaShortestVariousDoubles) {
TEST_F(FastDtoaTest, FastDtoaShortestVariousDoubles) {
char buffer_container[kBufferSize];
Vector<char> buffer(buffer_container, kBufferSize);
int length;
......@@ -58,45 +62,43 @@ TEST(FastDtoaShortestVariousDoubles) {
int status;
double min_double = 5e-324;
status = FastDtoa(min_double, FAST_DTOA_SHORTEST, 0,
buffer, &length, &point);
status = FastDtoa(min_double, FAST_DTOA_SHORTEST, 0, buffer, &length, &point);
CHECK(status);
CHECK_EQ(0, strcmp("5", buffer.begin()));
CHECK_EQ(-323, point);
double max_double = 1.7976931348623157e308;
status = FastDtoa(max_double, FAST_DTOA_SHORTEST, 0,
buffer, &length, &point);
status = FastDtoa(max_double, FAST_DTOA_SHORTEST, 0, buffer, &length, &point);
CHECK(status);
CHECK_EQ(0, strcmp("17976931348623157", buffer.begin()));
CHECK_EQ(309, point);
status = FastDtoa(4294967272.0, FAST_DTOA_SHORTEST, 0,
buffer, &length, &point);
status =
FastDtoa(4294967272.0, FAST_DTOA_SHORTEST, 0, buffer, &length, &point);
CHECK(status);
CHECK_EQ(0, strcmp("4294967272", buffer.begin()));
CHECK_EQ(10, point);
status = FastDtoa(4.1855804968213567e298, FAST_DTOA_SHORTEST, 0,
buffer, &length, &point);
status = FastDtoa(4.1855804968213567e298, FAST_DTOA_SHORTEST, 0, buffer,
&length, &point);
CHECK(status);
CHECK_EQ(0, strcmp("4185580496821357", buffer.begin()));
CHECK_EQ(299, point);
status = FastDtoa(5.5626846462680035e-309, FAST_DTOA_SHORTEST, 0,
buffer, &length, &point);
status = FastDtoa(5.5626846462680035e-309, FAST_DTOA_SHORTEST, 0, buffer,
&length, &point);
CHECK(status);
CHECK_EQ(0, strcmp("5562684646268003", buffer.begin()));
CHECK_EQ(-308, point);
status = FastDtoa(2147483648.0, FAST_DTOA_SHORTEST, 0,
buffer, &length, &point);
status =
FastDtoa(2147483648.0, FAST_DTOA_SHORTEST, 0, buffer, &length, &point);
CHECK(status);
CHECK_EQ(0, strcmp("2147483648", buffer.begin()));
CHECK_EQ(10, point);
status = FastDtoa(3.5844466002796428e+298, FAST_DTOA_SHORTEST, 0,
buffer, &length, &point);
status = FastDtoa(3.5844466002796428e+298, FAST_DTOA_SHORTEST, 0, buffer,
&length, &point);
if (status) { // Not all FastDtoa variants manage to compute this number.
CHECK_EQ(0, strcmp("35844466002796428", buffer.begin()));
CHECK_EQ(299, point);
......@@ -119,8 +121,7 @@ TEST(FastDtoaShortestVariousDoubles) {
}
}
TEST(FastDtoaPrecisionVariousDoubles) {
TEST_F(FastDtoaTest, FastDtoaPrecisionVariousDoubles) {
char buffer_container[kBufferSize];
Vector<char> buffer(buffer_container, kBufferSize);
int length;
......@@ -143,21 +144,21 @@ TEST(FastDtoaPrecisionVariousDoubles) {
}
double min_double = 5e-324;
status = FastDtoa(min_double, FAST_DTOA_PRECISION, 5,
buffer, &length, &point);
status =
FastDtoa(min_double, FAST_DTOA_PRECISION, 5, buffer, &length, &point);
CHECK(status);
CHECK_EQ(0, strcmp("49407", buffer.begin()));
CHECK_EQ(-323, point);
double max_double = 1.7976931348623157e308;
status = FastDtoa(max_double, FAST_DTOA_PRECISION, 7,
buffer, &length, &point);
status =
FastDtoa(max_double, FAST_DTOA_PRECISION, 7, buffer, &length, &point);
CHECK(status);
CHECK_EQ(0, strcmp("1797693", buffer.begin()));
CHECK_EQ(309, point);
status = FastDtoa(4294967272.0, FAST_DTOA_PRECISION, 14,
buffer, &length, &point);
status =
FastDtoa(4294967272.0, FAST_DTOA_PRECISION, 14, buffer, &length, &point);
if (status) {
CHECK_GE(14, length);
TrimRepresentation(buffer.begin());
......@@ -165,26 +166,26 @@ TEST(FastDtoaPrecisionVariousDoubles) {
CHECK_EQ(10, point);
}
status = FastDtoa(4.1855804968213567e298, FAST_DTOA_PRECISION, 17,
buffer, &length, &point);
status = FastDtoa(4.1855804968213567e298, FAST_DTOA_PRECISION, 17, buffer,
&length, &point);
CHECK(status);
CHECK_EQ(0, strcmp("41855804968213567", buffer.begin()));
CHECK_EQ(299, point);
status = FastDtoa(5.5626846462680035e-309, FAST_DTOA_PRECISION, 1,
buffer, &length, &point);
status = FastDtoa(5.5626846462680035e-309, FAST_DTOA_PRECISION, 1, buffer,
&length, &point);
CHECK(status);
CHECK_EQ(0, strcmp("6", buffer.begin()));
CHECK_EQ(-308, point);
status = FastDtoa(2147483648.0, FAST_DTOA_PRECISION, 5,
buffer, &length, &point);
status =
FastDtoa(2147483648.0, FAST_DTOA_PRECISION, 5, buffer, &length, &point);
CHECK(status);
CHECK_EQ(0, strcmp("21475", buffer.begin()));
CHECK_EQ(10, point);
status = FastDtoa(3.5844466002796428e+298, FAST_DTOA_PRECISION, 10,
buffer, &length, &point);
status = FastDtoa(3.5844466002796428e+298, FAST_DTOA_PRECISION, 10, buffer,
&length, &point);
CHECK(status);
CHECK_GE(10, length);
TrimRepresentation(buffer.begin());
......@@ -220,8 +221,7 @@ TEST(FastDtoaPrecisionVariousDoubles) {
CHECK_EQ(192, point);
}
TEST(FastDtoaGayShortest) {
TEST_F(FastDtoaTest, FastDtoaGayShortest) {
char buffer_container[kBufferSize];
Vector<char> buffer(buffer_container, kBufferSize);
bool status;
......@@ -245,12 +245,11 @@ TEST(FastDtoaGayShortest) {
CHECK_EQ(current_test.decimal_point, point);
CHECK_EQ(0, strcmp(current_test.representation, buffer.begin()));
}
CHECK_GT(succeeded*1.0/total, 0.99);
CHECK_GT(succeeded * 1.0 / total, 0.99);
CHECK(needed_max_length);
}
TEST(FastDtoaGayPrecision) {
TEST_F(FastDtoaTest, FastDtoaGayPrecision) {
char buffer_container[kBufferSize];
Vector<char> buffer(buffer_container, kBufferSize);
bool status;
......@@ -270,8 +269,8 @@ TEST(FastDtoaGayPrecision) {
int number_digits = current_test.number_digits;
total++;
if (number_digits <= 15) total_15++;
status = FastDtoa(v, FAST_DTOA_PRECISION, number_digits,
buffer, &length, &point);
status = FastDtoa(v, FAST_DTOA_PRECISION, number_digits, buffer, &length,
&point);
CHECK_GE(number_digits, length);
if (!status) continue;
succeeded++;
......@@ -283,10 +282,10 @@ TEST(FastDtoaGayPrecision) {
// The precomputed numbers contain many entries with many requested
// digits. These have a high failure rate and we therefore expect a lower
// success rate than for the shortest representation.
CHECK_GT(succeeded*1.0/total, 0.85);
CHECK_GT(succeeded * 1.0 / total, 0.85);
// However with less than 15 digits almost the algorithm should almost always
// succeed.
CHECK_GT(succeeded_15*1.0/total_15, 0.9999);
CHECK_GT(succeeded_15 * 1.0 / total_15, 0.9999);
}
} // namespace test_fast_dtoa
......
......@@ -25,21 +25,24 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "src/base/numbers/fixed-dtoa.h"
#include <stdlib.h>
#include "src/base/numbers/double.h"
#include "src/base/numbers/fixed-dtoa.h"
#include "src/base/platform/platform.h"
#include "src/init/v8.h"
#include "test/cctest/cctest.h"
#include "test/cctest/gay-fixed.h"
#include "test/unittests/gay-fixed.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace v8 {
using FixedDtoaTest = ::testing::Test;
namespace base {
static const int kBufferSize = 500;
TEST(FastFixedVariousDoubles) {
TEST_F(FixedDtoaTest, FastFixedVariousDoubles) {
char buffer_container[kBufferSize];
Vector<char> buffer(buffer_container, kBufferSize);
int length;
......@@ -74,8 +77,8 @@ TEST(FastFixedVariousDoubles) {
CHECK_EQ(0, strcmp("999999999999999868928", buffer.begin()));
CHECK_EQ(21, point);
CHECK(FastFixedDtoa(6.9999999999999989514240000e+21, 5, buffer,
&length, &point));
CHECK(FastFixedDtoa(6.9999999999999989514240000e+21, 5, buffer, &length,
&point));
CHECK_EQ(0, strcmp("6999999999999998951424", buffer.begin()));
CHECK_EQ(22, point);
......@@ -467,29 +470,27 @@ TEST(FastFixedVariousDoubles) {
CHECK_EQ(0, strcmp("1", buffer.begin()));
CHECK_EQ(-19, point);
CHECK(FastFixedDtoa(9.1193616301674545152000000e+19, 0,
buffer, &length, &point));
CHECK(FastFixedDtoa(9.1193616301674545152000000e+19, 0, buffer, &length,
&point));
CHECK_EQ(0, strcmp("91193616301674545152", buffer.begin()));
CHECK_EQ(20, point);
CHECK(FastFixedDtoa(4.8184662102767651659096515e-04, 19,
buffer, &length, &point));
CHECK(FastFixedDtoa(4.8184662102767651659096515e-04, 19, buffer, &length,
&point));
CHECK_EQ(0, strcmp("4818466210276765", buffer.begin()));
CHECK_EQ(-3, point);
CHECK(FastFixedDtoa(1.9023164229540652612705182e-23, 8,
buffer, &length, &point));
CHECK(FastFixedDtoa(1.9023164229540652612705182e-23, 8, buffer, &length,
&point));
CHECK_EQ(0, strcmp("", buffer.begin()));
CHECK_EQ(-8, point);
CHECK(FastFixedDtoa(1000000000000000128.0, 0,
buffer, &length, &point));
CHECK(FastFixedDtoa(1000000000000000128.0, 0, buffer, &length, &point));
CHECK_EQ(0, strcmp("1000000000000000128", buffer.begin()));
CHECK_EQ(19, point);
}
TEST(FastFixedDtoaGayFixed) {
TEST_F(FixedDtoaTest, FastFixedDtoaGayFixed) {
char buffer_container[kBufferSize];
Vector<char> buffer(buffer_container, kBufferSize);
bool status;
......@@ -502,8 +503,7 @@ TEST(FastFixedDtoaGayFixed) {
const PrecomputedFixed current_test = precomputed[i];
double v = current_test.v;
int number_digits = current_test.number_digits;
status = FastFixedDtoa(v, number_digits,
buffer, &length, &point);
status = FastFixedDtoa(v, number_digits, buffer, &length, &point);
CHECK(status);
CHECK_EQ(current_test.decimal_point, point);
CHECK_GE(number_digits, length - point);
......
......@@ -31,7 +31,7 @@
#include "src/init/v8.h"
#include "test/cctest/gay-fixed.h"
#include "test/unittests/gay-fixed.h"
namespace v8 {
namespace base {
......@@ -31,7 +31,7 @@
#include "src/init/v8.h"
#include "test/cctest/gay-precision.h"
#include "test/unittests/gay-precision.h"
namespace v8 {
namespace base {
......@@ -31,7 +31,7 @@
#include "src/init/v8.h"
#include "test/cctest/gay-shortest.h"
#include "test/unittests/gay-shortest.h"
namespace v8 {
namespace base {
......@@ -223,6 +223,8 @@
'LogMapsTest.*': [SKIP],
'LogMapsCodeTest.LogMapsDetailsCode': [SKIP],
'LogFunctionEventsTest.LogFunctionEvents': [SKIP],
'BignumDtoaTest.*': [SKIP],
'DtoaTest.*': [SKIP],
}], # variant == no_wasm_traps
##############################################################################
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment