MCPcopy Create free account
hub / github.com/apache/arrow / GetValues

Method GetValues

cpp/src/arrow/util/decimal_test.cc:980–1067  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

978class TestDecimalFromRealDouble : public ::testing::Test {
979 protected:
980 std::vector<FromDoubleTestParam> GetValues() {
981 std::vector<FromDoubleTestParam> values = {
982 // -- Stress the 53 bits of precision of a double
983 // 2**63 + 2**11
984 FromDoubleTestParam{9.223372036854778e+18, 19, 0, "9223372036854777856"},
985 // 2**64 - 2**11
986 FromDoubleTestParam{1.844674407370955e+19, 20, 0, "18446744073709549568"},
987 // 2**64 + 2**11
988 FromDoubleTestParam{1.8446744073709556e+19, 20, 0, "18446744073709555712"},
989 // 2**126
990 FromDoubleTestParam{8.507059173023462e+37, 38, 0,
991 "85070591730234615865843651857942052864"},
992 // 2**126 - 2**74
993 FromDoubleTestParam{8.50705917302346e+37, 38, 0,
994 "85070591730234596976377720379361198080"},
995 // 2**36 - 2**-16
996 FromDoubleTestParam{68719476735.999985, 11, 0, "68719476736"},
997 FromDoubleTestParam{68719476735.999985, 38, 27,
998 "68719476735.999984741210937500000000000"},
999 // -- Other cases
1000 // Almost 10**38 (minus 2**73)
1001 FromDoubleTestParam{9.999999999999998e+37, 38, 0,
1002 "99999999999999978859343891977453174784"},
1003 FromDoubleTestParam{9.999999999999998e+27, 38, 10,
1004 "9999999999999997384096481280.0000000000"},
1005 // 10**N (sometimes fits in N digits)
1006 FromDoubleTestParam{1e23, 23, 0, "99999999999999991611392"},
1007 FromDoubleTestParam{1e23, 24, 1, "99999999999999991611392.0"},
1008 FromDoubleTestParam{1e36, 37, 0, "1000000000000000042420637374017961984"},
1009 FromDoubleTestParam{1e36, 38, 1, "1000000000000000042420637374017961984.0"},
1010 FromDoubleTestParam{1e37, 37, 0, "9999999999999999538762658202121142272"},
1011 FromDoubleTestParam{1e37, 38, 1, "9999999999999999538762658202121142272.0"},
1012 FromDoubleTestParam{1e38, 38, 0, "99999999999999997748809823456034029568"},
1013 // Hand-picked test cases that can involve precision issues.
1014 // More comprehensive testing is done in the PyArrow test suite.
1015 FromDoubleTestParam{9.223372036854778e+10, 19, 8, "92233720368.54777527"},
1016 FromDoubleTestParam{1.8446744073709556e+15, 20, 4, "1844674407370955.5000"},
1017 FromDoubleTestParam{999999999999999.0, 16, 1, "999999999999999.0"},
1018 FromDoubleTestParam{9999999999999998.0, 17, 1, "9999999999999998.0"},
1019 FromDoubleTestParam{999999999999999.9, 16, 1, "999999999999999.9"},
1020 FromDoubleTestParam{9999999987., 38, 22, "9999999987.0000000000000000000000"},
1021 FromDoubleTestParam{9999999987., 38, 28,
1022 "9999999987.0000000000000000000000000000"},
1023 };
1024 std::vector<FromDoubleTestParam> type_dependent_values;
1025 if (std::is_same_v<T, Decimal128>) {
1026 // clang-format off
1027 type_dependent_values = {
1028 // 1 - 2**-52
1029 // XXX the result should be 0.99999999999999977795539507496869191527
1030 // but our algorithm loses the right digit.
1031 FromDoubleTestParam{0.9999999999999998, 38, 38,
1032 "0.99999999999999977795539507496869191520"},
1033 FromDoubleTestParam{0.9999999999999998, 20, 20, "0.99999999999999977796"},
1034 FromDoubleTestParam{0.9999999999999998, 16, 16, "0.9999999999999998"},
1035 };
1036 // clang-format on
1037 } else if (std::is_same_v<T, Decimal256>) {

Callers

nothing calls this directly

Calls 3

insertMethod · 0.45
endMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected